@JsonApiResource(type = "meta/mapType") public class MetaMapType extends MetaType { @JsonApiRelation(serialize=SerializeType.LAZY) private MetaType keyType; public MetaType getKeyType() { return keyType; } public void setKeyType(MetaType keyType) { this.keyType = keyType; } }
@JsonApiResource(type = "meta/primaryKey") public class MetaPrimaryKey extends MetaKey { private boolean generated; public boolean isGenerated() { return generated; } public void setGenerated(boolean generated) { this.generated = generated; } }
public static boolean getIncludeByDefault(Collection<Annotation> annotations) { for (Annotation annotation : annotations) { if (annotation instanceof JsonApiRelation) { JsonApiRelation jsonApiRelation = (JsonApiRelation) annotation; return jsonApiRelation.serialize() == SerializeType.EAGER; } if (annotation instanceof JsonApiIncludeByDefault) { return true; } } return false; }
@JsonApiResource(type = "projects") public class Project { @JsonApiId private Long id; private String name; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
private static String getOppositeName(List<Annotation> annotations) { for (Annotation annotation : annotations) { if (annotation instanceof JsonApiToMany) { return StringUtils.emptyToNull(((JsonApiToMany) annotation).opposite()); } if (annotation instanceof JsonApiToOne) { return StringUtils.emptyToNull(((JsonApiToOne) annotation).opposite()); } if (annotation instanceof JsonApiRelation) { return StringUtils.emptyToNull(((JsonApiRelation) annotation).opposite()); } } return null; }
public static LookupIncludeBehavior getLookupIncludeBehavior(Collection<Annotation> annotations, LookupIncludeBehavior defaultBehavior) { for (Annotation annotation : annotations) { if (annotation instanceof JsonApiRelation) { JsonApiRelation jsonApiRelation = (JsonApiRelation) annotation; return jsonApiRelation.lookUp(); } if (annotation instanceof JsonApiLookupIncludeAutomatically) { JsonApiLookupIncludeAutomatically includeAnnotation = (JsonApiLookupIncludeAutomatically) annotation; if (includeAnnotation.overwrite()) return LookupIncludeBehavior.AUTOMATICALLY_ALWAYS; else return LookupIncludeBehavior.AUTOMATICALLY_WHEN_NULL; } } return defaultBehavior; }
@JsonApiResource(type = "meta/collectionType") public abstract class MetaCollectionType extends MetaType { @JsonIgnore public <T> Collection<T> newInstance() { if (getImplementationClass() == Set.class) return new HashSet<>(); if (getImplementationClass() == List.class) return new ArrayList<>(); throw new UnsupportedOperationException(getImplementationClass().getName()); } }
@JsonApiResource(type = "meta/embeddableAttribute") public class MetaEmbeddableAttribute extends MetaAttribute { private static final Object VALUE_ANYTYPE_ATTR_NAME = "value"; @Override public boolean isDerived() { return super.isDerived() || AnyTypeObject.class.isAssignableFrom(getParent().getImplementationClass()) && getName().equals(VALUE_ANYTYPE_ATTR_NAME); } }
@JsonApiResource(type = "metaComputedAttribute") public class MetaComputedAttribute extends MetaAttribute { @Override public Object getValue(Object dataObject) { throw new UnsupportedOperationException(); } @Override public void setValue(Object dataObject, Object value) { throw new UnsupportedOperationException(); } }
@JsonApiResource(type = "meta/resourceAction") public class MetaResourceAction extends MetaElement { public enum MetaRepositoryActionType { REPOSITORY, RESOURCE } private MetaRepositoryActionType actionType; public MetaRepositoryActionType getActionType() { return actionType; } public void setActionType(MetaRepositoryActionType actionType) { this.actionType = actionType; } }
@JsonApiResource(type = "meta/setType") public class MetaSetType extends MetaCollectionType { }
@JsonApiResource(type = "meta/enumType") public class MetaEnumType extends MetaType { }
@JsonApiResource(type = "meta/resource") public class MetaResource extends MetaJsonObject { private String resourceType; public void setResourceType(String resourceType) { this.resourceType = resourceType; } public String getResourceType() { return resourceType; } @Override public List<MetaResourceField> getDeclaredAttributes() { return (List<MetaResourceField>) super.getDeclaredAttributes(); } }
@JsonApiResource(type = "meta/jsonObject") public class MetaJsonObject extends MetaDataObject { }
@JsonApiResource(type = "meta/entityAttribute") public class MetaEntityAttribute extends MetaAttribute { }
@JsonApiResource(type = "meta/mappedSuperclass") public class MetaMappedSuperclass extends MetaJpaDataObject { }
@JsonApiResource(type = "meta/jpaDataObject") public abstract class MetaJpaDataObject extends MetaDataObject { }
@JsonApiResource(type = "meta/arrayType") public class MetaArrayType extends MetaType { }
@JsonApiResource(type = "meta/listType") public class MetaListType extends MetaCollectionType { }
@JsonApiResource(type = "meta/embeddable") public class MetaEmbeddable extends MetaJpaDataObject { }