@Override public String apply(Annotation in) { return extractName(annotationType.cast(in)); }
@Override public String apply(NameExtractor<?> input) { return input.annotationType().getName(); } }));
return annotationToNameExtractor.get(annotation.annotationType()).apply(annotation);
return annotationToNameExtractor.get(annotation.annotationType()).apply(annotation);
return annotationToNameExtractor.get(annotation.annotationType()).apply(annotation);
for (Annotation annotation : c.getParameters().get(index).getAnnotations()) { if (annotationToNameExtractor.containsKey(annotation.annotationType())) { name = annotationToNameExtractor.get(annotation.annotationType()).apply(annotation); break;
for (Annotation annotation : c.getParameters().get(index).getAnnotations()) { if (annotationToNameExtractor.containsKey(annotation.annotationType())) { name = annotationToNameExtractor.get(annotation.annotationType()).apply(annotation); break;
for (Annotation annotation : c.getParameters().get(index).getAnnotations()) { if (annotationToNameExtractor.containsKey(annotation.annotationType())) { name = annotationToNameExtractor.get(annotation.annotationType()).apply(annotation); break;
public void testExtractSerializedName() throws Exception { NameExtractor<SerializedName> extractor = new ExtractSerializedName(); assertEquals(extractor.extractName(SimpleTest.class.getDeclaredField("a").getAnnotation(SerializedName.class)), "aardvark"); try { extractor.extractName(SimpleTest.class.getDeclaredField("b").getAnnotation(SerializedName.class)); fail(); } catch (NullPointerException e) { } try { extractor.extractName(SimpleTest.class.getDeclaredField("c").getAnnotation(SerializedName.class)); fail(); } catch (NullPointerException e) { } try { extractor.extractName(SimpleTest.class.getDeclaredField("d").getAnnotation(SerializedName.class)); fail(); } catch (NullPointerException e) { } }
public void testExtractSerializedName() throws Exception { NameExtractor<SerializedName> extractor = new ExtractSerializedName(); assertEquals(extractor.extractName(SimpleTest.class.getDeclaredField("a").getAnnotation(SerializedName.class)), "aardvark"); try { extractor.extractName(SimpleTest.class.getDeclaredField("b").getAnnotation(SerializedName.class)); fail(); } catch (NullPointerException e) { } try { extractor.extractName(SimpleTest.class.getDeclaredField("c").getAnnotation(SerializedName.class)); fail(); } catch (NullPointerException e) { } try { extractor.extractName(SimpleTest.class.getDeclaredField("d").getAnnotation(SerializedName.class)); fail(); } catch (NullPointerException e) { } }
@VisibleForTesting <T> String translateName(Invokable<T, T> c, int index) { String name = null; if (markers.contains(ConstructorProperties.class) && c.getAnnotation(ConstructorProperties.class) != null) { String[] names = c.getAnnotation(ConstructorProperties.class).value(); if (names != null && names.length > index) { name = names[index]; } } for (Annotation annotation : c.getParameters().get(index).getAnnotations()) { if (annotationToNameExtractor.containsKey(annotation.annotationType())) { name = annotationToNameExtractor.get(annotation.annotationType()).apply(annotation); break; } } return name; } }
@VisibleForTesting <T> String translateName(Invokable<T, T> c, int index) { String name = null; if (markers.contains(ConstructorProperties.class) && c.getAnnotation(ConstructorProperties.class) != null) { String[] names = c.getAnnotation(ConstructorProperties.class).value(); if (names != null && names.length > index) { name = names[index]; } } for (Annotation annotation : c.getParameters().get(index).getAnnotations()) { if (annotationToNameExtractor.containsKey(annotation.annotationType())) { name = annotationToNameExtractor.get(annotation.annotationType()).apply(annotation); break; } } return name; } }
public void testExtractNamed() throws Exception { NameExtractor<Named> extractor = new ExtractNamed(); try { extractor.extractName(SimpleTest.class.getDeclaredField("a").getAnnotation(Named.class)); } catch (NullPointerException e) { } try { extractor.extractName(SimpleTest.class.getDeclaredField("b").getAnnotation(Named.class)); fail(); } catch (NullPointerException e) { } assertEquals(extractor.extractName(SimpleTest.class.getDeclaredField("c").getAnnotation(Named.class)), "cat"); assertEquals(extractor.extractName(SimpleTest.class.getDeclaredField("d").getAnnotation(Named.class)), "dog"); }
@VisibleForTesting <T> String translateName(Invokable<T, T> c, int index) { String name = null; if (markers.contains(ConstructorProperties.class) && c.getAnnotation(ConstructorProperties.class) != null) { String[] names = c.getAnnotation(ConstructorProperties.class).value(); if (names != null && names.length > index) { name = names[index]; } } for (Annotation annotation : c.getParameters().get(index).getAnnotations()) { if (annotationToNameExtractor.containsKey(annotation.annotationType())) { name = annotationToNameExtractor.get(annotation.annotationType()).apply(annotation); break; } } return name; } }
public void testExtractNamed() throws Exception { NameExtractor<Named> extractor = new ExtractNamed(); try { extractor.extractName(SimpleTest.class.getDeclaredField("a").getAnnotation(Named.class)); } catch (NullPointerException e) { } try { extractor.extractName(SimpleTest.class.getDeclaredField("b").getAnnotation(Named.class)); fail(); } catch (NullPointerException e) { } assertEquals(extractor.extractName(SimpleTest.class.getDeclaredField("c").getAnnotation(Named.class)), "cat"); assertEquals(extractor.extractName(SimpleTest.class.getDeclaredField("d").getAnnotation(Named.class)), "dog"); }
@Override public String apply(Annotation in) { return extractName(annotationType.cast(in)); }
@Override public String apply(Annotation in) { return extractName(annotationType.cast(in)); }
@Override public Class<? extends Annotation> apply(NameExtractor<?> input) { return input.annotationType(); } });
@Override public String apply(Annotation in) { return extractName(annotationType.cast(in)); }
@Override public Class<? extends Annotation> apply(NameExtractor<?> input) { return input.annotationType(); } });