Package org.springframework.data.mapping
Class PreferredConstructor<T,P extends PersistentProperty<P>>
java.lang.Object
org.springframework.data.mapping.PreferredConstructor<T,P>
- All Implemented Interfaces:
InstanceCreatorMetadata<P>
Value object to encapsulate the constructor to be used when mapping persistent data to objects.
- Author:
- Oliver Gierke, Jon Brisbin, Thomas Darimont, Christoph Strobl, Mark Paluch, Myeonghyeon Lee, Xeno Amess
-
Constructor Summary
ConstructorDescriptionPreferredConstructor
(Constructor<T> constructor, Parameter<Object, P>... parameters) -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlyingConstructor
.Returns theParameter
s of the executable.boolean
isCreatorParameter
(PersistentProperty<?> property) Returns whether the givenPersistentProperty
is referenced in a creator argument of thePersistentEntity
backing thisInstanceCreatorMetadataSupport
.boolean
isEnclosingClassParameter
(Parameter<?, P> parameter) Returns whether the givenParameter
is one referring to an enclosing class.boolean
Returns whether the constructor was explicitly selected (byPersistenceCreator
).boolean
Returns whether the constructor does not have any arguments.boolean
isParentParameter
(Parameter<?, P> parameter) Returns whether the givenParameter
is one referring to parent value (such as an enclosing class or a receiver parameter).toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.data.mapping.InstanceCreatorMetadata
getParameterCount, hasParameters
-
Constructor Details
-
PreferredConstructor
@SafeVarargs public PreferredConstructor(Constructor<T> constructor, Parameter<Object, P>... parameters) - Parameters:
constructor
- must not be null.parameters
- must not be null.
-
-
Method Details
-
getConstructor
Returns the underlyingConstructor
.- Returns:
-
isNoArgConstructor
public boolean isNoArgConstructor()Returns whether the constructor does not have any arguments.- Returns:
- See Also:
-
isExplicitlyAnnotated
public boolean isExplicitlyAnnotated()Returns whether the constructor was explicitly selected (byPersistenceCreator
).- Returns:
- true if the constructor was explicitly selected.
-
isParentParameter
Description copied from interface:InstanceCreatorMetadata
Returns whether the givenParameter
is one referring to parent value (such as an enclosing class or a receiver parameter).- Returns:
-
isEnclosingClassParameter
Returns whether the givenParameter
is one referring to an enclosing class. That is in case the class thisPreferredConstructor
belongs to is a member class actually. If that's the case the compiler creates a first constructor argument of the enclosing class type.- Parameters:
parameter
- must not be null.- Returns:
- true if the
PersistentProperty
maps to the enclosing class.
-
getParameters
Returns theParameter
s of the executable.- Specified by:
getParameters
in interfaceInstanceCreatorMetadata<T>
- Returns:
-
isCreatorParameter
Returns whether the givenPersistentProperty
is referenced in a creator argument of thePersistentEntity
backing thisInstanceCreatorMetadataSupport
.Results of this call are cached and reused on the next invocation. Calling this method for a
PersistentProperty
that was not yet added to its owningPersistentEntity
will capture that state and return the same result after addingPersistentProperty
to its entity.- Specified by:
isCreatorParameter
in interfaceInstanceCreatorMetadata<T>
- Parameters:
property
- must not be null.- Returns:
- true if the
PersistentProperty
is used in the creator.
-
toString
-