private static <T> Object findProperty(AnnotationRef annotationRef, String propName, Function<TypeInstance, T> convert) { // annotationRef.structuredValue().properties().get(0).values().get(0).value() for (TypeInstanceProperty typeInstanceProperty : annotationRef.structuredValue().properties()) { if (typeInstanceProperty.name().equalsIgnoreCase(propName)) { if (typeInstanceProperty.isArray()) { return toValueList(convert, typeInstanceProperty.values()); } else { return convert.apply(typeInstanceProperty.value()); } } } return null; }
@Override public PluginDef apply(@Nullable TypeInstance input) { if (input.properties().size() == 0) { return new PluginDef((String) input.value(), Collections.<String>emptyList()); } else { if ( input.properties().size() == 1 ) { return new PluginDef((String) input.properties().get(0).value().value(), Collections.<String>emptyList()); } else { return new PluginDef((String) input.properties().get(0).value().value(), Lists.transform(input.properties().get(1).values(), new Function<TypeInstance, String>() { @Nullable @Override public String apply(@Nullable TypeInstance input) { return (String) input.value(); } } )); } } } }
@Override public PluginDef apply(@Nullable TypeInstance input) { if (input.properties().size() == 0) { return new PluginDef((String) input.value(), Collections.<String>emptyList()); } else { if (input.properties().size() == 1) { return new PluginDef((String) input.properties().get(0).value().value(), Collections.<String>emptyList()); } else { return new PluginDef((String) input.properties().get(0).value().value(), Lists.transform(input.properties().get(1) .values(), new Function<TypeInstance, String>() { @Nullable @Override public String apply(@Nullable TypeInstance input) { return (String) input.value(); } } )); } } } }
private static Object findProperty(AnnotationRef annotationRef, String propName) { // annotationRef.structuredValue().properties().get(0).values().get(0).value() for (TypeInstanceProperty typeInstanceProperty : annotationRef.structuredValue().properties()) { if (typeInstanceProperty.name().equalsIgnoreCase(propName)) { if (typeInstanceProperty.isArray()) { return toValueList(typeInstanceProperty.values()); } else { return typeInstanceProperty.value().value(); } } } return null; }
private static Object findProperty(AnnotationRef annotationRef, String propName) { // annotationRef.structuredValue().properties().get(0).values().get(0).value() for (TypeInstanceProperty typeInstanceProperty : annotationRef.structuredValue().properties()) { if (typeInstanceProperty.name().equalsIgnoreCase(propName)) { if (typeInstanceProperty.isArray()) { return toValueList(typeInstanceProperty.values()); } else { return typeInstanceProperty.value().value(); } } } return null; }