Simple Conflict-free Replicated Data Types (CRDTs) for distributed systems. CRDTs on different replicas can diverge from one another but at the end they can be safely merged providing an eventually consistent value. In other words, CRDTs have a merge method that is idempotent, commutative and associative.
The following CRDTs are currently implemented:
PN-Counter:
PNCounter<String> replica1 = new PNCounter<>();
replica1.increment("hostname1");
PNCounter<String> replica2 = replica1.copy();
replica1.increment("hostname2");
replica2.decrement("hostname2");
replica1.merge( replica2 );
replica1.get(); // counter is 1
2-P Set:
TwoPSet<String> replica1 = new TwoPSet<>();
replica1.add("a");
replica1.add("b");
TwoPSet<String> replica2 = replica1.copy();
replica2.remove("b");
replica2.add("c");
replica1.merge(replica2);
replica1.get(); // set is {"a", "c"}
Maven/Gradle dependency: https://jitpack.io/#ajermakovics/crdts
All CRDT classes implement Java Serializable but you should be able to use any other library.
Java 1.6
The only dependency is Google Guava
MIT