Class JacksonMetadata

java.lang.Object
org.springframework.data.rest.webmvc.json.JacksonMetadata
All Implemented Interfaces:
Iterable<com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition>

public class JacksonMetadata extends Object implements Iterable<com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition>
Value object to abstract Jackson based bean metadata of a given type.
Author:
Oliver Gierke, Greg Turnquist
  • Constructor Summary

    Constructors
    Constructor
    Description
    JacksonMetadata(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> type)
    Creates a new JacksonMetadata instance for the given ObjectMapper and type.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition
    getDefinitionFor(org.springframework.data.mapping.PersistentProperty<?> property)
    Returns the BeanPropertyDefinition for the given PersistentProperty.
    getFallbackDescription(ResourceMetadata ownerMetadata, com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition definition)
    Returns the fallback ResourceDescription to be used for the given BeanPropertyDefinition.
    com.fasterxml.jackson.databind.JsonSerializer<?>
    Returns the JsonSerializer for the given type, or null if none available.
    boolean
    isExported(org.springframework.data.mapping.PersistentProperty<?> property)
    Check if a given property for a type is available to be exported, i.e. serialized via Jackson.
    boolean
    isReadOnly(org.springframework.data.mapping.PersistentProperty<?> property)
    Returns whether the given PersistentProperty is considered read-only by Jackson.
    boolean
    Returns whether the backing type is considered a Jackson value type.
    Iterator<com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition>
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • JacksonMetadata

      public JacksonMetadata(com.fasterxml.jackson.databind.ObjectMapper mapper, Class<?> type)
      Creates a new JacksonMetadata instance for the given ObjectMapper and type.
      Parameters:
      mapper - must not be null.
      type - must not be null.
  • Method Details

    • getDefinitionFor

      public com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition getDefinitionFor(org.springframework.data.mapping.PersistentProperty<?> property)
      Returns the BeanPropertyDefinition for the given PersistentProperty.
      Parameters:
      property - must not be null.
      Returns:
      can be null in case there's no Jackson property to be exposed for the given PersistentProperty.
    • getFallbackDescription

      public ResourceDescription getFallbackDescription(ResourceMetadata ownerMetadata, com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition definition)
      Returns the fallback ResourceDescription to be used for the given BeanPropertyDefinition.
      Parameters:
      ownerMetadata - must not be null.
      definition - must not be null.
      Returns:
    • isExported

      public boolean isExported(org.springframework.data.mapping.PersistentProperty<?> property)
      Check if a given property for a type is available to be exported, i.e. serialized via Jackson.
      Parameters:
      property - must not be null.
      Returns:
    • isValueType

      public boolean isValueType()
      Returns whether the backing type is considered a Jackson value type.
      Returns:
      the isValue
    • isReadOnly

      public boolean isReadOnly(org.springframework.data.mapping.PersistentProperty<?> property)
      Returns whether the given PersistentProperty is considered read-only by Jackson.
      Parameters:
      property - must not be null.
      Returns:
    • getTypeSerializer

      public com.fasterxml.jackson.databind.JsonSerializer<?> getTypeSerializer(Class<?> type)
      Returns the JsonSerializer for the given type, or null if none available.
      Parameters:
      type - must not be null.
      Returns:
    • iterator

      public Iterator<com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition> iterator()
      Specified by:
      iterator in interface Iterable<com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition>