Class PolaritySet<T>

java.lang.Object
org.aksw.commons.collections.PolaritySet<T>
Type Parameters:
T -
All Implemented Interfaces:
Serializable, Cloneable

public class PolaritySet<T> extends Object implements Cloneable, Serializable
A set of values with positive or negative polarity This set can thus act as a white or blacklist.
Author:
Claus Stadler, Aug 1, 2018
See Also:
  • Field Details

    • values

      protected Set<T> values
    • isPositive

      protected boolean isPositive
  • Constructor Details

    • PolaritySet

      public PolaritySet(Set<T> values)
    • PolaritySet

      public PolaritySet(boolean isPositive, Set<T> values)
  • Method Details

    • clone

      protected PolaritySet<T> clone()
      Overrides:
      clone in class Object
    • create

      public static <T> PolaritySet<T> create(boolean isPositive, T... values)
    • union

      public PolaritySet<T> union(PolaritySet<T> that)
      Immutable union; returns a view
    • intersect

      public PolaritySet<T> intersect(PolaritySet<T> that)
      Immutable union; returns a view
    • difference

      public PolaritySet<T> difference(PolaritySet<T> that)
      Immutable union; returns a view
    • negate

      public PolaritySet<T> negate()
      Immutable negate; returns a view
    • isEmpty

      public boolean isEmpty()
    • contains

      public boolean contains(Object item)
    • isPositive

      public boolean isPositive()
    • setPolarity

      public boolean setPolarity(boolean isPositive)
      Set the polarity
      Parameters:
      isPositive - the new value for the polarity; true = positive
      Returns:
      The old polarity befor setting the new one.
    • getValue

      public Set<T> getValue()
    • clear

      public void clear()
    • toString

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

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

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

      public PolaritySet<T> stateIntersect(PolaritySet<T> that)
      Mutating intersection
    • stateUnion

      public PolaritySet<T> stateUnion(PolaritySet<T> that)
      Mutating union
    • stateNegate

      public PolaritySet<T> stateNegate()
      Mutates this by flipping the polarity
    • createDifferenceView

      public static <T> PolaritySet<T> createDifferenceView(PolaritySet<T> self, PolaritySet<T> that)
      case: positive - positive Simply take the difference case: positive - negative {1, 2, 3} difference {not {3}}: -> { 3 } (intersection) case: negative - positive {not {3} } difference {1, 2, 3}: case: negative - negative Simply take the intersection
      Parameters:
      other -
      Returns:
    • createIntersectionView

      public static <T> PolaritySet<T> createIntersectionView(PolaritySet<T> self, PolaritySet<T> that)
      case: positive - positive Simply take the intersection case: positive - negative {1, 2, 3} intersect {not {2}}: -> {1, 3} (positive.removeAll(negative)) case: negative - positive Same as above case: negative - negative Simply take the union
      Parameters:
      other -
      Returns:
    • createUnionView

      public static <T> PolaritySet<T> createUnionView(PolaritySet<T> self, PolaritySet<T> that)
      case: positive - positive Simply take the union case: positive - negative {1, 2, 3} intersect {not {1, 4}}: -> {4} (negative.removeAll(positive)) case: negative - positive Same as above case: negative - negative Simply take the intersection
      Parameters:
      that -
      Returns: