static Baz newBaz(int id, String name, long timestamp) { Baz message = new Baz(); message.setId(id); message.setName(name); message.setTimestamp(timestamp); return message; }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); byte[] data = XmlIOUtil.toByteArray(bazCompare, schema); XmlIOUtil.mergeFrom(data, dbaz, schema); SerializableObjects.assertEquals(bazCompare, dbaz); } }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); byte[] data = JsonIOUtil.toByteArray(bazCompare, schema, false); JsonIOUtil.mergeFrom(data, dbaz, schema, false); SerializableObjects.assertEquals(bazCompare, dbaz); } }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); byte[] data = JsonIOUtil.toByteArray(bazCompare, schema, true); JsonIOUtil.mergeFrom(data, dbaz, schema, true); SerializableObjects.assertEquals(bazCompare, dbaz); } }
static void fill(PojoWithByteArray pwba) { pwba.bytes = ba("1"); pwba.bytesList = newList(); pwba.bytesList.add(ba("2")); pwba.bytesList.add(ba("3")); pwba.scalarKeyMap = newMap(); pwba.scalarKeyMap.put(1, ba("4")); pwba.scalarKeyMap.put(2, ba("5")); pwba.enumKeyMap = newMap(); pwba.enumKeyMap.put(Direction.EAST, ba("6")); pwba.enumKeyMap.put(Direction.WEST, ba("7")); pwba.pojoKeyMap = newMap(); pwba.pojoKeyMap.put(new Baz(1, "bz1", 0), ba("8")); pwba.pojoKeyMap.put(new Baz(2, "bz2", 0), ba("9")); pwba.scalarValueMap = newMap(); pwba.scalarValueMap.put(ba("10"), 1); pwba.scalarValueMap.put(ba("11"), 2); pwba.enumValueMap = newMap(); pwba.enumValueMap.put(ba("12"), Direction.EAST); pwba.enumValueMap.put(ba("13"), Direction.WEST); pwba.pojoValueMap = newMap(); pwba.pojoValueMap.put(ba("14"), new Baz(1, "bz1", 0)); pwba.pojoValueMap.put(ba("15"), new Baz(2, "bz2", 0)); pwba.bytesMap = newMap(); pwba.bytesMap.put(ba("16"), ba("17")); pwba.bytesMap.put(ba("18"), ba("19")); }
static void fill(PojoWithByteString pwbs) { pwbs.bytes = bs("1"); pwbs.bytesList = newList(); pwbs.bytesList.add(bs("2")); pwbs.bytesList.add(bs("3")); pwbs.scalarKeyMap = newMap(); pwbs.scalarKeyMap.put(1, bs("4")); pwbs.scalarKeyMap.put(2, bs("5")); pwbs.enumKeyMap = newMap(); pwbs.enumKeyMap.put(Direction.EAST, bs("6")); pwbs.enumKeyMap.put(Direction.WEST, bs("7")); pwbs.pojoKeyMap = newMap(); pwbs.pojoKeyMap.put(new Baz(1, "bz1", 0), bs("8")); pwbs.pojoKeyMap.put(new Baz(2, "bz2", 0), bs("9")); pwbs.scalarValueMap = newMap(); pwbs.scalarValueMap.put(bs("10"), 1); pwbs.scalarValueMap.put(bs("11"), 2); pwbs.enumValueMap = newMap(); pwbs.enumValueMap.put(bs("12"), Direction.EAST); pwbs.enumValueMap.put(bs("13"), Direction.WEST); pwbs.pojoValueMap = newMap(); pwbs.pojoValueMap.put(bs("14"), new Baz(1, "bz1", 0)); pwbs.pojoValueMap.put(bs("15"), new Baz(2, "bz2", 0)); pwbs.bytesMap = newMap(); pwbs.bytesMap.put(bs("16"), bs("17")); pwbs.bytesMap.put(bs("18"), bs("19")); }
public void testBazStreamed() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); ByteArrayOutputStream out = new ByteArrayOutputStream(); LinkedBuffer buffer = buf(); try { JsonXIOUtil.writeTo(out, bazCompare, schema, true, buffer); } finally { buffer.clear(); } byte[] data = out.toByteArray(); JsonIOUtil.mergeFrom(data, dbaz, schema, true); SerializableObjects.assertEquals(bazCompare, dbaz); } }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); byte[] data = JsonXIOUtil.toByteArray(bazCompare, schema, true, buf()); JsonIOUtil.mergeFrom(data, dbaz, schema, true); SerializableObjects.assertEquals(bazCompare, dbaz); } }
public void testBaz() throws Exception { Schema<Baz> schema = RuntimeSchema.getSchema(Baz.class); for (Baz bazCompare : new Baz[] { baz, negativeBaz }) { Baz dbaz = new Baz(); int expectedSize = ComputedSizeOutput.getSize(bazCompare, schema); byte[] deferred = toByteArray(bazCompare, schema); assertTrue(deferred.length == expectedSize); ProtostuffIOUtil.mergeFrom(deferred, dbaz, schema); SerializableObjects.assertEquals(bazCompare, dbaz); // System.err.println(dbaz.getId()); // System.err.println(dbaz.getName()); // System.err.println(dbaz.getTimestamp()); } }
public class Bar { public Bar() { new Baz(); } }
class BazBuilder { Baz build(int value) { return new Baz(value); } }
function Baz() { return this; } Baz.prototype.fn = Baz.prototype; var Foo = new Baz(); Baz = null; (function(Bar) { Bar.fn.myPlugin = function() { return "test"; }; })(Foo); Foo.myPlugin(); //returns test
public Foo( Bar bar, Baz baz ) { if (baz == null) { baz = new Baz(this instanceof FooSubClass); } // do stuff } public Foo( Bar bar ) { this( bar, null ); }
MyClass<Baz> myBazClass = myClassFactory.create(); Baz baz = new Baz(); myBazClass.setVal(baz); System.out.println(myBazClass.getVal());
var Baz = function(){ this.counter = 99; }; Baz.protype = new Bar(); var baz = new Baz(); console.log(baz.counter); // 99 baz.inc(); console.log(baz.counter); // 100 console.log(baz instanceof Baz); // true console.log(baz instanceof Bar); // true console.log(baz instanceof Object); // true
public void something() { Bar myBar = new Bar(); Baz myBaz = new Baz(); myFunction(myBar); myFunction(myBaz); }
public class Foo { private Bar bar = new Bar(); // this field is visible throughout the object public Foo() { Baz baz = new Baz(); // this is only visible within this constructor }
Foo f = new Foo(); f.bar = new Baz(); m.marshal(f, System.err);