Class FieldLocation
- java.lang.Object
-
- org.assertj.core.api.recursive.comparison.FieldLocation
-
- All Implemented Interfaces:
java.lang.Comparable<FieldLocation>
public final class FieldLocation extends java.lang.Object implements java.lang.Comparable<FieldLocation>
Represents the path to a given field. Immutable
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>decomposedPathstatic java.lang.StringFIELD_SEPARATORprivate java.util.Set<java.lang.String>pathsHierarchyToUseInRulesprivate java.lang.StringpathToUseInRules
-
Constructor Summary
Constructors Constructor Description FieldLocation(java.lang.String s)FieldLocation(java.util.List<java.lang.String> path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intcompareTo(FieldLocation other)booleanequals(java.lang.Object obj)booleanexactlyMatches(java.lang.String fieldPath)booleanexactlyMatches(FieldLocation field)FieldLocationfield(java.lang.String field)java.util.List<java.lang.String>getDecomposedPath()java.lang.StringgetFieldName()java.lang.StringgetPathToUseInErrorReport()java.lang.StringgetPathToUseInRules()java.lang.StringgetPathToUseInRulesForChildField(java.lang.String fieldName)booleanhasChild(FieldLocation child)Returns true if this field has the given child (direct or indirect), false otherwise.inthashCode()booleanhasParent(FieldLocation parent)Returns true if this has the given parent (direct or indirect), false otherwise.booleanhierarchyMatches(java.lang.String fieldPath)Checks whether this fieldLocation or any of its parents matches the given fieldPath.booleanhierarchyMatchesRegex(java.util.regex.Pattern regex)Checks whether this fieldLocation or any of its parents matches the given regex.booleanisRoot()private booleanisRootPath(java.lang.String pathToUseInRules)booleanisTopLevelField()booleanmatches(java.lang.String fieldPath)Deprecated.useexactlyMatches(String)instead.booleanmatches(FieldLocation field)Deprecated.useexactlyMatches(String)instead.private java.lang.Stringparent(java.lang.String currentPath)private java.util.Set<java.lang.String>pathsHierarchyToUseInRules()private static java.lang.StringpathToUseInRules(java.util.List<java.lang.String> path)static FieldLocationrootFieldLocation()java.lang.StringshortDescription()java.lang.StringtoString()
-
-
-
Field Detail
-
FIELD_SEPARATOR
public static final java.lang.String FIELD_SEPARATOR
- See Also:
- Constant Field Values
-
pathToUseInRules
private final java.lang.String pathToUseInRules
-
decomposedPath
private final java.util.List<java.lang.String> decomposedPath
-
pathsHierarchyToUseInRules
private final java.util.Set<java.lang.String> pathsHierarchyToUseInRules
-
-
Method Detail
-
compareTo
public int compareTo(FieldLocation other)
- Specified by:
compareToin interfacejava.lang.Comparable<FieldLocation>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
shortDescription
public java.lang.String shortDescription()
-
pathToUseInRules
private static java.lang.String pathToUseInRules(java.util.List<java.lang.String> path)
-
exactlyMatches
public boolean exactlyMatches(FieldLocation field)
-
exactlyMatches
public boolean exactlyMatches(java.lang.String fieldPath)
-
matches
@Deprecated public boolean matches(java.lang.String fieldPath)
Deprecated.useexactlyMatches(String)instead.Reruns true if it exactly matches this field, false otherwise.- Parameters:
fieldPath- field path to check- Returns:
- true if it exactly matches this field, false otherwise
-
matches
@Deprecated public boolean matches(FieldLocation field)
Deprecated.useexactlyMatches(String)instead.Reruns true if it exactly matches this field, false otherwise.- Parameters:
field- field to check- Returns:
- true if it exactly matches this field, false otherwise
-
hierarchyMatches
public boolean hierarchyMatches(java.lang.String fieldPath)
Checks whether this fieldLocation or any of its parents matches the given fieldPath.Examples:
| fieldLocation | fieldPath | matches? ----------------------------------------------- | name.first | "name" | true | name.first.nickname | "name" | true | name.first | "name.first" | true | name.first.nickname | "name.first" | true | name | "name" | true | name | "name.first" | false | person.name | "name" | false | names | "name" | false | nickname | "name" | false | name | "nickname" | false | first.nickname | "name" | false- Parameters:
fieldPath- the field path to test- Returns:
- true if this fieldLocation is the given fieldPath or a child of it, false otherwise.
-
hierarchyMatchesRegex
public boolean hierarchyMatchesRegex(java.util.regex.Pattern regex)
Checks whether this fieldLocation or any of its parents matches the given regex.Examples:
| fieldLocation | regex | matches? ----------------------------------------------- | name.first | "name" | true | name.first | "..me" | true | name.first.nickname | "name" | true | name.first | "name.first" | true | name.first.nickname | "name.first" | true | name | "name" | true | name | "name.first" | false | person.name | "name" | false | names | "name" | false | nickname | "name" | false | name | "nickname" | false | first.nickname | "name" | false- Parameters:
regex- the regex to test- Returns:
- true, this fieldLocation or any of its parent matches the given regex., false otherwise.
-
getDecomposedPath
public java.util.List<java.lang.String> getDecomposedPath()
-
getPathToUseInRules
public java.lang.String getPathToUseInRules()
-
getPathToUseInRulesForChildField
public java.lang.String getPathToUseInRulesForChildField(java.lang.String fieldName)
-
field
public FieldLocation field(java.lang.String field)
-
getPathToUseInErrorReport
public java.lang.String getPathToUseInErrorReport()
-
getFieldName
public java.lang.String getFieldName()
-
isRoot
public boolean isRoot()
-
isRootPath
private boolean isRootPath(java.lang.String pathToUseInRules)
-
isTopLevelField
public boolean isTopLevelField()
-
rootFieldLocation
public static FieldLocation rootFieldLocation()
-
hasParent
public boolean hasParent(FieldLocation parent)
Returns true if this has the given parent (direct or indirect), false otherwise.Examples:
| field | parent | hasParent? ----------------------------------------------- | "name.first" | "name" | true | "name.first.nickname" | "name" | true | "name.first.nickname" | "name.first" | true | "name" | "name" | false | "names" | "name" | false | "nickname" | "name" | false | "name" | "nickname" | false | "first.nickname" | "name" | false- Parameters:
parent- the field to check for being a parent- Returns:
- true if this has the given parent (direct or indirect), false otherwise.
-
hasChild
public boolean hasChild(FieldLocation child)
Returns true if this field has the given child (direct or indirect), false otherwise.Examples:
| field | child | hasChild? ----------------------------------------------- | "name" | "name.first" | true | "name" | "name.last" | true | "one" | "one.two.three" | true | "name.first" | "name " | false | "name" | "name" | false | "names" | "name" | false | "nickname" | "name" | false | "name" | "nickname" | false | "first.nickname" | "name" | false- Parameters:
child- the field to check for being a child- Returns:
- true if this has the given child (direct or indirect), false otherwise.
-
pathsHierarchyToUseInRules
private java.util.Set<java.lang.String> pathsHierarchyToUseInRules()
-
parent
private java.lang.String parent(java.lang.String currentPath)
-
-