private boolean isIndexed(Method method) { final AnnotationDelegate annotations = Common.getAnnotationDelegate(fieldNameConverter, method); final Indexed indexed = annotations.getAnnotation(Indexed.class); return indexed != null; }
private boolean isIndexed(Method method) { final AnnotationDelegate annotations = Common.getAnnotationDelegate(fieldNameConverter, method); final Indexed indexed = annotations.getAnnotation(Indexed.class); return indexed != null; }
public static List<String> getSearchableFields(EntityManager manager, Class<? extends RawEntity<?>> type) { List<String> back = new ArrayList<String>(); for (Method m : type.getMethods()) { Searchable annot = getAnnotationDelegate(manager.getNameConverters().getFieldNameConverter(), m).getAnnotation(Searchable.class); if (annot != null) { Class<?> attributeType = Common.getAttributeTypeFromMethod(m); String name = manager.getNameConverters().getFieldNameConverter().getName(m); // don't index Entity fields if (name != null && !RawEntity.class.isAssignableFrom(attributeType) && !back.contains(name)) { back.add(name); } } } return back; }
public static List<String> getSearchableFields(EntityManager manager, Class<? extends RawEntity<?>> type) { List<String> back = new ArrayList<String>(); for (Method m : type.getMethods()) { Searchable annot = getAnnotationDelegate(manager.getNameConverters().getFieldNameConverter(), m).getAnnotation(Searchable.class); if (annot != null) { Class<?> attributeType = Common.getAttributeTypeFromMethod(m); String name = manager.getNameConverters().getFieldNameConverter().getName(m); // don't index Entity fields if (name != null && !RawEntity.class.isAssignableFrom(attributeType) && !back.contains(name)) { back.add(name); } } } return back; }
@SuppressWarnings("unchecked") private FieldInfo createFieldInfo(String fieldName, Method accessor, Method mutator) { Class fieldType = Common.getAttributeTypeFromMethod(MoreObjects.firstNonNull(accessor, mutator)); AnnotationDelegate annotations = getAnnotations(accessor, mutator); Generator generatorAnnotation = annotations.getAnnotation(Generator.class); return new ImmutableFieldInfo( fieldName, fieldType.isAnnotationPresent(Polymorphic.class) ? nameConverters.getFieldNameConverter().getPolyTypeName(MoreObjects.firstNonNull(accessor, mutator)) : null, accessor, mutator, fieldType, typeManager.getType(fieldType), annotations.isAnnotationPresent(PrimaryKey.class), !annotations.isAnnotationPresent(NotNull.class), annotations.isAnnotationPresent(Transient.class), annotations.isAnnotationPresent(AutoIncrement.class), annotations.isAnnotationPresent(Default.class), generatorAnnotation != null ? generatorAnnotation.value() : null ); }
@SuppressWarnings("unchecked") private FieldInfo createFieldInfo(String fieldName, Method accessor, Method mutator) { Class fieldType = Common.getAttributeTypeFromMethod(MoreObjects.firstNonNull(accessor, mutator)); AnnotationDelegate annotations = getAnnotations(accessor, mutator); Generator generatorAnnotation = annotations.getAnnotation(Generator.class); return new ImmutableFieldInfo( fieldName, fieldType.isAnnotationPresent(Polymorphic.class) ? nameConverters.getFieldNameConverter().getPolyTypeName(MoreObjects.firstNonNull(accessor, mutator)) : null, accessor, mutator, fieldType, typeManager.getType(fieldType), annotations.isAnnotationPresent(PrimaryKey.class), !annotations.isAnnotationPresent(NotNull.class), annotations.isAnnotationPresent(Transient.class), annotations.isAnnotationPresent(AutoIncrement.class), annotations.isAnnotationPresent(Default.class), generatorAnnotation != null ? generatorAnnotation.value() : null ); }
final Object defaultValue = convertStringDefaultValue(annotations.getAnnotation(Default.class).value(), sqlType, method); if (type.isEnum() && ((Integer) defaultValue) > EnumUtils.size((Class<? extends Enum>) type) - 1) { throw new ActiveObjectsConfigurationException("There is no enum value of '" + type + "'for which the ordinal is " + defaultValue); field.setJdbcType(java.sql.Types.VARCHAR); if (annotations.getAnnotation(NotNull.class) != null) { field.setNotNull(true);
final Object defaultValue = convertStringDefaultValue(annotations.getAnnotation(Default.class).value(), sqlType, method); if (type.isEnum() && ((Integer) defaultValue) > EnumUtils.size((Class<? extends Enum>) type) - 1) { throw new ActiveObjectsConfigurationException("There is no enum value of '" + type + "'for which the ordinal is " + defaultValue); field.setJdbcType(java.sql.Types.VARCHAR); if (annotations.getAnnotation(NotNull.class) != null) { field.setNotNull(true);
public static TypeInfo<?> getSQLTypeFromMethod(TypeManager typeManager, Class<?> type, Method method, AnnotationDelegate annotations) { TypeQualifiers qualifiers = qualifiers(); StringLength lengthAnno = annotations.getAnnotation(StringLength.class); if (lengthAnno != null) { final int length = lengthAnno.value(); if (length > MAX_STRING_LENGTH) { throw new ActiveObjectsConfigurationException("@StringLength must be <= " + MAX_STRING_LENGTH + " or UNLIMITED").forMethod(method); } try { qualifiers = qualifiers.stringLength(length); } catch (ActiveObjectsConfigurationException e) { throw new ActiveObjectsConfigurationException(e.getMessage()).forMethod(method); } } return typeManager.getType(type, qualifiers); }
public static TypeInfo<?> getSQLTypeFromMethod(TypeManager typeManager, Class<?> type, Method method, AnnotationDelegate annotations) { TypeQualifiers qualifiers = qualifiers(); StringLength lengthAnno = annotations.getAnnotation(StringLength.class); if (lengthAnno != null) { final int length = lengthAnno.value(); if (length > MAX_STRING_LENGTH) { throw new ActiveObjectsConfigurationException("@StringLength must be <= " + MAX_STRING_LENGTH + " or UNLIMITED").forMethod(method); } try { qualifiers = qualifiers.stringLength(length); } catch (ActiveObjectsConfigurationException e) { throw new ActiveObjectsConfigurationException(e.getMessage()).forMethod(method); } } return typeManager.getType(type, qualifiers); }