Paste: ugly java
Author: | crest |
Mode: | java |
Date: | Mon, 26 Jul 2010 16:20:16 |
Plain Text |
package test;
import java.util.UUID;
import data.MasterDataSet;
import data.SlaveDataSet;
import data.SlaveVersion;
import data.StringValue;
public class Main {
static void puts(Object o) {
System.out.println(o);
}
public static void main(String[] args) {
MasterDataSet master = new MasterDataSet();
SlaveDataSet slave1 = new SlaveDataSet();
SlaveDataSet slave2 = new SlaveDataSet();
StringValue value1 = new StringValue("foo");
UUID id1 = value1.getID();
slave1.add(value1);
slave1.pushToMaster(master, id1);
StringValue value2 = value1.change("bar");
slave1.add(value2);
slave1.pushToMaster(master, id1);
slave2.pullFromMaster(master, id1);
SlaveVersion version1 = slave2.get(id1);
StringValue value3 = (StringValue) version1.getValue();
StringValue value4 = value3.change("baz");
slave2.add(value4);
slave2.pushToMaster(master, id1);
puts(slave2);
puts(master);
slave1.pullFromMaster(master, id1);
puts(slave1);
}
}
Author: | crest |
Mode: | java |
Date: | Mon, 26 Jul 2010 16:20:59 |
Plain Text |
package test;
import java.util.UUID;
import data.DuplicateUUIDException;
import data.ForeignValueException;
import data.MasterDataSet;
import data.StringChanger;
import data.StringValue;
public class Main {
static void puts(Object o) {
System.out.println(o);
}
private static StringValue change(StringValue oldValue, String newContent) throws ForeignValueException {
StringChanger changer = oldValue.getChanger();
changer.setContent(newContent);
changer.commit();
return changer.getResult();
}
public static void main(String[] args) throws ForeignValueException, DuplicateUUIDException {
MasterDataSet<StringValue> master = new MasterDataSet<StringValue>();
StringValue sv1 = new StringValue(master, "foo");
UUID id1 = sv1.getID();
StringValue sv2 = change(sv1, "bar");
puts(master);
}
}
New Annotation