@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(); } } )); } } } }
@Override public List<String> getAuthorizationGrants() { if (!"oauth_2_0".equalsIgnoreCase(getName())) { return Collections.emptyList(); } TypeInstance structuredValue = this.securitySchemeRef.structuredValue(); if (structuredValue == null) { return Collections.emptyList(); } List<String> authorizationGrants = new ArrayList<>(); List<TypeInstanceProperty> properties = structuredValue.properties(); for (TypeInstanceProperty property : properties) { if ("authorizationGrants".equalsIgnoreCase(property.name())) { authorizationGrants.add(property.value().value().toString()); } } return authorizationGrants; } }
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; }
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; }