Module spring.data.mongodb
Record Class FieldName
java.lang.Object
java.lang.Record
org.springframework.data.mongodb.core.mapping.FieldName
Value Object representing a field name that should be used to read/write fields within the MongoDB document.
Field names field names may contain special characters (such as dot (.)) but may be
treated differently depending on their type.- Since:
- 4.2
- Author:
- Christoph Strobl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFieldName(String name, FieldName.Type type) Creates an instance of aFieldNamerecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.booleanisKey()booleanisOfType(FieldName.Type type) booleanisPath()name()Returns the value of thenamerecord component.static FieldNameCreate a newFieldNamethat treats the given value as is.String[]parts()Get the parts the field name consists of.static FieldNameCreate a newFieldNamethat treats the given value as a path.toString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Field Details
-
ID
-
-
Constructor Details
-
FieldName
Creates an instance of aFieldNamerecord class.- Parameters:
name- the value for thenamerecord componenttype- the value for thetyperecord component
-
-
Method Details
-
name
Create a newFieldNamethat treats the given value as is.- Parameters:
value- must not be null.- Returns:
- new instance of
FieldName.
-
path
Create a newFieldNamethat treats the given value as a path. If the value contains dot (.) characters, they are considered deliminators in a path.- Parameters:
value- must not be null.- Returns:
- new instance of
FieldName.
-
parts
Get the parts the field name consists of. If theFieldNameis aFieldName.Type.KEYor aFieldName.Type.PATHthat does not contain dot (.) characters an array containing a single element is returned. Otherwise thename()is split into segments using dot (.) as a separator.- Returns:
- never null.
-
isOfType
- Parameters:
type- return true if the givenFieldName.Typeis equal totype().- Returns:
- true if values are equal.
-
isKey
public boolean isKey()- Returns:
- whether the field name represents a key (i.e. as-is name).
-
isPath
public boolean isPath()- Returns:
- whether the field name represents a path (i.e. dot-path).
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-