Class ConflictCollection
- java.lang.Object
-
- 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 ofConflicts. This collection isIterable, i.e. it can be used infor-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
Fields Modifier and Type Field Description private java.util.List<Conflict<? extends OsmPrimitive>>conflictsprivate java.util.concurrent.CopyOnWriteArrayList<IConflictListener>listeners
-
Constructor Summary
Constructors Constructor Description ConflictCollection()Constructs a newConflictCollection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.util.Collection<Conflict<?>> otherConflicts)Add the conflicts inotherConflictsto this collection of conflictsvoidadd(Conflict<?> conflict)Adds a conflict to the collection of conflicts.voidadd(ConflictCollection other)Adds all conflicts from another collection.voidadd(OsmPrimitive my, OsmPrimitive their)protected voidaddConflict(Conflict<?> conflict)Adds a conflict to the collectionvoidaddConflictListener(IConflictListener listener)Adds the specified conflict listener, if not already present.booleanequals(java.lang.Object obj)protected voidfireConflictAdded()protected voidfireConflictRemoved()java.util.List<Conflict<?>>get()Replies the conflicts as list.Conflict<?>get(int idx)Replies the conflict at positionidxConflict<?>getConflictForMy(OsmPrimitive my)Replies the conflict for theOsmPrimitivemy, null if no such conflict exists.Conflict<?>getConflictForTheir(OsmPrimitive their)Replies the conflict for theOsmPrimitivetheir, null if no such conflict exists.java.util.Set<OsmPrimitive>getMyConflictParties()Replies the set ofOsmPrimitivewhich participate in the role of "my" in the conflicts managed by this collection.java.util.Collection<Conflict<? extends OsmPrimitive>>getNodeConflicts()Returns the list of conflicts involving nodes.private longgetNumberOfConflicts(java.util.function.Predicate<Conflict<?>> predicate)longgetNumberOfNodeConflicts()Returns the number of conflicts involving nodes.longgetNumberOfRelationConflicts()Returns the number of conflicts involving nodes.longgetNumberOfWayConflicts()Returns the number of conflicts involving nodes.java.util.Collection<Conflict<? extends OsmPrimitive>>getRelationConflicts()Returns the list of conflicts involving relations.java.util.Set<OsmPrimitive>getTheirConflictParties()Replies the set ofOsmPrimitivewhich participate in the role of "their" in the conflicts managed by this collection.java.util.Collection<Conflict<? extends OsmPrimitive>>getWayConflicts()Returns the list of conflicts involving ways.booleanhasConflict(Conflict<?> c)Replies true, if this collection includes a given conflictbooleanhasConflictForMy(OsmPrimitive my)Replies true, if this collection includes a conflict formy.booleanhasConflictForTheir(OsmPrimitive their)Replies true, if this collection includes a conflict fortheir.inthashCode()booleanisEmpty()Replies true if this collection is emptyjava.util.Iterator<Conflict<?>>iterator()Replies the iterator for this collection.voidremove(Conflict<?> conflict)removes a conflict from this collectionvoidremoveConflictListener(IConflictListener listener)Removes the specified conflict listener.voidremoveForMy(OsmPrimitive my)Removes any conflicts for theOsmPrimitivemy.voidremoveForTheir(OsmPrimitive their)Removes any conflicts for theOsmPrimitivetheir.intsize()Replies the size of the collectionjava.lang.StringtoString()
-
-
-
Field Detail
-
conflicts
private final java.util.List<Conflict<? extends OsmPrimitive>> conflicts
-
listeners
private final java.util.concurrent.CopyOnWriteArrayList<IConflictListener> listeners
-
-
Constructor Detail
-
ConflictCollection
public ConflictCollection()
Constructs a newConflictCollection.
-
-
Method Detail
-
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:
java.lang.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:
java.lang.IllegalArgumentException- if conflict is nulljava.lang.IllegalStateException- if this collection already includes a conflict for conflict.getMy()
-
add
public void add(java.util.Collection<Conflict<?>> otherConflicts)
Add the conflicts inotherConflictsto this collection of conflicts- Parameters:
otherConflicts- the collection of conflicts. Does nothing is conflicts is null.
-
add
public void add(OsmPrimitive my, OsmPrimitive their)
- Parameters:
my- my primitivetheir- their primitive
-
remove
public void remove(Conflict<?> conflict)
removes a conflict from this collection- Parameters:
conflict- the conflict
-
getConflictForMy
public Conflict<?> getConflictForMy(OsmPrimitive my)
Replies the conflict for theOsmPrimitivemy, null if no such conflict exists.- Parameters:
my- my primitive- Returns:
- the conflict for the
OsmPrimitivemy, null if no such conflict exists.
-
getConflictForTheir
public Conflict<?> getConflictForTheir(OsmPrimitive their)
Replies the conflict for theOsmPrimitivetheir, null if no such conflict exists.- Parameters:
their- their primitive- Returns:
- the conflict for the
OsmPrimitivetheir, null if no such conflict exists.
-
hasConflictForMy
public boolean hasConflictForMy(OsmPrimitive my)
Replies true, if this collection includes a conflict formy.- 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 fortheir.- 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 theOsmPrimitivemy.- Parameters:
my- the primitive
-
removeForTheir
public void removeForTheir(OsmPrimitive their)
Removes any conflicts for theOsmPrimitivetheir.- 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 positionidx- 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:
iteratorin interfacejava.lang.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
public java.util.Set<OsmPrimitive> getMyConflictParties()
Replies the set ofOsmPrimitivewhich participate in the role of "my" in the conflicts managed by this collection.- Returns:
- the set of
OsmPrimitivewhich participate in the role of "my" in the conflicts managed by this collection.
-
getTheirConflictParties
public java.util.Set<OsmPrimitive> getTheirConflictParties()
Replies the set ofOsmPrimitivewhich participate in the role of "their" in the conflicts managed by this collection.- Returns:
- the set of
OsmPrimitivewhich 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:
toStringin classjava.lang.Object
-
getNodeConflicts
public final java.util.Collection<Conflict<? extends OsmPrimitive>> getNodeConflicts()
Returns the list of conflicts involving nodes.- Returns:
- The list of conflicts involving nodes.
- Since:
- 6555
-
getWayConflicts
public final java.util.Collection<Conflict<? extends OsmPrimitive>> getWayConflicts()
Returns the list of conflicts involving ways.- Returns:
- The list of conflicts involving ways.
- Since:
- 6555
-
getRelationConflicts
public final java.util.Collection<Conflict<? extends OsmPrimitive>> 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(java.util.function.Predicate<Conflict<?>> predicate)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-