@Override public void setDatatype(Datatype<V> datatype) { Preconditions.checkNotNullArgument(datatype); this.datatype = datatype; }
@SuppressWarnings("unchecked") @Override public <T> T getPrototype(String name, Object... args) { Preconditions.checkNotNullArgument(name, "name is null"); return (T) applicationContext.getBean(name, args); }
@Override public String getPasswordHash(UUID userId, String password) { checkNotNullArgument(userId); checkNotNullArgument(password); return encryptionModule.getPasswordHash(userId, password); }
/** * @return true if the first MetaClass is equal or an ancestor of the second. */ public boolean isAssignableFrom(MetaClass metaClass, MetaClass other) { checkNotNullArgument(metaClass); checkNotNullArgument(other); return metaClass.equals(other) || metaClass.getDescendants().contains(other); }
public <L> void addListener(Class<L> listenerClass, L listener) { Preconditions.checkNotNullArgument(listener, "listener cannot be null"); if (events == null) { events = new IdentityHashMap<>(EVENTS_MAP_EXPECTED_MAX_SIZE); } List<Object> listeners = events.computeIfAbsent(listenerClass, clazz -> new ArrayList<>(EVENTS_LIST_INITIAL_CAPACITY)); if (!listeners.contains(listener)) { listeners.add(listener); } }
public static Object getValue(Entity entity, String attribute) { Preconditions.checkNotNullArgument(entity, "entity is null"); Field field = FieldUtils.getField(entity.getClass(), attribute, true); if (field == null) throw new RuntimeException(String.format("Cannot find field '%s' in class %s", attribute, entity.getClass().getName())); try { return field.get(entity); } catch (IllegalAccessException e) { throw new RuntimeException(String.format("Unable to set value to %s.%s", entity.getClass().getSimpleName(), attribute), e); } }
/** * Creates new {@code Sort} for the given list of orders. */ public static Sort by(List<Order> orders) { Preconditions.checkNotNullArgument(orders, "orders list is null"); return orders.isEmpty() ? Sort.UNSORTED : new Sort(orders); }
public static void setValue(Entity entity, String attribute, @Nullable Object value) { Preconditions.checkNotNullArgument(entity, "entity is null"); Field field = FieldUtils.getField(entity.getClass(), attribute, true); if (field == null) throw new RuntimeException(String.format("Cannot find field '%s' in class %s", attribute, entity.getClass().getName())); try { field.set(entity, value); } catch (IllegalAccessException e) { throw new RuntimeException(String.format("Unable to set value to %s.%s", entity.getClass().getSimpleName(), attribute), e); } }
@Override @Deprecated public String getPlainHash(String content) { checkNotNullArgument(content); return encryptionModule.getPlainHash(content); }
@Override public void setEnabled(Boolean enabled) { if (component != null) { checkNotNullArgument(enabled, "Unable to reset enabled flag for the bound FieldConfig"); component.setEnabled(enabled); } else { this.targetEnabled = enabled; } }
/** * Determine whether the given metaclass represents a persistent entity. * <p> * A persistent entity is an entity that is managed by ORM (i.e. registered in a persistence.xml file) * and is not a MappedSuperclass or Embeddable. */ public boolean isPersistent(MetaClass metaClass) { checkNotNullArgument(metaClass, "metaClass is null"); return Boolean.TRUE.equals(metaClass.getAnnotations().get(PERSISTENT_ANN_NAME)) && metaClass.getJavaClass().isAnnotationPresent(javax.persistence.Entity.class); }
public static void setSecurityState(Entity entity, SecurityState securityState) { Preconditions.checkNotNullArgument(entity, "Entity is null"); if (entity instanceof BaseGenericIdEntity) { BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) entity; baseGenericIdEntity.__securityState = securityState; } else if (entity instanceof EmbeddableEntity) { EmbeddableEntity embeddableEntity = (EmbeddableEntity) entity; embeddableEntity.__securityState = securityState; } else { throw new IllegalArgumentException(String.format("Entity with type [%s] does not support security state", entity.getMetaClass().getName())); } }
@Override public void removeDomAttribute(Component component, String attributeName) { checkNotNullArgument(component); checkNotNullArgument(attributeName); com.vaadin.ui.Component vComponent = component.unwrapComposition(com.vaadin.ui.Component.class); HtmlAttributesExtension.get(vComponent) .removeDomAttribute(attributeName); }
@Override public void removeCssProperty(Component component, String propertyName) { checkNotNullArgument(component); checkNotNullArgument(propertyName); com.vaadin.ui.Component vComponent = component.unwrapComposition(com.vaadin.ui.Component.class); HtmlAttributesExtension.get(vComponent) .removeCssProperty(propertyName); }
/** * Determine whether the given class represents a non-persistent entity. * <p> * A non-persistent entity is not managed by ORM (i.e. registered in a metadata.xml file). * <p> * Note that {@code isNotPersistent()} is not the same as {@code !isPersistent()}, because the latter does not * include MappedSuperclass and Embeddable entities that a still managed by ORM. */ public boolean isNotPersistent(Class aClass) { checkNotNullArgument(aClass, "class is null"); return isNotPersistent(metadata.getClassNN(aClass)); }
@Override public String getMessage(Enum caller) { checkNotNullArgument(caller, "Enum parameter 'caller' is null"); Locale loc = getUserLocale(); return getMessage(caller, loc); }
/** * Determine whether the given class represents a persistent entity. * <p> * A persistent entity is an entity that is managed by ORM (i.e. registered in a persistence.xml file) * and is not a MappedSuperclass or Embeddable. */ public boolean isPersistent(Class aClass) { checkNotNullArgument(aClass, "class is null"); return isPersistent(metadata.getClassNN(aClass)); }
@Override public String formatSubstitution(@Nonnull User user, @Nullable User substitutedUser) { Preconditions.checkNotNullArgument(user); if (substitutedUser == null || user.equals(substitutedUser)) { return formatOfficial(user); } else { return messages.formatMessage(getClass(), "onBehalfOf", formatOfficial(user), formatOfficial(substitutedUser)); } }
/** * @return list of related properties defined in {@link com.haulmont.chile.core.annotations.MetaProperty#related()} * or empty list */ public List<String> getRelatedProperties(Class<?> entityClass, String property) { checkNotNullArgument(entityClass, "entityClass is null"); MetaClass metaClass = metadata.getClassNN(entityClass); return getRelatedProperties(metaClass.getPropertyNN(property)); }
/** * @param javaClass class of the loaded entities */ public LoadContext(Class<E> javaClass) { Preconditions.checkNotNullArgument(javaClass, "javaClass is null"); this.metaClass = AppBeans.get(Metadata.class).getExtendedEntities().getEffectiveMetaClass(javaClass).getName(); }