Class MappedJacksonProperties

java.lang.Object
org.springframework.data.rest.webmvc.json.MappedJacksonProperties

public class MappedJacksonProperties extends Object
Simple value object to capture a mapping of Jackson mapped field names and PersistentProperty instances.
Since:
5.0
Author:
Mark Paluch, Oliver Gierke, Mark Paluch, Mathias Düsterhöft
  • Method Details

    • forDeserialization

      public static MappedJacksonProperties forDeserialization(PersistentEntity<?,?> entity, tools.jackson.databind.ObjectMapper mapper)
      Creates MappedJacksonProperties for the given PersistentEntity for deserialization purposes. Will not include Jackson-read-only properties.
      Parameters:
      entity - must not be null.
      mapper - must not be null.
      Returns:
    • forSerialization

      public static MappedJacksonProperties forSerialization(PersistentEntity<?,?> entity, tools.jackson.databind.ObjectMapper mapper)
      Creates MappedJacksonProperties for the given PersistentEntity for serialization purposes. Includes Jackson-read-only properties.
      Parameters:
      entity - must not be null.
      mapper - must not be null.
      Returns:
    • forDescription

      public static MappedJacksonProperties forDescription(PersistentEntity<?,?> entity, tools.jackson.databind.BeanDescription description)
    • none

      public static MappedJacksonProperties none()
    • getMappedName

      public String getMappedName(PersistentProperty<?> property)
      Parameters:
      property - must not be null
      Returns:
      the mapped name for the PersistentProperty
    • hasPersistentPropertyForField

      public boolean hasPersistentPropertyForField(String fieldName)
      Parameters:
      fieldName - must not be empty or null.
      Returns:
      true if the field name resolves to a PersistentProperty.
    • getPersistentProperty

      public @Nullable PersistentProperty<?> getPersistentProperty(String fieldName)
      Parameters:
      fieldName - must not be empty or null.
      Returns:
      the PersistentProperty backing the field with the field name.
    • getSpringDataUnmappedProperties

      public Iterable<String> getSpringDataUnmappedProperties()
      Returns all properties only known to Jackson.
      Returns:
      the names of all properties that are not known to Spring Data but appear in the Jackson metamodel.
    • getIgnoredProperties

      public Iterable<String> getIgnoredProperties()
      Returns all property names of ignored properties.
      Returns:
      will never be null.
      Since:
      3.5.11, 3.6.4
    • isMappedProperty

      public boolean isMappedProperty(PersistentProperty<?> property)
      Returns whether the given PersistentProperty is mapped, i.e. known to both Jackson and Spring Data.
      Parameters:
      property - must not be null.
      Returns:
    • isWritableField

      public boolean isWritableField(String name)
      Returns whether the property is actually writable. I.e. whether there's a non-read-only property on the target type or there's a catch all method annotated with JsonAnySetter.
      Parameters:
      name - must not be null or empty.
      Returns:
    • isReadableField

      public boolean isReadableField(String name)
    • isExposedProperty

      public boolean isExposedProperty(String name)