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 ofConflict
s. 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>>
conflicts
private 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 void
add(java.util.Collection<Conflict<?>> otherConflicts)
Add the conflicts inotherConflicts
to this collection of conflictsvoid
add(Conflict<?> conflict)
Adds a conflict to the collection of conflicts.void
add(ConflictCollection other)
Adds all conflicts from another collection.void
add(OsmPrimitive my, OsmPrimitive their)
protected void
addConflict(Conflict<?> conflict)
Adds a conflict to the collectionvoid
addConflictListener(IConflictListener listener)
Adds the specified conflict listener, if not already present.boolean
equals(java.lang.Object obj)
protected void
fireConflictAdded()
protected void
fireConflictRemoved()
java.util.List<Conflict<?>>
get()
Replies the conflicts as list.Conflict<?>
get(int idx)
Replies the conflict at positionidx
Conflict<?>
getConflictForMy(OsmPrimitive my)
Replies the conflict for theOsmPrimitive
my
, null if no such conflict exists.Conflict<?>
getConflictForTheir(OsmPrimitive their)
Replies the conflict for theOsmPrimitive
their
, null if no such conflict exists.java.util.Set<OsmPrimitive>
getMyConflictParties()
Replies the set ofOsmPrimitive
which 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 long
getNumberOfConflicts(java.util.function.Predicate<Conflict<?>> predicate)
long
getNumberOfNodeConflicts()
Returns the number of conflicts involving nodes.long
getNumberOfRelationConflicts()
Returns the number of conflicts involving nodes.long
getNumberOfWayConflicts()
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 ofOsmPrimitive
which 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.boolean
hasConflict(Conflict<?> c)
Replies true, if this collection includes a given conflictboolean
hasConflictForMy(OsmPrimitive my)
Replies true, if this collection includes a conflict formy
.boolean
hasConflictForTheir(OsmPrimitive their)
Replies true, if this collection includes a conflict fortheir
.int
hashCode()
boolean
isEmpty()
Replies true if this collection is emptyjava.util.Iterator<Conflict<?>>
iterator()
Replies the iterator for this collection.void
remove(Conflict<?> conflict)
removes a conflict from this collectionvoid
removeConflictListener(IConflictListener listener)
Removes the specified conflict listener.void
removeForMy(OsmPrimitive my)
Removes any conflicts for theOsmPrimitive
my
.void
removeForTheir(OsmPrimitive their)
Removes any conflicts for theOsmPrimitive
their
.int
size()
Replies the size of the collectionjava.lang.String
toString()
-
-
-
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 inotherConflicts
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)
- 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 theOsmPrimitive
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 theOsmPrimitive
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 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 theOsmPrimitive
my
.- Parameters:
my
- the primitive
-
removeForTheir
public void removeForTheir(OsmPrimitive their)
Removes any conflicts for theOsmPrimitive
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 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:
iterator
in 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 ofOsmPrimitive
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 ofOsmPrimitive
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 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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-