Class ConflictCollection

java.lang.Object
org.openstreetmap.josm.data.conflict.ConflictCollection
All Implemented Interfaces:
Iterable<Conflict<? extends OsmPrimitive>>

public class ConflictCollection extends Object implements Iterable<Conflict<? extends OsmPrimitive>>
This is a collection of Conflicts. This collection is Iterable, i.e. it can be used in for-loops as follows:
    ConflictCollection conflictCollection = ....

    for (Conflict c : conflictCollection) {
      // do something
    }
 
This collection emits an event when the content of the collection changes. You can register and unregister for these events using:
  • Field Details

  • Constructor Details

  • Method Details

    • addConflictListener

      public void addConflictListener(IConflictListener listener)
      Adds the specified conflict listener, if not already present.
      Parameters:
      listener - The conflict listener to add
    • removeConflictListener

      public void removeConflictListener(IConflictListener listener)
      Removes the specified conflict listener.
      Parameters:
      listener - The conflict listener to remove
    • fireConflictAdded

      protected void fireConflictAdded()
    • fireConflictRemoved

      protected void fireConflictRemoved()
    • addConflict

      protected void addConflict(Conflict<?> conflict)
      Adds a conflict to the collection
      Parameters:
      conflict - the conflict
      Throws:
      IllegalStateException - if this collection already includes a conflict for conflict.getMy()
    • add

      public void add(Conflict<?> conflict)
      Adds a conflict to the collection of conflicts.
      Parameters:
      conflict - the conflict to add. Must not be null.
      Throws:
      IllegalArgumentException - if conflict is null
      IllegalStateException - if this collection already includes a conflict for conflict.getMy()
    • add

      public void add(Collection<Conflict<?>> otherConflicts)
      Add the conflicts in otherConflicts to this collection of conflicts
      Parameters:
      otherConflicts - the collection of conflicts. Does nothing is conflicts is null.
    • add

      public void add(OsmPrimitive my, OsmPrimitive their)
      Adds a conflict for the pair of OsmPrimitives given by my and their.
      Parameters:
      my - my primitive
      their - their primitive
    • remove

      public void remove(Conflict<?> conflict)
      removes a conflict from this collection
      Parameters:
      conflict - the conflict
    • getConflictForMy

      Replies the conflict for the OsmPrimitive my, null if no such conflict exists.
      Parameters:
      my - my primitive
      Returns:
      the conflict for the OsmPrimitive my, null if no such conflict exists.
    • getConflictForTheir

      Replies the conflict for the OsmPrimitive their, null if no such conflict exists.
      Parameters:
      their - their primitive
      Returns:
      the conflict for the OsmPrimitive their, null if no such conflict exists.
    • hasConflictForMy

      public boolean hasConflictForMy(OsmPrimitive my)
      Replies true, if this collection includes a conflict for my.
      Parameters:
      my - my primitive
      Returns:
      true, if this collection includes a conflict for my; false, otherwise
    • hasConflict

      public boolean hasConflict(Conflict<?> c)
      Replies true, if this collection includes a given conflict
      Parameters:
      c - the conflict
      Returns:
      true, if this collection includes the conflict; false, otherwise
    • hasConflictForTheir

      public boolean hasConflictForTheir(OsmPrimitive their)
      Replies true, if this collection includes a conflict for their.
      Parameters:
      their - their primitive
      Returns:
      true, if this collection includes a conflict for their; false, otherwise
    • removeForMy

      public void removeForMy(OsmPrimitive my)
      Removes any conflicts for the OsmPrimitive my.
      Parameters:
      my - the primitive
    • removeForTheir

      public void removeForTheir(OsmPrimitive their)
      Removes any conflicts for the OsmPrimitive their.
      Parameters:
      their - the primitive
    • get

      public List<Conflict<?>> get()
      Replies the conflicts as list.
      Returns:
      the list of conflicts
    • size

      public int size()
      Replies the size of the collection
      Returns:
      the size of the collection
    • get

      public Conflict<?> get(int idx)
      Replies the conflict at position idx
      Parameters:
      idx - the index
      Returns:
      the conflict at position idx
    • iterator

      public Iterator<Conflict<?>> iterator()
      Replies the iterator for this collection.
      Specified by:
      iterator in interface Iterable<Conflict<? extends OsmPrimitive>>
      Returns:
      the iterator
    • add

      public void add(ConflictCollection other)
      Adds all conflicts from another collection.
      Parameters:
      other - The other collection of conflicts to add
    • getMyConflictParties

      Replies the set of OsmPrimitive which participate in the role of "my" in the conflicts managed by this collection.
      Returns:
      the set of OsmPrimitive which participate in the role of "my" in the conflicts managed by this collection.
    • getTheirConflictParties

      Replies the set of OsmPrimitive which participate in the role of "their" in the conflicts managed by this collection.
      Returns:
      the set of OsmPrimitive which participate in the role of "their" in the conflicts managed by this collection.
    • isEmpty

      public boolean isEmpty()
      Replies true if this collection is empty
      Returns:
      true, if this collection is empty; false, otherwise
    • toString

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

      public final Collection<Conflict<? extends OsmPrimitive>> getNodeConflicts()
      Returns the list of conflicts involving nodes.
      Returns:
      The list of conflicts involving nodes.
      Since:
      6555
    • getWayConflicts

      public final Collection<Conflict<? extends OsmPrimitive>> getWayConflicts()
      Returns the list of conflicts involving ways.
      Returns:
      The list of conflicts involving ways.
      Since:
      6555
    • getRelationConflicts

      Returns the list of conflicts involving relations.
      Returns:
      The list of conflicts involving relations.
      Since:
      6555
    • getNumberOfNodeConflicts

      public final long getNumberOfNodeConflicts()
      Returns the number of conflicts involving nodes.
      Returns:
      The number of conflicts involving nodes.
      Since:
      17524
    • getNumberOfWayConflicts

      public final long getNumberOfWayConflicts()
      Returns the number of conflicts involving nodes.
      Returns:
      The number of conflicts involving nodes.
      Since:
      17524
    • getNumberOfRelationConflicts

      public final long getNumberOfRelationConflicts()
      Returns the number of conflicts involving nodes.
      Returns:
      The number of conflicts involving nodes.
      Since:
      17524
    • getNumberOfConflicts

      private long getNumberOfConflicts(Predicate<Conflict<?>> predicate)
    • hashCode

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

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