@Override public boolean isNative() { return field.isAnnotationPresent(Native.class); }
public String init(TypeOracle oracle, JField targetWidget, JType targetType, JField targetFieldType, JField targetEntityField, String variable, List<JField> fields) { StringBuilder builder = new StringBuilder(variable + ".setDefaultTitleValues(new String[] {"); Iterator<JField> iter = fields.iterator(); JField fld; String fieldName; while (iter.hasNext()) { if ((fld = iter.next()).isAnnotationPresent(FriendlyName.class)) { fieldName = fld.getAnnotation(FriendlyName.class).value(); } else { fieldName = fld.getName(); } builder.append("\"").append(fieldName).append("\""); if (iter.hasNext()) builder.append(", "); } return builder.append("});").toString(); } }
@Override public Class<? extends InstanceCreator<?, ?>> getInstanceCreator() { Class<? extends InstanceCreator<?, ?>> instanceCreator = null; if (field.isAnnotationPresent(CreateWith.class)) { instanceCreator = field.getAnnotation(CreateWith.class).value(); } return instanceCreator; }
@Override public Class<? extends PropertyGetter<?, ?>> getGetter() { Class<? extends PropertyGetter<?, ?>> getter = null; if (field.isAnnotationPresent(Getter.class)) { getter = field.getAnnotation(Getter.class).value(); } return getter; }
@Override public Class<? extends Converter<?>> getConverter() { Class<? extends Converter<?>> converter = null; if (field.isAnnotationPresent(Convert.class)) { converter = field.getAnnotation(Convert.class).value(); } return converter; }
@Override public String getFormat() { String format = null; if (field.isAnnotationPresent(Format.class)) { format = field.getAnnotation(Format.class).value(); } return format; }
@Override public WhitespaceHandling getWhitespaceHandling() { WhitespaceHandling whitespaceHandling = REMOVE; if (field.isAnnotationPresent(Whitespace.class)) { whitespaceHandling = field.getAnnotation(Whitespace.class).value(); } return whitespaceHandling; }
@Override public Class<? extends PropertySetter<?, ?>> getSetter() { Class<? extends PropertySetter<?, ?>> setter = null; if (field.isAnnotationPresent(Setter.class)) { setter = field.getAnnotation(Setter.class).value(); } return setter; } }
@Override public String getPath() { String path = null; if (field.isAnnotationPresent(Id.class)) { path = field.getAnnotation(Id.class).value(); } else if (field.isAnnotationPresent(IdRef.class)) { path = field.getAnnotation(IdRef.class).value(); } else if (field.isAnnotationPresent(Path.class)) { path = field.getAnnotation(Path.class).value(); } return path; }
@Override public int getOrder() { int order = TypeContext.nextOrder(); if (field.isAnnotationPresent(Order.class)) { order = field.getAnnotation(Order.class).value(); } return order; }
private boolean includeField(JField field, Set<Class<? extends Annotation>> mustHaveAnnotations) { if (mustHaveAnnotations.isEmpty()) { return true; } for (Class<? extends Annotation> a : mustHaveAnnotations) { if (field.isAnnotationPresent(a)) { return true; } } logger.debug("Skipping field %s in %s as it is not annotated with any of %s", field.getName(), field .getEnclosingType().getParameterizedQualifiedSourceName(), mustHaveAnnotations); return false; }
public static List<Injection> getInjectedFields(JClassType dType) { List<Injection> injects = new ArrayList<Injection>(); for (JField f : dType.getFields()) { if(f.isAnnotationPresent(NgInjected.class)) { JClassType pType = f.getType().isClassOrInterface(); if (pType != null) { NgInject pInject = pType.getAnnotation(NgInject.class); if (pInject != null) { injects.add(Injection.create(pType, f.getName(),pInject.name())); } } } } return injects; } }
/** * Scans the owner class to find all fields annotated with @UiField, and puts * them in {@link #uiFields} and {@link #uiFieldTypes}. * * @param ownerType the type of the owner class */ private void findUiFields(JClassType ownerType) throws UnableToCompleteException { JField[] fields = ownerType.getFields(); for (JField field : fields) { if (field.isAnnotationPresent(UiField.class)) { JClassType ownerFieldType = field.getType().isClassOrInterface(); if (ownerFieldType == null) { logger.die("Field type is not a class in field " + field.getName()); } OwnerField ownerField = new OwnerField(field, logger, context); String ownerFieldName = field.getName(); uiFields.put(ownerFieldName, ownerField); uiFieldTypes.put(ownerFieldType, ownerField); } } // Recurse to superclass JClassType superclass = ownerType.getSuperclass(); if (superclass != null) { findUiFields(superclass); } }
/** * Scans the owner class to find all fields annotated with @UiField, and puts * them in {@link #uiFields} and {@link #uiFieldTypes}. * * @param ownerType the type of the owner class */ private void findUiFields(JClassType ownerType) throws UnableToCompleteException { JField[] fields = ownerType.getFields(); for (JField field : fields) { if (field.isAnnotationPresent(UiField.class)) { JClassType ownerFieldType = field.getType().isClassOrInterface(); if (ownerFieldType == null) { logger.die("Field type is not a class in field " + field.getName()); } OwnerField ownerField = new OwnerField(field, logger, context); String ownerFieldName = field.getName(); uiFields.put(ownerFieldName, ownerField); uiFieldTypes.put(ownerFieldType, ownerField); } } // Recurse to superclass JClassType superclass = ownerType.getSuperclass(); if (superclass != null) { findUiFields(superclass); } }
protected boolean skipField(JField field, Set<Class<? extends Annotation>> annotationsToSkip) { if (field.isTransient() || field.isStatic()) { logger.debug("Skipping %s field %s in %s", field.isTransient() ? "transient" : "static", field.getName(), field.getEnclosingType().getParameterizedQualifiedSourceName()); return true; } for (Class<? extends Annotation> a : annotationsToSkip) { if (field.isAnnotationPresent(a)) { logger.debug("Skipping field %s in %s as it is annotated with @%s", field.getName(), field .getEnclosingType().getParameterizedQualifiedSourceName(), a.getClass().getName()); return true; } } return false; }
if (currField.isAnnotationPresent(WidgetMapper.class) && widgetMapper.isAssignableFrom(currField.getType().isClassOrInterface())) { WidgetMapper mf = currField.getAnnotation(WidgetMapper.class); if (currField.isAnnotationPresent(EntityFields.class)) { EntityFields ef = currField.getAnnotation(EntityFields.class); for (String fieldName : ef.value()) { else if (currField.isAnnotationPresent(EntityMapped.class)) { EntityMapped entityMappedA = currField.getAnnotation(EntityMapped.class); if (fld.isAnnotationPresent(MapField.class)) { MapField mapFieldA = fld.getAnnotation(MapField.class); toEntityField = "".equals(mapFieldA.value()) ? entityFieldName : mapFieldA.value(); else if (currField.isAnnotationPresent(AddAllTo.class)) { String copyToField = currField.getAnnotation(AddAllTo.class).value(); String copyFromField = currField.getName();
private boolean isPropertyConstrained(PropertyDescriptor p, boolean useField) { // cascaded counts as constrained // we must know if the @Valid annotation is on a field or a getter JClassType jClass = beanHelper.getJClass(); if (useField && jClass.findField(p.getPropertyName()).isAnnotationPresent(Valid.class)) { return true; } else if (!useField && jClass.findMethod(asGetter(p),NO_ARGS).isAnnotationPresent(Valid.class)) { return true; } // for non-cascaded properties for (ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) { org.hibernate.validator.metadata.ConstraintDescriptorImpl<?> constraintHibernate = (org.hibernate.validator.metadata.ConstraintDescriptorImpl<?>) constraint; if (constraintHibernate.getElementType() == (useField ? ElementType.FIELD : ElementType.METHOD)) { return true; } } return false; }
private boolean isPropertyConstrained(PropertyDescriptor p, boolean useField) { // cascaded counts as constrained // we must know if the @Valid annotation is on a field or a getter JClassType jClass = beanHelper.getJClass(); if (useField && jClass.findField(p.getPropertyName()).isAnnotationPresent(Valid.class)) { return true; } else if (!useField && jClass.findMethod(asGetter(p),NO_ARGS).isAnnotationPresent(Valid.class)) { return true; } // for non-cascaded properties for (ConstraintDescriptor<?> constraint : p.getConstraintDescriptors()) { org.hibernate.validator.metadata.ConstraintDescriptorImpl<?> constraintHibernate = (org.hibernate.validator.metadata.ConstraintDescriptorImpl<?>) constraint; if (constraintHibernate.getElementType() == (useField ? ElementType.FIELD : ElementType.METHOD)) { return true; } } return false; }
private boolean isPropertyConstrained(final PropertyDescriptor ppropertyDescription, final boolean useField) { // cascaded counts as constrained // we must know if the @Valid annotation is on a field or a getter final JClassType jClass = beanHelper.getJClass(); if (useField && jClass.findField(ppropertyDescription.getPropertyName()) .isAnnotationPresent(Valid.class)) { return true; } else if (!useField && jClass.findMethod(asGetter(ppropertyDescription), NO_ARGS) .isAnnotationPresent(Valid.class)) { return true; } // for non-cascaded properties for (final ConstraintDescriptor<?> constraint : ppropertyDescription .getConstraintDescriptors()) { final org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?> constraintHibernate = (org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl<?>) constraint; if (constraintHibernate .getElementType() == (useField ? ElementType.FIELD : ElementType.METHOD)) { return true; } } return false; }