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
  • Constructor Details

    • FieldLocation

      public FieldLocation(List<String> path)
    • FieldLocation

      public FieldLocation(String s)
  • Method Details

    • matches

      public boolean matches(FieldLocation field)
    • matches

      public boolean matches(String fieldPath)
    • getDecomposedPath

      public List<String> getDecomposedPath()
    • getPathToUseInRules

      public String getPathToUseInRules()
    • field

      public FieldLocation field(String field)
    • compareTo

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

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

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

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

      public String shortDescription()
    • getPathToUseInErrorReport

      public String getPathToUseInErrorReport()
    • getFieldName

      public String getFieldName()
    • 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.