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
ConstructorsConstructorDescriptionPreferredConstructor(Constructor<T> constructor, Parameter<Object, P>... parameters) -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlyingConstructor.Returns theParameters of the executable.booleanisConstructorParameter(PersistentProperty<?> property) Deprecated.booleanisCreatorParameter(PersistentProperty<?> property) Returns whether the givenPersistentPropertyis referenced in a creator argument of thePersistentEntitybacking thisInstanceCreatorMetadataSupport.booleanisEnclosingClassParameter(Parameter<?, P> parameter) Returns whether the givenParameteris one referring to an enclosing class.booleanReturns whether the constructor was explicitly selected (byPersistenceConstructor).booleanReturns whether the constructor does not have any arguments.booleanisParentParameter(Parameter<?, P> parameter) Returns whether the givenParameteris 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, waitMethods 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 (byPersistenceConstructor).- Returns:
-
isConstructorParameter
Deprecated.since 3.0, useInstanceCreatorMetadata.isCreatorParameter(PersistentProperty)instead.- Parameters:
property-- Returns:
-
isParentParameter
Description copied from interface:InstanceCreatorMetadataReturns whether the givenParameteris one referring to parent value (such as an enclosing class or a receiver parameter).- Returns:
-
isEnclosingClassParameter
Returns whether the givenParameteris one referring to an enclosing class. That is in case the class thisPreferredConstructorbelongs 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
PersistentPropertymaps to the enclosing class.
-
getParameters
Returns theParameters of the executable.- Specified by:
getParametersin interfaceInstanceCreatorMetadata<T>- Returns:
-
isCreatorParameter
Returns whether the givenPersistentPropertyis referenced in a creator argument of thePersistentEntitybacking thisInstanceCreatorMetadataSupport.Results of this call are cached and reused on the next invocation. Calling this method for a
PersistentPropertythat was not yet added to its owningPersistentEntitywill capture that state and return the same result after addingPersistentPropertyto its entity.- Specified by:
isCreatorParameterin interfaceInstanceCreatorMetadata<T>- Parameters:
property- must not be null.- Returns:
- true if the
PersistentPropertyis used in the creator.
-
toString
-
InstanceCreatorMetadata.isCreatorParameter(PersistentProperty)instead.