@Test
 public void demonstrateLWWRegister() {
   // #lwwregister
   final Cluster node = Cluster.get(system);
   final LWWRegister<String> r1 = LWWRegister.create(node, "Hello");
   final LWWRegister<String> r2 = r1.withValue(node, "Hi");
   System.out.println(r1.value() + " by " + r1.updatedBy() + " at " + r1.timestamp());
   // #lwwregister
   assertEquals("Hi", r2.value());
 }
  public void demonstrateLWWRegisterWithCustomClock() {
    // #lwwregister-custom-clock

    final Cluster node = Cluster.get(system);
    final LWWRegister.Clock<Record> recordClock =
        new LWWRegister.Clock<Record>() {
          @Override
          public long apply(long currentTimestamp, Record value) {
            return value.version;
          }
        };

    final Record record1 = new Record(1, "Alice", "Union Square");
    final LWWRegister<Record> r1 = LWWRegister.create(node, record1);

    final Record record2 = new Record(2, "Alice", "Madison Square");
    final LWWRegister<Record> r2 = LWWRegister.create(node, record2);

    final LWWRegister<Record> r3 = r1.merge(r2);
    System.out.println(r3.value());
    // #lwwregister-custom-clock

    assertEquals("Madison Square", r3.value().address);
  }