@Test public void testCollections() throws Exception { Collection<String> j = Lists.newArrayList(); j.add("a"); j.add("b"); Schema collectionSchema = Schema.createArray( Schema.createUnion(ImmutableList.of( Avros.strings().getSchema(), Schema.create(Type.NULL)))); GenericData.Array<Utf8> w = new GenericData.Array<Utf8>(2, collectionSchema); w.add(new Utf8("a")); w.add(new Utf8("b")); testInputOutputFn(Avros.collections(Avros.strings()), j, w); }
public static final <T> AvroType<Collection<T>> collections(PType<T> ptype) { AvroType<T> avroType = (AvroType<T>) ptype; Schema collectionSchema = Schema.createArray(allowNulls(avroType .getSchema())); GenericDataArrayToCollection<T> input = new GenericDataArrayToCollection<T>( avroType.getInputMapFn()); CollectionToGenericDataArray output = new CollectionToGenericDataArray( collectionSchema, avroType.getOutputMapFn()); return new AvroType(Collection.class, collectionSchema, input, output, ptype); }
Avros { public static final <T> AvroType<Collection<T>> collections(PType<T> ptype) { AvroType<T> avroType = (AvroType<T>) ptype; Schema collectionSchema = Schema.createArray(allowNulls(avroType .getSchema())); GenericDataArrayToCollection<T> input = new GenericDataArrayToCollection<T>( avroType.getInputMapFn()); CollectionToGenericDataArray output = new CollectionToGenericDataArray( collectionSchema, avroType.getOutputMapFn()); return new AvroType(Collection.class, collectionSchema, input, output, ptype); } }
Avros { public static final <T> AvroType<Collection<T>> collections(PType<T> ptype) { AvroType<T> avroType = (AvroType<T>) ptype; Schema collectionSchema = Schema.createArray(allowNulls(avroType .getSchema())); GenericDataArrayToCollection<T> input = new GenericDataArrayToCollection<T>( avroType.getInputMapFn()); CollectionToGenericDataArray output = new CollectionToGenericDataArray( collectionSchema, avroType.getOutputMapFn()); return new AvroType(Collection.class, collectionSchema, input, output, ptype); } private  Avros(); }
Avros { public static final <T> AvroType<Collection<T>> collections(PType<T> ptype) { AvroType<T> avroType = (AvroType<T>) ptype; Schema collectionSchema = Schema.createArray(allowNulls(avroType .getSchema())); GenericDataArrayToCollection<T> input = new GenericDataArrayToCollection<T>( avroType.getInputMapFn()); CollectionToGenericDataArray output = new CollectionToGenericDataArray( collectionSchema, avroType.getOutputMapFn()); return new AvroType(Collection.class, collectionSchema, input, output, ptype); } private  Avros(); static void configureReflectDataFactory(Configuration conf); static ReflectDataFactory getReflectDataFactory(Configuration conf); static void register(Class<T> clazz, AvroType<T> ptype); static PType<T> getPrimitiveType(Class<T> clazz); static final AvroType<Void> nulls(); static final AvroType<String> strings(); static final AvroType<Long> longs(); static final AvroType<Integer> ints(); static final AvroType<Float> floats(); static final AvroType<Double> doubles(); static final AvroType<Boolean> booleans(); static final AvroType<ByteBuffer> bytes(); static final AvroType<T> records(Class<T> clazz); static final AvroType<GenericData.Record> generics(Schema schema); static final AvroType<T> containers(Class<T> clazz); static final AvroType<T> reflects(Class<T> clazz); static final AvroType<T> writables(
			Class<T> clazz); static final AvroType<Collection<T>> collections(PType<T> ptype); static final AvroType<Map<String, T>> maps(PType<T> ptype); static final AvroType<Pair<V1, V2>> pairs(PType<V1> p1,
			PType<V2> p2); static final AvroType<Tuple3<V1, V2, V3>> triples(
			PType<V1> p1, PType<V2> p2, PType<V3> p3); static final AvroType<Tuple4<V1, V2, V3, V4>> quads(
			PType<V1> p1, PType<V2> p2, PType<V3> p3, PType<V4> p4); static final AvroType<TupleN> tuples(PType... ptypes); static AvroType<T> tuples(Class<T> clazz,
			PType... ptypes); static final AvroType<T> derived(Class<T> clazz,
			MapFn<S, T> inputFn, MapFn<T, S> outputFn, PType<S> base); static PType<T> jsons(Class<T> clazz); static final AvroTableType<K, V> tableOf(PType<K> key,
			PType<V> value); }
Avros { public static final <T> AvroType<Collection<T>> collections(PType<T> ptype) { AvroType<T> avroType = (AvroType<T>) ptype; Schema collectionSchema = Schema.createArray(allowNulls(avroType .getSchema())); GenericDataArrayToCollection<T> input = new GenericDataArrayToCollection<T>( avroType.getInputMapFn()); CollectionToGenericDataArray output = new CollectionToGenericDataArray( collectionSchema, avroType.getOutputMapFn()); return new AvroType(Collection.class, collectionSchema, input, output, ptype); } private  Avros(); static void configureReflectDataFactory(Configuration conf); static ReflectDataFactory getReflectDataFactory(Configuration conf); static void register(Class<T> clazz, AvroType<T> ptype); static PType<T> getPrimitiveType(Class<T> clazz); static final AvroType<Void> nulls(); static final AvroType<String> strings(); static final AvroType<Long> longs(); static final AvroType<Integer> ints(); static final AvroType<Float> floats(); static final AvroType<Double> doubles(); static final AvroType<Boolean> booleans(); static final AvroType<ByteBuffer> bytes(); static final AvroType<T> records(Class<T> clazz); static final AvroType<GenericData.Record> generics(Schema schema); static final AvroType<T> containers(Class<T> clazz); static final AvroType<T> reflects(Class<T> clazz); static final AvroType<T> writables(
			Class<T> clazz); static final AvroType<Collection<T>> collections(PType<T> ptype); static final AvroType<Map<String, T>> maps(PType<T> ptype); static final AvroType<Pair<V1, V2>> pairs(PType<V1> p1,
			PType<V2> p2); static final AvroType<Tuple3<V1, V2, V3>> triples(
			PType<V1> p1, PType<V2> p2, PType<V3> p3); static final AvroType<Tuple4<V1, V2, V3, V4>> quads(
			PType<V1> p1, PType<V2> p2, PType<V3> p3, PType<V4> p4); static final AvroType<TupleN> tuples(PType... ptypes); static AvroType<T> tuples(Class<T> clazz,
			PType... ptypes); static final AvroType<T> derived(Class<T> clazz,
			MapFn<S, T> inputFn, MapFn<T, S> outputFn, PType<S> base); static PType<T> jsons(Class<T> clazz); static final AvroTableType<K, V> tableOf(PType<K> key,
			PType<V> value); static ReflectDataFactory REFLECT_DATA_FACTORY; static final String REFLECT_DATA_FACTORY_CLASS; static MapFn<CharSequence, String> UTF8_TO_STRING; static MapFn<String, Utf8> STRING_TO_UTF8; static MapFn<Object, ByteBuffer> BYTES_IN; }