Class Property

java.lang.Object
org.springframework.data.mapping.model.Property

public class Property extends Object
Value object to abstract the concept of a property backed by a Field and / or a PropertyDescriptor.
Author:
Oliver Gierke, Christoph Strobl, Mark Paluch
  • Method Details

    • of

      public static Property of(TypeInformation<?> type, Field field)
      Creates a new Property backed by the given field.
      Parameters:
      type - the owning type, must not be null.
      field - must not be null.
      Returns:
    • of

      public static Property of(TypeInformation<?> type, Field field, PropertyDescriptor descriptor)
      Creates a new Property backed by the given Field and PropertyDescriptor.
      Parameters:
      type - the owning type, must not be null.
      field - must not be null.
      descriptor - must not be null.
      Returns:
    • of

      public static Property of(TypeInformation<?> type, PropertyDescriptor descriptor)
      Creates a new Property for the given PropertyDescriptor. The creation might fail if the given property is not representing a proper property.
      Parameters:
      type - the owning type, must not be null.
      descriptor - must not be null.
      Returns:
      See Also:
    • supportsStandalone

      public static boolean supportsStandalone(PropertyDescriptor descriptor)
      Returns whether the given PropertyDescriptor is supported in for standalone creation of a Property instance.
      Parameters:
      descriptor -
      Returns:
    • isFieldBacked

      public boolean isFieldBacked()
      Returns whether the property is backed by a field.
      Returns:
    • getGetter

      public Optional<Method> getGetter()
      Returns the getter of the property if available and if it matches the type of the property.
      Returns:
      will never be null.
    • getSetter

      public Optional<Method> getSetter()
      Returns the setter of the property if available and if its first (only) parameter matches the type of the property.
      Returns:
      will never be null.
    • getWither

      public Optional<Method> getWither()
      Returns the wither of the property if available and if its first (only) parameter matches the type of the property.
      Returns:
      will never be null.
    • getField

      public Optional<Field> getField()
      Returns the field of the property if available and if its first (only) parameter matches the type of the property.
      Returns:
      will never be null.
    • hasAccessor

      public boolean hasAccessor()
      Returns whether the property exposes a getter or a setter.
      Returns:
    • getName

      public String getName()
      Returns the name of the property.
      Returns:
      will never be null.
    • getType

      public Class<?> getType()
      Returns the type of the property.
      Returns:
      will never be null.
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object