Package org.springframework.data.mapping
Class Alias
java.lang.Object
org.springframework.data.mapping.Alias
A container object which may or may not contain a type alias value. If a value is present,
isPresent() will
return true and getValue() will return the value.
Additional methods that depend on the presence or absence of a contained value are provided, such as
hasValue(Object) or isPresent()
Aliases are immutable once created.
- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Aliasempty()Returns an emptyAliasinstance.booleanRetrieve the required value or throwNoSuchElementExceptionif the value isabsent.@Nullable ObjectgetValue()inthashCode()booleanhasSamePresentValueAs(Alias other) Returns whether the current alias is present and has the same value as the givenAlias.booleanChecks whether thisAliascontains the valuethat.booleanisEmpty()booleanbooleanisPresentButDifferent(Alias other) Checks whether thisAliashas a value but is different from theothervalue.<T> @Nullable TReturn the value typed totypeif the value is present and assignable totype.static AliasCreate anAliasgiven thealiasobject.static AliasofNullable(@Nullable Object alias) Create anAliasfrom a possibly presentaliasobject.toString()
-
Field Details
-
NONE
Common instance forempty().
-
-
Method Details
-
of
Create anAliasgiven thealiasobject.- Parameters:
alias- must not be null.- Returns:
- the
Aliasforalias.
-
ofNullable
-
empty
Returns an emptyAliasinstance. No value is present for this Alias.- Returns:
- an empty
Alias.
-
isPresentButDifferent
Checks whether thisAliashas a value but is different from theothervalue.- Parameters:
other- must not be null.- Returns:
- true if this value is present but different from the
othervalue.
-
hasValue
Checks whether thisAliascontains the valuethat.- Parameters:
that- the other value, may be null.- Returns:
- true if this alias has a value and it equals to
that.
-
hasSamePresentValueAs
Returns whether the current alias is present and has the same value as the givenAlias. -
isPresent
public boolean isPresent()- Returns:
- true if this
Aliascontains a value.
-
isEmpty
public boolean isEmpty()- Returns:
- true if this
Aliasdoes not contain a value. - Since:
- 4.0
-
mapTyped
Return the value typed totypeif the value is present and assignable totype.- Parameters:
type- must not be null.- Returns:
-
getValue
-
getRequiredValue
Retrieve the required value or throwNoSuchElementExceptionif the value isabsent.- Returns:
- the required value.
-
equals
-
hashCode
public int hashCode() -
toString
-