Package org.springframework.data.mapping
Class PreferredConstructor<T,P extends PersistentProperty<P>>
java.lang.Object
org.springframework.data.mapping.PreferredConstructor<T,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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
PreferredConstructor.Parameter<T,
P extends PersistentProperty<P>> Value object to represent constructor parameters. -
Constructor Summary
ConstructorDescriptionPreferredConstructor
(Constructor<T> constructor, PreferredConstructor.Parameter<Object, P>... parameters) -
Method Summary
Modifier and TypeMethodDescriptionReturns the underlyingConstructor
.Returns thePreferredConstructor.Parameter
s of the constructor.boolean
Returns whether the constructor hasPreferredConstructor.Parameter
s.boolean
isConstructorParameter
(PersistentProperty<?> property) Returns whether the givenPersistentProperty
is referenced in a constructor argument of thePersistentEntity
backing thisPreferredConstructor
.boolean
isEnclosingClassParameter
(PreferredConstructor.Parameter<?, P> parameter) Returns whether the givenPreferredConstructor.Parameter
is one referring to an enclosing class.boolean
Returns whether the constructor was explicitly selected (byPersistenceConstructor
).boolean
Returns whether the constructor does not have any arguments.
-
Constructor Details
-
PreferredConstructor
@SafeVarargs public PreferredConstructor(Constructor<T> constructor, PreferredConstructor.Parameter<Object, P>... parameters) - Parameters:
constructor
- must not be null.parameters
- must not be null.
-
-
Method Details
-
getConstructor
Returns the underlyingConstructor
.- Returns:
-
getParameters
Returns thePreferredConstructor.Parameter
s of the constructor.- Returns:
-
hasParameters
public boolean hasParameters()Returns whether the constructor hasPreferredConstructor.Parameter
s.- Returns:
- See Also:
-
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
Returns whether the givenPersistentProperty
is referenced in a constructor argument of thePersistentEntity
backing thisPreferredConstructor
.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.- Parameters:
property
- must not be null.- Returns:
- true if the
PersistentProperty
is used in the constructor.
-
isEnclosingClassParameter
Returns whether the givenPreferredConstructor.Parameter
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.
-