@Test public void testEmptyList() { assertEquals(0, resolver.resolveConflicts(new ArrayList<Versioned<String>>()).size()); }
public List<Versioned<T>> resolveConflicts(List<Versioned<T>> items) { int size = items.size(); if(size <= 1) return items; List<Versioned<T>> newItems = Lists.newArrayList(); for(Versioned<T> v1: items) { boolean found = false; for(ListIterator<Versioned<T>> it2 = newItems.listIterator(); it2.hasNext();) { Versioned<T> v2 = it2.next(); Occurred compare = v1.getVersion().compare(v2.getVersion()); if(compare == Occurred.AFTER) { if(found) it2.remove(); else it2.set(v1); } if(compare != Occurred.CONCURRENTLY) found = true; } if(!found) newItems.add(v1); } return newItems; }
VectorClockInconsistencyResolver implements IInconsistencyResolver<Versioned<T>> { public List<Versioned<T>> resolveConflicts(List<Versioned<T>> items) { int size = items.size(); if(size <= 1) return items; List<Versioned<T>> newItems = Lists.newArrayList(); for(Versioned<T> v1: items) { boolean found = false; for(ListIterator<Versioned<T>> it2 = newItems.listIterator(); it2.hasNext();) { Versioned<T> v2 = it2.next(); Occurred compare = v1.getVersion().compare(v2.getVersion()); if(compare == Occurred.AFTER) { if(found) it2.remove(); else it2.set(v1); } if(compare != Occurred.CONCURRENTLY) found = true; } if(!found) newItems.add(v1); } return newItems; } }
VectorClockInconsistencyResolver implements IInconsistencyResolver<Versioned<T>> { public List<Versioned<T>> resolveConflicts(List<Versioned<T>> items) { int size = items.size(); if(size <= 1) return items; List<Versioned<T>> newItems = Lists.newArrayList(); for(Versioned<T> v1: items) { boolean found = false; for(ListIterator<Versioned<T>> it2 = newItems.listIterator(); it2.hasNext();) { Versioned<T> v2 = it2.next(); Occurred compare = v1.getVersion().compare(v2.getVersion()); if(compare == Occurred.AFTER) { if(found) it2.remove(); else it2.set(v1); } if(compare != Occurred.CONCURRENTLY) found = true; } if(!found) newItems.add(v1); } return newItems; }  }
VectorClockInconsistencyResolver implements IInconsistencyResolver<Versioned<T>> { public List<Versioned<T>> resolveConflicts(List<Versioned<T>> items) { int size = items.size(); if(size <= 1) return items; List<Versioned<T>> newItems = Lists.newArrayList(); for(Versioned<T> v1: items) { boolean found = false; for(ListIterator<Versioned<T>> it2 = newItems.listIterator(); it2.hasNext();) { Versioned<T> v2 = it2.next(); Occurred compare = v1.getVersion().compare(v2.getVersion()); if(compare == Occurred.AFTER) { if(found) it2.remove(); else it2.set(v1); } if(compare != Occurred.CONCURRENTLY) found = true; } if(!found) newItems.add(v1); } return newItems; }  List<Versioned<T>> resolveConflicts(List<Versioned<T>> items); @Override boolean equals(Object o); @Override int hashCode(); }
VectorClockInconsistencyResolver implements IInconsistencyResolver<Versioned<T>> { public List<Versioned<T>> resolveConflicts(List<Versioned<T>> items) { int size = items.size(); if(size <= 1) return items; List<Versioned<T>> newItems = Lists.newArrayList(); for(Versioned<T> v1: items) { boolean found = false; for(ListIterator<Versioned<T>> it2 = newItems.listIterator(); it2.hasNext();) { Versioned<T> v2 = it2.next(); Occurred compare = v1.getVersion().compare(v2.getVersion()); if(compare == Occurred.AFTER) { if(found) it2.remove(); else it2.set(v1); } if(compare != Occurred.CONCURRENTLY) found = true; } if(!found) newItems.add(v1); } return newItems; }  List<Versioned<T>> resolveConflicts(List<Versioned<T>> items); @Override boolean equals(Object o); @Override int hashCode();  }