Class ConverterConfiguration


  • public class ConverterConfiguration
    extends Object
    Converter configuration.

    This class exposes contracts needed to handle JSON API spec serialization/deserialization.

    Author:
    jbegic
    • 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.
        Parameters:
        clazz - Class type
        Returns:
        Field meta field or null
      • getMetaType

        public Class<?> getMetaType​(Class<?> clazz)
        Returns meta-data type for given class.
        Parameters:
        clazz - Class class
        Returns:
        Class type or null if no field with meta annotaiton is found on given type
      • getLinksField

        public Field getLinksField​(Class<?> clazz)
        Resolves link field for given type.
        Parameters:
        clazz - Class type
        Returns:
        Field or null
      • getTypeClass

        public Class<?> getTypeClass​(String typeName)
        Resolves a type for given type name.
        Parameters:
        typeName - String type name
        Returns:
        Class resolved type
      • getIdField

        public Field getIdField​(Class<?> clazz)
        Returns the id field for given type.
        Parameters:
        clazz - Class type to resolve id field for
        Returns:
        Field id field
      • getIdHandler

        public ResourceIdHandler getIdHandler​(Class<?> clazz)
        Returns handler registered for given type's id field.
        Parameters:
        clazz - Class type to resolve id handler for
        Returns:
        handler
      • getRelationshipField

        public Field getRelationshipField​(Class<?> clazz,
                                          String fieldName)
        Returns relationship field.
        Parameters:
        clazz - Class class holding relationship
        fieldName - String name of the field
        Returns:
        Field field
      • getRelationshipType

        public Class<?> getRelationshipType​(Class<?> clazz,
                                            String fieldName)
        Returns a type of a relationship.
        Parameters:
        clazz - Class owning the field with relationship annotation
        fieldName - String name of the field
        Returns:
        Class field type
      • getFieldRelationship

        public Relationship getFieldRelationship​(Field field)
        Resolves Relationship instance for given field.

        This works for fields that were found to be annotated with Relationship annotation.

        Parameters:
        field - Field to get relationship for
        Returns:
        Relationship anotation or null
      • getRelationshipFields

        public List<Field> getRelationshipFields​(Class<?> clazz)
        Returns list of all fields annotated with Relationship annotation for given class.
        Parameters:
        clazz - Class to 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 - Class to check
        Returns:
        true if class was registed else false
      • getTypeName

        public String getTypeName​(Class<?> clazz)
        Resolves and returns name of the type given to provided class.
        Parameters:
        clazz - Class to resolve type name for
        Returns:
        type name or null if type was not registered
      • getType

        public Type getType​(Class<?> clazz)
        Resolves and returns the type given to provided class.
        Parameters:
        clazz - Class to resolve type name for
        Returns:
        type or null if type was not registered
      • registerType

        public boolean registerType​(Class<?> type)
        Registers new type with this configuration instance.
        Parameters:
        type - Class type to register
        Returns:
        true in case type was registered, false in case type was registered already
      • isEligibleType

        public static boolean isEligibleType​(Class<?> type)
        Checks if class is eligible as resource type (must have Type annotation and field annotated with Id.
        Parameters:
        type - type to test
        Returns:
        true if type is eligible
      • getRelationshipMetaField

        public Field getRelationshipMetaField​(Class<?> clazz,
                                              String relationshipName)
        Returns relationship meta field.
        Parameters:
        clazz - Class class holding relationship
        relationshipName - String name of the relationship
        Returns:
        Field field
      • getRelationshipMetaType

        public Class<?> getRelationshipMetaType​(Class<?> clazz,
                                                String relationshipName)
        Returns a type of a relationship meta field.
        Parameters:
        clazz - Class owning the field with relationship meta annotation
        relationshipName - String name of the field
        Returns:
        Class meta field type
      • getRelationshipLinksField

        public Field getRelationshipLinksField​(Class<?> clazz,
                                               String relationshipName)
        Returns relationship links field.
        Parameters:
        clazz - Class class holding relationship
        relationshipName - String name of the relationship
        Returns:
        Field field