Comparison (Apache Ant API)
Description: declaration: package: org.apache.tools.ant.types, class: Comparison

# Class Comparison

java.lang.Object
org.apache.tools.ant.types.EnumeratedAttribute
org.apache.tools.ant.types.Comparison

Direct Known Subclasses:
  `Length.When, SizeSelector.SizeComparisons`

public class Comparison extends EnumeratedAttribute
EnumeratedAttribute for generic comparisons. Accepts values "equal", "greater", "more", "less", "ne" (not equal), "ge" (greater or equal), "le" (less or equal), "eq" (equal), "gt" (greater), "lt" (less).

Since:
  Ant 1.7

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Comparison`
  `EQUAL`
  Equal Comparison.
  `static final Comparison`
  `GREATER`
  Greater Comparison.
  `static final Comparison`
  `GREATER_EQUAL`
  Greater-or-Equal Comparison.
  `static final Comparison`
  `LESS`
  Less Comparison.
  `static final Comparison`
  `LESS_EQUAL`
  Less-or-Equal Comparison.
  `static final Comparison`
  `NOT_EQUAL`
  Not-Equal Comparison.

  ### Fields inherited from class EnumeratedAttribute

  `value`
  Modifier and Type
  Field
  Description
  `protected String`
  `value`
  The selected value in this enumeration.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Comparison()`
  Default constructor.
  `Comparison(String value)`
  Construct a new Comparison with the specified value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `evaluate(int comparisonResult)`
  Evaluate a comparison result as from Comparator.compare() or Comparable.compareTo().
  `String[]`
  `getValues()`
  Return the possible values.

  ### Methods inherited from class EnumeratedAttribute

  `containsValue, getIndex, getInstance, getValue, indexOfValue, setValue, toString`
  Modifier and Type
  Method
  Description
  `final boolean`
  `containsValue(String value)`
  Is this value included in the enumeration?
  `final int`
  `getIndex()`
  `static EnumeratedAttribute`
  `getInstance(Class<? extends EnumeratedAttribute> clazz, String value)`
  Factory method for instantiating EAs via API in a more developer friendly way.
  `final String`
  `getValue()`
  `final int`
  `indexOfValue(String value)`
  get the index of a value in this enumeration.
  `void`
  `setValue(String value)`
  Invoked by `IntrospectionHelper`.
  `String`
  `toString()`
  Convert the value to its string form.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### EQUAL

    public static final Comparison EQUAL
    Equal Comparison.

  - ### NOT_EQUAL

    public static final Comparison NOT_EQUAL
    Not-Equal Comparison.

  - ### GREATER

    public static final Comparison GREATER
    Greater Comparison.

  - ### LESS

    public static final Comparison LESS
    Less Comparison.

  - ### GREATER_EQUAL

    public static final Comparison GREATER_EQUAL
    Greater-or-Equal Comparison.

  - ### LESS_EQUAL

    public static final Comparison LESS_EQUAL
    Less-or-Equal Comparison.

- ## Constructor Details

  - ### Comparison

    public Comparison()
    Default constructor.

  - ### Comparison

    public Comparison(String value)
    Construct a new Comparison with the specified value.
    Parameters:
      `value` - the EnumeratedAttribute value.

- ## Method Details

  - ### getValues

    public String[] getValues()
    Return the possible values.
    Specified by:
      `getValues` in class `EnumeratedAttribute`
    Returns:
      String[] of EnumeratedAttribute values.

  - ### evaluate

    public boolean evaluate(int comparisonResult)
    Evaluate a comparison result as from Comparator.compare() or Comparable.compareTo().
    Parameters:
      `comparisonResult` - the result to evaluate.
    Returns:
      true if the comparison result fell within the parameters of this Comparison.