// License: GPL. For details, see LICENSE file.
package org.openstreetmap.josm.data.conflict;
import static org.openstreetmap.josm.tools.I18n.tr;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
/**
* This is a collection of {@see Conflict}s. This collection is {@see 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: *
otherConflicts
to this collection of conflicts
*
* @param otherConflicts the collection of conflicts. Does nothing is conflicts is null.
*/
public void add(Collectionmy
and
* their
.
*
* @param my my primitive
* @param their their primitive
*/
public void add(OsmPrimitive my, OsmPrimitive their) {
addConflict(new Conflictmy
if any
*
* @param my the primitive
*/
public void remove(OsmPrimitive my) {
Iteratormy
, null
* if no such conflict exists.
*
* @param my my primitive
* @return the conflict for the {@see OsmPrimitive} my
, null
* if no such conflict exists.
*/
public Conflict> getConflictForMy(OsmPrimitive my) {
for(Conflict> c : conflicts) {
if (c.isMatchingMy(my))
return c;
}
return null;
}
/**
* Replies the conflict for the {@see OsmPrimitive} their
, null
* if no such conflict exists.
*
* @param my my primitive
* @return the conflict for the {@see OsmPrimitive} their
, null
* if no such conflict exists.
*/
public Conflict> getConflictForTheir(OsmPrimitive their) {
for(Conflict> c : conflicts) {
if (c.isMatchingTheir(their))
return c;
}
return null;
}
/**
* Replies true, if this collection includes a conflict for my
.
*
* @param my my primitive
* @return true, if this collection includes a conflict for my
; false, otherwise
*/
public boolean hasConflictForMy(OsmPrimitive my) {
return getConflictForMy(my) != null;
}
/**
* Replies true, if this collection includes a given conflict
*
* @param c the conflict
* @return true, if this collection includes the conflict; false, otherwise
*/
public boolean hasConflict(Conflict> c) {
return hasConflictForMy(c.getMy());
}
/**
* Replies true, if this collection includes a conflict for their
.
*
* @param their their primitive
* @return true, if this collection includes a conflict for their
; false, otherwise
*/
public boolean hasConflictForTheir(OsmPrimitive their) {
return getConflictForTheir(their) != null;
}
/**
* Removes any conflicts for the {@see OsmPrimitive} my
.
*
* @param my the primitive
*/
public void removeForMy(OsmPrimitive my) {
Iteratortheir
.
*
* @param their the primitive
*/
public void removeForTheir(OsmPrimitive their) {
Iteratoridx
*
* @param idx the index
* @return the conflict at position idx
*/
public Conflict> get(int idx) {
return conflicts.get(idx);
}
/**
* Replies the iterator for this collection.
*
* @return the iterator
*/
public Iterator