@Override public <T> Field<T> create(int number, String name, java.lang.reflect.Field field, IdStrategy strategy) { final RuntimeFieldFactory<Collection<?>> factory = 0 != (IdStrategy.COLLECTION_SCHEMA_ON_REPEATED_FIELDS & strategy.flags) ? RuntimeCollectionFieldFactory.getFactory() : RuntimeRepeatedFieldFactory.getFactory(); return factory.create(number, name, field, strategy); }
/** * Gets the schema that was either registered or lazily initialized at runtime. */ public static <T> Schema<T> getSchema(Class<T> typeClass, IdStrategy strategy) { return strategy.getSchemaWrapper(typeClass, true).getSchema(); }
PojoWithImmutableListAsDelegate fill() { List<Baz> bazList = newList( new Baz(567, "baz", 202020202), new Baz(999, "buzz", 10101010) ); list = new ImmutableList(bazList); return this; }
static void assertEquals(HasBar h1, HasBar h2) { // true if both are null if (h1 == h2) return; assertTrue(h1.getId() == h2.getId()); assertEquals(h1.getName(), h2.getName()); SerializableObjects.assertEquals(h1.getBar(), h2.getBar()); }
public void testPojoWithArrayAndSet() throws Exception { RuntimeSchema<PojoWithArrayAndSet> schema = getSchema(PojoWithArrayAndSet.class); PojoWithArrayAndSet p = SerDeserTest.filledPojoWithArrayAndSet(); roundTrip(p, schema, schema.getPipeSchema()); }
public void testEmployee() throws Exception { RuntimeSchema<Employee> schema = getSchema(Employee.class); Employee emp = CollectionTest.filledEmployee(); roundTrip(emp, schema, schema.getPipeSchema()); }
public void testPayment() throws Exception { RuntimeSchema<Payment> schema = getSchema(Payment.class); Payment payment = MathObjectsTest.filledPayment(); roundTrip(payment, schema, schema.getPipeSchema()); }
public void testTask() throws Exception { RuntimeSchema<Task> schema = getSchema(Task.class); Task task = CollectionTest.filledTask(); roundTrip(task, schema, schema.getPipeSchema()); }
public void testRegisterCustom() throws IOException { RuntimeSchema.register(PersistentObjectList.class); RuntimeSchema.register(PersistentObjectMap.class); verifyObjectListField(); verifyObjectMapField(); if (RuntimeEnv.POJO_SCHEMA_ON_COLLECTION_FIELDS) verifyListField(); if (RuntimeEnv.POJO_SCHEMA_ON_MAP_FIELDS) verifyMapField(); }
static Schema<Baz> ex3(int min, int max) { return RuntimeView.createFrom(rs(), RuntimeView.Factories.EXCLUDE, new Predicate.RANGE(min, max), (String[]) null); }
static Schema<Baz> ex1(String... args) { return RuntimeView.createFrom(rs(), RuntimeView.Factories.EXCLUDE, null, args); }
static void attachHead(Document document) { Head head = new Head(document, document); Title title = new Title(head, document); title.text = "Hello world from protostuff-runtime graph ser/deser!"; Link link = new Link(head, document); link.rel = "shortcut icon"; link.href = "/favicon.ico"; link.type = "image/x-icon"; }
static void assertEquals(HasHasBar h1, HasHasBar h2) { // true if both are null if (h1 == h2) return; assertEquals(h1.getName(), h2.getName()); assertEquals(h1.getHasBar(), h2.getHasBar()); }
/** * Gets the schema that was either registered or lazily initialized at runtime. */ public static <T> Schema<T> getSchema(Class<T> typeClass, IdStrategy strategy) { return strategy.getSchemaWrapper(typeClass, true).getSchema(); }
@Override public <T> Field<T> create(int number, String name, java.lang.reflect.Field field, IdStrategy strategy) { final RuntimeFieldFactory<Collection<?>> factory = 0 != (IdStrategy.COLLECTION_SCHEMA_ON_REPEATED_FIELDS & strategy.flags) ? RuntimeCollectionFieldFactory.getFactory() : RuntimeRepeatedFieldFactory.getFactory(); return factory.create(number, name, field, strategy); }
static Schema<Baz> NOTRANGE(String... args) { return RuntimeView.createFrom(rs(), RuntimeView.Factories.PREDICATE, Predicate.Factories.NOTRANGE, args); }
static Schema<Baz> LT(String... args) { return RuntimeView.createFrom(rs(), RuntimeView.Factories.PREDICATE, Predicate.Factories.LT, args); }
static Schema<Baz> RANGE(String... args) { return RuntimeView.createFrom(rs(), RuntimeView.Factories.PREDICATE, Predicate.Factories.RANGE, args); }
static Schema<Baz> in1(String... args) { return RuntimeView.createFrom(rs(), RuntimeView.Factories.INCLUDE, null, args); }