/** * Gets exposed property or parameter name for properties with an appropriate setter (=write) method. * * @param inputParameter for exposure * @return property name */ private String getWritableExposedPropertyOrPropertyName(PropertyDescriptor inputParameter) { final Method writeMethod = inputParameter.getWriteMethod(); final Expose expose = writeMethod .getAnnotation(Expose.class); String propertyName; if (expose != null) { propertyName = expose.value(); } else { propertyName = inputParameter.getName(); } return propertyName; }
private void addEnumTerms(Map<String, Object> termsMap, Expose expose, String name, Enum value) throws NoSuchFieldException { if (value != null) { Map<String, String> map = new LinkedHashMap<String, String>(); if (expose != null) { map.put(JsonLdKeywords.AT_ID, expose.value()); } map.put(JsonLdKeywords.AT_TYPE, JsonLdKeywords.AT_VOCAB); termsMap.put(name, map); final Expose enumValueExpose = findAnnotation(value.getClass() .getField(value.name()), Expose.class); if (enumValueExpose != null) { termsMap.put(value.toString(), enumValueExpose.value()); } else { // might use upperToCamelCase if nothing is exposed final String camelCaseEnumValue = WordUtils.capitalizeFully(value.toString(), new char[]{'_'}) .replaceAll("_", ""); termsMap.put(value.toString(), camelCaseEnumValue); } } }
private void addEnumTerms(Map<String, Object> termsMap, Expose expose, String name, Enum value) throws NoSuchFieldException { if (value != null) { Map<String, String> map = new LinkedHashMap<String, String>(); if (expose != null) { map.put(JsonLdKeywords.AT_ID, expose.value()); } map.put(JsonLdKeywords.AT_TYPE, JsonLdKeywords.AT_VOCAB); termsMap.put(name, map); final Expose enumValueExpose = findAnnotation(value.getClass() .getField(value.name()), Expose.class); if (enumValueExpose != null) { termsMap.put(value.toString(), enumValueExpose.value()); } else { // might use upperToCamelCase if nothing is exposed final String camelCaseEnumValue = WordUtils.capitalizeFully(value.toString(), new char[]{'_'}) .replaceAll("_", ""); termsMap.put(value.toString(), camelCaseEnumValue); } } }
@Nullable private String getExposedUrl(String plainName, String vocab, Map<String, Object> terms, Expose expose) { final String name; if (expose != null) { name = expose.value(); // expose is better than Java name } else { name = plainName; } String url; if (name.matches("http(s)?://.+")) { url = name; } else if (name.contains(":")) { url = resolveCurie(terms, name); } else { url = makeVocabUrl(vocab, name); } return url; }
private void serializeType(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException { // adds @type attribute, reflecting the simple name of the class or the exposed annotation on the class. final Expose classExpose = getAnnotation(bean.getClass(), Expose.class); // TODO allow to search up the hierarchy for ResourceSupport mixins and cache find result? final Class<?> mixin = provider.getConfig() .findMixInClassFor(bean.getClass()); final Expose mixinExpose = getAnnotation(mixin, Expose.class); final String val; if (mixinExpose != null) { val = mixinExpose.value(); // mixin wins over class } else if (classExpose != null) { val = classExpose.value(); // expose is better than Java type } else { val = bean.getClass() .getSimpleName(); } jgen.writeStringField(AT_TYPE, val); }
protected void serializeType(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (proxyUnwrapper != null) { bean = proxyUnwrapper.unwrapProxy(bean); } // adds @type attribute, reflecting the simple name of the class or the exposed annotation on the class. final Expose classExpose = findAnnotation(bean.getClass(), Expose.class); // TODO allow to search up the hierarchy for ResourceSupport mixins and cache found result? final Class<?> mixin = provider.getConfig() .findMixInClassFor(bean.getClass()); final Expose mixinExpose = findAnnotation(mixin, Expose.class); final String val; if (mixinExpose != null) { val = mixinExpose.value(); // mixin wins over class } else if (classExpose != null) { val = classExpose.value(); // expose is better than Java type } else { val = bean.getClass() .getSimpleName(); } jgen.writeStringField(JsonLdKeywords.AT_TYPE, val); }
/** * Gets exposed property or parameter name. * * @param inputParameter for exposure * @return property name */ private String getExposedPropertyOrParamName(ActionInputParameter inputParameter) { final Expose expose = inputParameter.getAnnotation(Expose.class); String property; if (expose != null) { property = expose.value(); } else { property = inputParameter.getParameterName(); } return property; }
protected void serializeType(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (proxyUnwrapper != null) { bean = proxyUnwrapper.unwrapProxy(bean); } // adds @type attribute, reflecting the simple name of the class or the exposed annotation on the class. final Expose classExpose = findAnnotation(bean.getClass(), Expose.class); // TODO allow to search up the hierarchy for ResourceSupport mixins and cache found result? final Class<?> mixin = provider.getConfig() .findMixInClassFor(bean.getClass()); final Expose mixinExpose = findAnnotation(mixin, Expose.class); final String val; if (mixinExpose != null) { val = mixinExpose.value(); // mixin wins over class } else if (classExpose != null) { val = classExpose.value(); // expose is better than Java type } else { val = bean.getClass() .getSimpleName(); } jgen.writeStringField(JsonLdKeywords.AT_TYPE, val); }
final String typeName; if (classExpose != null) { typeName = classExpose.value(); } else { typeName = requestBodyInputParameter.getParameterType()
String subClass = null; if (expose != null) { subClass = expose.value(); } else { if (List.class.isAssignableFrom(parameterType)) {