public GwtRetention getRetention(JField field) { GwtRetention retention = field.getAnnotation(GwtRetention.class); if (retention == null) { retention = strategy.fieldRetention(); } return retention; }
private void appendPastValidator(SourceWriter w, JField field) { Past pastAnnotation = field.getAnnotation(Past.class); if (pastAnnotation != null) { w.println(", new PastValidator(\"%s\")", pastAnnotation.message()); } }
private void appendNullValidator(SourceWriter w, JField field) { Null nullAnnotation = field.getAnnotation(Null.class); if (nullAnnotation != null) { w.println(", new NullValidator(\"%s\")", nullAnnotation.message()); } }
private void appendTrueValidator(SourceWriter w, JField field) { AssertTrue trueAnnotation = field.getAnnotation(AssertTrue.class); if (trueAnnotation != null) { w.println(", new AssertTrueValidator(\"%s\")", trueAnnotation.message()); } }
private void appendNotNullValidator(SourceWriter w, JField field) { NotNull notNullAnnotation = field.getAnnotation(NotNull.class); if (notNullAnnotation != null) { w.println(", new NotNullValidator(\"%s\")", notNullAnnotation.message()); } }
private void appendFutureValidator(SourceWriter w, JField field) { Future futureAnnotation = field.getAnnotation(Future.class); if (futureAnnotation != null) { w.println(", new FutureValidator(\"%s\")", futureAnnotation.message()); } }
private void appendFalseValidator(SourceWriter w, JField field) { AssertFalse falseAnnotation = field.getAnnotation(AssertFalse.class); if (falseAnnotation != null) { w.println(", new AssertFalseValidator(\"%s\")", falseAnnotation.message()); } }
@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; }
public static EditorAccess via(JField field) { String path = field.getName(); Path pathAnnotation = field.getAnnotation(Editor.Path.class); if (pathAnnotation != null) { path = pathAnnotation.value(); } else if (path.endsWith(EDITOR_SUFFIX)) { path = path.substring(0, path.length() - EDITOR_SUFFIX.length()); } return new EditorAccess(path, field.getType().isClassOrInterface(), field.getName()); }
public static EditorAccess via(JField field) { String path = field.getName(); Path pathAnnotation = field.getAnnotation(Editor.Path.class); if (pathAnnotation != null) { path = pathAnnotation.value(); } else if (path.endsWith(EDITOR_SUFFIX)) { path = path.substring(0, path.length() - EDITOR_SUFFIX.length()); } return new EditorAccess(path, field.getType().isClassOrInterface(), field.getName()); }
private void appendMinValidator(SourceWriter w, JField field) { Min minAnnotation = field.getAnnotation(Min.class); if (minAnnotation != null) { w.println(", new MinValidator(\"%s\", %s)", minAnnotation.message(), minAnnotation.value()); } }
private void appendPatternValidator(SourceWriter w, JField field) { Pattern patternAnnotation = field.getAnnotation(Pattern.class); if (patternAnnotation != null) { w.println(", new PatternValidator(\"%s\", \"%s\")", patternAnnotation.message(), patternAnnotation.regexp() .replace("\\", "\\\\"), patternAnnotation.flags()); } }
private void appendMaxValidator(SourceWriter w, JField field) { Max maxAnnotation = field.getAnnotation(Max.class); if (maxAnnotation != null) { w.println(", new MaxValidator(\"%s\", %s)", maxAnnotation.message(), maxAnnotation.value()); } }
public GwtRetention getRetention(final JField field) { GwtRetention retention = field.getAnnotation(GwtRetention.class); if (retention == null) { if (strategy.memberRetention().length == 0) { retention = strategy.fieldRetention(); } else { retention = strategy.memberRetention()[0]; } } return retention; }
void stubFieldIdAnnotation(JField field, String fieldId, boolean processType) { WithElementId idAnnotation = mock(WithElementId.class); when(field.getAnnotation(WithElementId.class)).thenReturn(idAnnotation); when(idAnnotation.value()).thenReturn(fieldId); when(idAnnotation.processType()).thenReturn(processType); }
@Test public void processField_missingIdAnnotation() { when(field.getAnnotation(WithElementId.class)).thenReturn(null); verifyProcessFieldReturns(false); }
private void appendSizeValidator(SourceWriter w, JField field) { Size sizeAnnotation = field.getAnnotation(Size.class); if (sizeAnnotation != null) { w.println(", new SizeValidator(\"%s\", %s, %s)", sizeAnnotation.message(), sizeAnnotation.min(), sizeAnnotation.max()); } }
boolean processField(JField field) { return !field.isPrivate() && !field.isStatic() && field.getType().isClass() != null && field.getAnnotation(WithElementId.class) != null; }
void stubPassingField(JField field, JClassType fieldType, String fieldName) { WithElementId idAnnotation = mock(WithElementId.class); when(field.isPrivate()).thenReturn(false); when(field.isStatic()).thenReturn(false); when(field.getType()).thenReturn(fieldType); when(field.getName()).thenReturn(fieldName); when(fieldType.isClass()).thenReturn(fieldType); when(field.getAnnotation(WithElementId.class)).thenReturn(idAnnotation); when(idAnnotation.value()).thenReturn(""); //$NON-NLS-1$ when(idAnnotation.processType()).thenReturn(true); }