Enum Class Role

java.lang.Object
java.lang.Enum<Role>
com.deltawalker.script.Role
All Implemented Interfaces:
Serializable, Comparable<Role>, Constable

public enum Role extends Enum<Role>
The role a compared item - a file, a folder, a block of text - plays in a comparison. A two-way comparison has the roles REF and ONE; a three-way comparison also has TWO, with REF as the common base. See Comparisons.create(Comparison.Type, String[], ComparisonListener) for which path gets which role.

 const Role = Java.type('com.deltawalker.script.Role');
 const res = node.resource(Role.REF);
 
Since:
2.0
  • Enum Constant Details

    • ONE

      public static final Role ONE
      The Modified role. In a 3-way comparison, this is the first of two modified roles.
    • REF

      public static final Role REF
      The Reference role against which modified roles are compared.
    • TWO

      public static final Role TWO
      The Second Modified role. Present only in a 3-way comparison.
  • Method Details

    • values

      public static Role[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Role valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • count

      public static int count()
      Returns the number of Roles.
      Returns:
      the number of values defined by this enum.
      Since:
      2.0
    • fromInt

      public static Role fromInt(int intVal)
      Returns the Role with the specified numerical value.
      Parameters:
      intVal - the numerical value of the requested role
      Returns:
      the Role with the specified numerical value.
      Since:
      2.0
    • getDisplayName

      public String getDisplayName(boolean threeWay)
      The name of this Role to be used for display purposes. The display of the same Role may vary depending on whether it's used in the context of a two or three-way comparison. For instance, in a two-way comparison ONE's name would be just 'Modified'; in a three-way comparison it would be 'First Modified'. The display name of REF would remain the same - 'Reference'.
      Parameters:
      threeWay - true to construct a display name for a three-way comparison, false for a two-way.
      Returns:
      the name of this role as a string suitable for display purposes
      Since:
      2.0
    • toInt

      public int toInt()
      Returns the integer value of this Role: 0 for REF, 1 for ONE and 2 for TWO. This is also the index of each role in HistoryEntry.getPaths().
      Returns:
      the integer value of this role
      Since:
      2.0