@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; } }
@Override public String getResourceType(Class<?> resourceClass) { Annotation[] annotations = resourceClass.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof JsonApiResource) { JsonApiResource apiResource = (JsonApiResource) annotation; return apiResource.type(); } } // won't reach this throw new RepositoryAnnotationNotFoundException(resourceClass.getName()); }
public <T> RegistryEntry getEntry(T targetDataObject) { Class<?> targetDataObjClass = targetDataObject.getClass(); RegistryEntry relationshipEntry; if (targetDataObjClass.getAnnotation(JsonApiResource.class) != null) { relationshipEntry = findEntry(targetDataObjClass.getAnnotation(JsonApiResource.class).type(), targetDataObjClass.getClass()); } else { relationshipEntry = findEntry(targetDataObject.getClass()); } return relationshipEntry; }
@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/primitiveType") public class MetaPrimitiveType extends MetaType { }
@JsonApiResource(type = "meta/arrayType") public class MetaArrayType extends MetaType { }
@JsonApiResource(type = "meta/enumLiteral") public class MetaLiteral extends MetaElement { }
@JsonApiResource(type = "meta/listType") public class MetaListType extends MetaCollectionType { }
@JsonApiResource(type = "meta/embeddable") public class MetaEmbeddable extends MetaJpaDataObject { }
@JsonApiResource(type = "meta/entity") public class MetaEntity extends MetaJpaDataObject { }