Class WithConfidence<T>

Object
WithConfidence<T>
Type Parameters:
T - element to be associated with a confidence score
All Implemented Interfaces:
Comparable<WithConfidence<T>>

public class WithConfidence<T> extends Object implements Comparable<WithConfidence<T>>
Wraps an element with a confidence-score.

A natural ordering exists, highest confidences ahead of lower confidences.

  • Constructor Details

    • WithConfidence

      public WithConfidence(T element, double confidence)
      Creates a new WithConfidence instance.
      Parameters:
      element - The underlying element with whom a confidence is associated.
      confidence - The confidence associated with element.
  • Method Details

    • map

      public <S> WithConfidence<S> map(Function<T,S> transform)
      Maps the existing object to another object, while retaining an identical confidence score.
      Type Parameters:
      S - type to map to
      Parameters:
      transform - converts the existing element into the new type
      Returns:
      a newly created WithConfidence object containing the transformed element but preserving the confidence.
    • compareTo

      public int compareTo(WithConfidence<T> other)
      Specified by:
      compareTo in interface Comparable<T>
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

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

      public T getElement()
      The underlying element with whom a confidence is associated.
    • getConfidence

      public double getConfidence()
      The confidence associated with element.