Class FieldLocation

java.lang.Object
org.assertj.core.api.recursive.comparison.FieldLocation
All Implemented Interfaces:
Comparable<FieldLocation>

public final class FieldLocation extends Object implements Comparable<FieldLocation>
Represents the path to a given field. Immutable
  • Field Details Link icon

  • Constructor Details Link icon

    • FieldLocation Link icon

      public FieldLocation(List<String> path)
    • FieldLocation Link icon

      public FieldLocation(String s)
  • Method Details Link icon

    • compareTo Link icon

      public int compareTo(FieldLocation other)
      Specified by:
      compareTo in interface Comparable<FieldLocation>
    • equals Link icon

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • shortDescription Link icon

      public String shortDescription()
    • exactlyMatches Link icon

      public boolean exactlyMatches(FieldLocation field)
    • exactlyMatches Link icon

      public boolean exactlyMatches(String fieldPath)
    • matches Link icon

      @Deprecated public boolean matches(String fieldPath)
      Deprecated.
      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 Link icon

      @Deprecated public boolean matches(FieldLocation field)
      Deprecated.
      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 Link icon

      public boolean hierarchyMatches(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 Link icon

      public boolean hierarchyMatchesRegex(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 Link icon

      public List<String> getDecomposedPath()
    • getPathToUseInRules Link icon

      public String getPathToUseInRules()
    • getPathToUseInRulesForChildField Link icon

      public String getPathToUseInRulesForChildField(String fieldName)
    • field Link icon

      public FieldLocation field(String field)
    • getPathToUseInErrorReport Link icon

      public String getPathToUseInErrorReport()
    • getFieldName Link icon

      public String getFieldName()
    • isRoot Link icon

      public boolean isRoot()
    • isTopLevelField Link icon

      public boolean isTopLevelField()
    • rootFieldLocation Link icon

      public static FieldLocation rootFieldLocation()
    • hasParent Link icon

      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 Link icon

      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.