/** * 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; }
@Expose("orderedItem") public List<? extends Product> getItems() { return items; }
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); } } }
@Expose("orderedItem") public List<? extends Product> getItems() { return items; }
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); } } }
/** * Created by Dietrich on 17.02.2015. */ @Expose("CafeOrCoffeeShop") public class Store extends ResourceSupport { public String name = "Kaffeehaus Hagen"; private List<Offer> offers = new ArrayList<Offer>(); public String getName() { return name; } public List<Offer> getMakesOffer() { return offers; } public void addOffer(Offer offer) { this.offers.add(offer); } }
@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; }
/** * Created by Dietrich on 17.02.2015. */ @Expose("CafeOrCoffeeShop") public class Store extends ResourceSupport { public String name = "Kaffeehaus Hagen"; private List<Offer> offers = new ArrayList<Offer>(); public String getName() { return name; } public List<Offer> getMakesOffer() { return offers; } public void addOffer(Offer offer) { this.offers.add(offer); } }
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); }
/** * Mixin for json-ld serialization of Resources. Created by dschulten on 14.09.2014. */ @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY) @Term(define = "hydra", as = "http://www.w3.org/ns/hydra/core#") @Expose("hydra:Collection") public abstract class ResourcesMixin<T> extends Resources<T> { @Override @JsonProperty("hydra:member") @ContextProvider public Collection<T> getContent() { return super.getContent(); } @Override @JsonSerialize(using = LinkListSerializer.class) @JsonUnwrapped public List<Link> getLinks() { return super.getLinks(); } }
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); }
/** * Mixin for json-ld serialization of PagedResources. */ @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY) @Term(define = "hydra", as = "http://www.w3.org/ns/hydra/core#") @Expose("hydra:Collection") public abstract class PagedResourcesMixin<T> extends PagedResources<T> { @Override @JsonProperty("hydra:member") @ContextProvider public Collection<T> getContent() { return super.getContent(); } @Override @JsonSerialize(using = LinkListSerializer.class) @JsonUnwrapped public List<Link> getLinks() { return super.getLinks(); } @Override @JsonIgnore // used by PagedResourcesSerializer instead public PageMetadata getMetadata() { return super.getMetadata(); } }
/** * 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)) {