/** * Created by dschulten on 08.12.2014. */ @Term(define = "rdfs", as = "http://www.w3.org/2000/01/rdf-schema#") public class CreativeWork { public final String name; @JsonCreator public CreativeWork(@JsonProperty("name") String name) { this.name = name; } }
private void collectTerms(String name, Map<String, Object> annotatedTermsMap, Term term) { final String define = term.define(); final String as = term.as(); final boolean reverse = term.reverse(); if (annotatedTermsMap.containsKey(as)) { throw new IllegalStateException("duplicate definition of term '" + define + "' in " + name); } if (!reverse) { annotatedTermsMap.put(define, as); } else { Map<String, String> reverseTerm = new LinkedHashMap<String, String>(); reverseTerm.put(JsonLdKeywords.AT_REVERSE, as); annotatedTermsMap.put(define, reverseTerm); } }
/** * Gets explicitly defined terms, e.g. on package, class or mixin. * * @param annotatedElement to find terms * @param name of annotated element, i.e. class name or package name * @return terms */ private Map<String, Object> getAnnotatedTerms(AnnotatedElement annotatedElement, String name) { final Terms annotatedTerms = getAnnotation(annotatedElement, Terms.class); final Term annotatedTerm = getAnnotation(annotatedElement, Term.class); if (annotatedTerms != null && annotatedTerm != null) { throw new IllegalStateException("found both @Terms and @Term in " + name + ", use either one or the other"); } Map<String, Object> annotatedTermsMap = new LinkedHashMap<String, Object>(); if (annotatedTerms != null) { final Term[] terms = annotatedTerms.value(); for (Term term : terms) { final String define = term.define(); final String as = term.as(); if (annotatedTermsMap.containsKey(as)) { throw new IllegalStateException("duplicate definition of term '" + define + "' in " + name); } annotatedTermsMap.put(define, as); } } if (annotatedTerm != null) { annotatedTermsMap.put(annotatedTerm.define(), annotatedTerm.as()); } return annotatedTermsMap; }
private void collectTerms(String name, Map<String, Object> annotatedTermsMap, Term term) { final String define = term.define(); final String as = term.as(); final boolean reverse = term.reverse(); if (annotatedTermsMap.containsKey(as)) { throw new IllegalStateException("duplicate definition of term '" + define + "' in " + name); } if (!reverse) { annotatedTermsMap.put(define, as); } else { Map<String, String> reverseTerm = new LinkedHashMap<String, String>(); reverseTerm.put(JsonLdKeywords.AT_REVERSE, as); annotatedTermsMap.put(define, reverseTerm); } }
/** * Created by dschulten on 08.12.2014. */ @Term(define = "rdfs", as = "http://www.w3.org/2000/01/rdf-schema#") public class CreativeWork { public final String name; @JsonCreator public CreativeWork(@JsonProperty("name") String name) { this.name = name; } }
/** * 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(); } }
/** * 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(); } }
@Term(define = "accessories", as = "isAccessoryOrSparePartFor", reverse = true) @Relation("product") public class Product extends ResourceSupport {
@Term(define = "accessories", as = "isAccessoryOrSparePartFor", reverse = true) @Relation("product") public class Product extends ResourceSupport {