org.openstreetmap.josm.data.conflict
Class ConflictCollection

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

public class ConflictCollection
extends java.lang.Object
implements java.lang.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 Summary
private  java.util.List<Conflict<? extends OsmPrimitive>> conflicts
           
private  java.util.concurrent.CopyOnWriteArrayList<IConflictListener> listeners
           
 
Constructor Summary
ConflictCollection()
           
 
Method Summary
 void add(java.util.Collection<Conflict<?>> otherConflicts)
          Add the conflicts in otherConflicts to this collection of conflicts
 void add(Conflict<?> conflict)
          Adds a conflict to the collection of conflicts.
 void add(ConflictCollection other)
           
 void add(OsmPrimitive my, OsmPrimitive their)
          Adds a conflict for the pair of OsmPrimitives given by my and their.
protected  void addConflict(Conflict<?> conflict)
          Adds a conflict to the collection
 void addConflictListener(IConflictListener listener)
           
protected  void fireConflictAdded()
           
protected  void fireConflictRemoved()
           
 java.util.List<Conflict<?>> get()
          Replies the conflicts as list.
 Conflict<?> get(int idx)
          Replies the conflict at position idx
 Conflict<?> getConflictForMy(OsmPrimitive my)
          Replies the conflict for the OsmPrimitive my, null if no such conflict exists.
 Conflict<?> getConflictForTheir(OsmPrimitive their)
          Replies the conflict for the OsmPrimitive their, null if no such conflict exists.
 java.util.Set<OsmPrimitive> getMyConflictParties()
          Replies the set of OsmPrimitive which participate in the role of "my" in the conflicts managed by this collection.
 java.util.Set<OsmPrimitive> getTheirConflictParties()
          Replies the set of OsmPrimitive which participate in the role of "their" in the conflicts managed by this collection.
 boolean hasConflict(Conflict<?> c)
          Replies true, if this collection includes a given conflict
 boolean hasConflictForMy(OsmPrimitive my)
          Replies true, if this collection includes a conflict for my.
 boolean hasConflictForTheir(OsmPrimitive their)
          Replies true, if this collection includes a conflict for their.
 boolean isEmpty()
          Replies true if this collection is empty
 java.util.Iterator<Conflict<?>> iterator()
          Replies the iterator for this collection.
 void remove(Conflict<?> conflict)
          removes a conflict from this collection
 void remove(OsmPrimitive my)
          removes the conflict registered for OsmPrimitive my if any
 void removeConflictListener(IConflictListener listener)
           
 void removeForMy(OsmPrimitive my)
          Removes any conflicts for the OsmPrimitive my.
 void removeForTheir(OsmPrimitive their)
          Removes any conflicts for the OsmPrimitive their.
 int size()
          Replies the size of the collection
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

conflicts

private final java.util.List<Conflict<? extends OsmPrimitive>> conflicts

listeners

private java.util.concurrent.CopyOnWriteArrayList<IConflictListener> listeners
Constructor Detail

ConflictCollection

public ConflictCollection()
Method Detail

addConflictListener

public void addConflictListener(IConflictListener listener)

removeConflictListener

public void removeConflictListener(IConflictListener listener)

fireConflictAdded

protected void fireConflictAdded()

fireConflictRemoved

protected void fireConflictRemoved()

addConflict

protected void addConflict(Conflict<?> conflict)
                    throws java.lang.IllegalStateException
Adds a conflict to the collection

Parameters:
conflict - the conflict
Throws:
java.lang.IllegalStateException - thrown, if this collection already includes a conflict for conflict.getMy()

add

public void add(Conflict<?> conflict)
         throws java.lang.IllegalStateException
Adds a conflict to the collection of conflicts.

Parameters:
conflict - the conflict to add. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown, if conflict is null
java.lang.IllegalStateException - thrown if this collection already includes a conflict for conflict.getMy()

add

public void add(java.util.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

remove

public void remove(OsmPrimitive my)
removes the conflict registered for OsmPrimitive my if any

Parameters:
my - the primitive

getConflictForMy

public Conflict<?> getConflictForMy(OsmPrimitive my)
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

public Conflict<?> getConflictForTheir(OsmPrimitive their)
Replies the conflict for the OsmPrimitive their, null if no such conflict exists.

Parameters:
my - my 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 java.util.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 java.util.Iterator<Conflict<?>> iterator()
Replies the iterator for this collection.

Specified by:
iterator in interface java.lang.Iterable<Conflict<? extends OsmPrimitive>>
Returns:
the iterator

add

public void add(ConflictCollection other)

getMyConflictParties

public java.util.Set<OsmPrimitive> 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

public java.util.Set<OsmPrimitive> 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 java.lang.String toString()
Overrides:
toString in class java.lang.Object


JOSM