Package com.github.jasminb.jsonapi
Class ConverterConfiguration
- java.lang.Object
-
- com.github.jasminb.jsonapi.ConverterConfiguration
-
public class ConverterConfiguration extends Object
Converter configuration.This class exposes contracts needed to handle JSON API spec serialization/deserialization.
- Author:
- jbegic
-
-
Constructor Summary
Constructors Constructor Description ConverterConfiguration(Class<?>... classes)Creates new ConverterConfiguration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RelationshipgetFieldRelationship(Field field)ResolvesRelationshipinstance for given field.FieldgetIdField(Class<?> clazz)Returns the id field for given type.ResourceIdHandlergetIdHandler(Class<?> clazz)Returns handler registered for given type's id field.FieldgetLinksField(Class<?> clazz)Resolves link field for given type.FieldgetMetaField(Class<?> clazz)Returns field annotated with meta annotation for given type.Class<?>getMetaType(Class<?> clazz)Returns meta-data type for given class.FieldgetRelationshipField(Class<?> clazz, String fieldName)Returns relationship field.List<Field>getRelationshipFields(Class<?> clazz)Returns list of all fields annotated withRelationshipannotation for given class.FieldgetRelationshipLinksField(Class<?> clazz, String relationshipName)Returns relationship links field.FieldgetRelationshipMetaField(Class<?> clazz, String relationshipName)Returns relationship meta field.Class<?>getRelationshipMetaType(Class<?> clazz, String relationshipName)Returns a type of a relationship meta field.Class<?>getRelationshipType(Class<?> clazz, String fieldName)Returns a type of a relationship.TypegetType(Class<?> clazz)Resolves and returns the type given to provided class.Class<?>getTypeClass(String typeName)Resolves a type for given type name.StringgetTypeName(Class<?> clazz)Resolves and returns name of the type given to provided class.static booleanisEligibleType(Class<?> type)booleanisRegisteredType(Class<?> clazz)Checks if provided class was registered with this configuration instance.booleanregisterType(Class<?> type)Registers new type with this configuration instance.
-
-
-
Constructor Detail
-
ConverterConfiguration
public ConverterConfiguration(Class<?>... classes)
Creates new ConverterConfiguration.- Parameters:
classes- list of mapped classes
-
-
Method Detail
-
getMetaField
public Field getMetaField(Class<?> clazz)
Returns field annotated with meta annotation for given type.
-
getIdHandler
public ResourceIdHandler getIdHandler(Class<?> clazz)
Returns handler registered for given type's id field.- Parameters:
clazz-Classtype to resolve id handler for- Returns:
- handler
-
getRelationshipField
public Field getRelationshipField(Class<?> clazz, String fieldName)
Returns relationship field.
-
getRelationshipType
public Class<?> getRelationshipType(Class<?> clazz, String fieldName)
Returns a type of a relationship.
-
getFieldRelationship
public Relationship getFieldRelationship(Field field)
ResolvesRelationshipinstance for given field.This works for fields that were found to be annotated with
Relationshipannotation.- Parameters:
field-Fieldto get relationship for- Returns:
Relationshipanotation ornull
-
getRelationshipFields
public List<Field> getRelationshipFields(Class<?> clazz)
Returns list of all fields annotated withRelationshipannotation for given class.- Parameters:
clazz-Classto get relationship fields for- Returns:
- list of relationship fields
-
isRegisteredType
public boolean isRegisteredType(Class<?> clazz)
Checks if provided class was registered with this configuration instance.- Parameters:
clazz-Classto check- Returns:
trueif class was registed elsefalse
-
getTypeName
public String getTypeName(Class<?> clazz)
Resolves and returns name of the type given to provided class.- Parameters:
clazz-Classto resolve type name for- Returns:
- type name or
nullif type was not registered
-
getType
public Type getType(Class<?> clazz)
Resolves and returns the type given to provided class.- Parameters:
clazz-Classto resolve type name for- Returns:
- type or
nullif type was not registered
-
registerType
public boolean registerType(Class<?> type)
Registers new type with this configuration instance.- Parameters:
type-Classtype to register- Returns:
truein case type was registered,falsein case type was registered already
-
isEligibleType
public static boolean isEligibleType(Class<?> type)
Checks if class is eligible as resource type (must haveTypeannotation and field annotated withId.- Parameters:
type- type to test- Returns:
trueif type is eligible
-
getRelationshipMetaField
public Field getRelationshipMetaField(Class<?> clazz, String relationshipName)
Returns relationship meta field.
-
getRelationshipMetaType
public Class<?> getRelationshipMetaType(Class<?> clazz, String relationshipName)
Returns a type of a relationship meta field.
-
-