@Override protected FieldAccessor getAccessor(Field field) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return new ReflectionBasesAccessorCustomEncoded(field, enc.using().newInstance()); } catch (Exception e) { throw new AvroRuntimeException("Could not instantiate custom Encoding"); } return new ReflectionBasedAccessor(field); }
@AvroEncode(using = MapAsJsonAsStringEncoding.class) protected Map<String, Serializable> params;
@AvroEncode(using = MapAsJsonAsStringEncoding.class) protected Map<String, Serializable> result = new HashMap<>();
@Override protected FieldAccessor getAccessor(Field field) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return new ReflectionBasesAccessorCustomEncoded(field, enc.using().newInstance()); } catch (Exception e) { throw new AvroRuntimeException("Could not instantiate custom Encoding"); } return new ReflectionBasedAccessor(field); }
/** Create a schema for a field. */ protected Schema createFieldSchema(Field field, Map<String, Schema> names) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return enc.using().newInstance().getSchema(); } catch (Exception e) { throw new AvroRuntimeException("Could not create schema from custom serializer for " + field.getName()); } AvroSchema explicit = field.getAnnotation(AvroSchema.class); if (explicit != null) // explicit schema return Schema.parse(explicit.value()); Union union = field.getAnnotation(Union.class); if (union != null) return getAnnotatedUnion(union, names); Schema schema = createSchema(field.getGenericType(), names); if (field.isAnnotationPresent(Stringable.class)) { // Stringable schema = Schema.create(Schema.Type.STRING); } if (field.isAnnotationPresent(Nullable.class)) // nullable schema = makeNullable(schema); return schema; }
/** Create a schema for a field. */ protected Schema createFieldSchema(Field field, Map<String, Schema> names) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return enc.using().newInstance().getSchema(); } catch (Exception e) { throw new AvroRuntimeException("Could not create schema from custom serializer for " + field.getName()); } AvroSchema explicit = field.getAnnotation(AvroSchema.class); if (explicit != null) // explicit schema return Schema.parse(explicit.value()); Schema schema = createSchema(field.getGenericType(), names); if (field.isAnnotationPresent(Stringable.class)) { // Stringable schema = Schema.create(Schema.Type.STRING); } if (field.isAnnotationPresent(Nullable.class)) // nullable schema = makeNullable(schema); return schema; }
@Override protected FieldAccessor getAccessor(Field field) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return new UnsafeCustomEncodedField(field, enc.using().newInstance() ); } catch (Exception e) { throw new AvroRuntimeException("Could not instantiate custom Encoding"); } Class<?> c = field.getType(); if (c == int.class) return new UnsafeIntField(field); else if (c == long.class) return new UnsafeLongField(field); else if (c == byte.class) return new UnsafeByteField(field); else if (c == float.class) return new UnsafeFloatField(field); else if (c == double.class) return new UnsafeDoubleField(field); else if (c == char.class) return new UnsafeCharField(field); else if (c == boolean.class) return new UnsafeBooleanField(field); else if (c == short.class) return new UnsafeShortField(field); else return new UnsafeObjectField(field); }
@Override protected FieldAccessor getAccessor(Field field) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return new UnsafeCustomEncodedField(field, enc.using().newInstance() ); } catch (Exception e) { throw new AvroRuntimeException("Could not instantiate custom Encoding"); } Class<?> c = field.getType(); if (c == int.class) return new UnsafeIntField(field); else if (c == long.class) return new UnsafeLongField(field); else if (c == byte.class) return new UnsafeByteField(field); else if (c == float.class) return new UnsafeFloatField(field); else if (c == double.class) return new UnsafeDoubleField(field); else if (c == char.class) return new UnsafeCharField(field); else if (c == boolean.class) return new UnsafeBooleanField(field); else if (c == short.class) return new UnsafeShortField(field); else return new UnsafeObjectField(field); }
@Override protected FieldAccessor getAccessor(Field field) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return new ReflectionBasesAccessorCustomEncoded(field, enc.using().newInstance()); } catch (Exception e) { throw new AvroRuntimeException("Could not instantiate custom Encoding"); } return new ReflectionBasedAccessor(field); }
/** Create a schema for a field. */ protected Schema createFieldSchema(Field field, Map<String, Schema> names) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return enc.using().newInstance().getSchema(); } catch (Exception e) { throw new AvroRuntimeException("Could not create schema from custom serializer for " + field.getName()); } Schema schema = createSchema(field.getGenericType(), names); if (field.isAnnotationPresent(Stringable.class)) { // Stringable schema = Schema.create(Schema.Type.STRING); } if (field.isAnnotationPresent(Nullable.class)) // nullable schema = makeNullable(schema); return schema; }
/** Create a schema for a field. */ protected Schema createFieldSchema(Field field, Map<String, Schema> names) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return enc.using().newInstance().getSchema(); } catch (Exception e) { throw new AvroRuntimeException("Could not create schema from custom serializer for " + field.getName()); } AvroSchema explicit = field.getAnnotation(AvroSchema.class); if (explicit != null) // explicit schema return Schema.parse(explicit.value()); Schema schema = createSchema(field.getGenericType(), names); if (field.isAnnotationPresent(Stringable.class)) { // Stringable schema = Schema.create(Schema.Type.STRING); } if (field.isAnnotationPresent(Nullable.class)) // nullable schema = makeNullable(schema); return schema; }
@Override public Object findDeserializer(MapperConfig<?> config, Annotated am) { AvroEncode ann = _findAnnotation(am, AvroEncode.class); if (ann != null) { return new CustomEncodingDeserializer<>((CustomEncoding<?>)ClassUtil.createInstance(ann.using(), true)); } return null; }
@Override public Object findSerializer(MapperConfig<?> config, Annotated a) { if (a.hasAnnotation(Stringable.class)) { return ToStringSerializer.class; } AvroEncode ann = _findAnnotation(a, AvroEncode.class); if (ann != null) { return new CustomEncodingSerializer<>((CustomEncoding<?>)ClassUtil.createInstance(ann.using(), true)); } return null; }
@Override protected FieldAccessor getAccessor(Field field) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return new UnsafeCustomEncodedField(field, enc.using().newInstance() ); } catch (Exception e) { throw new AvroRuntimeException("Could not instantiate custom Encoding"); } Class<?> c = field.getType(); if (c == int.class) return new UnsafeIntField(field); else if (c == long.class) return new UnsafeLongField(field); else if (c == byte.class) return new UnsafeByteField(field); else if (c == float.class) return new UnsafeFloatField(field); else if (c == double.class) return new UnsafeDoubleField(field); else if (c == char.class) return new UnsafeCharField(field); else if (c == boolean.class) return new UnsafeBooleanField(field); else if (c == short.class) return new UnsafeShortField(field); else return new UnsafeObjectField(field); }
@Override protected FieldAccessor getAccessor(Field field) { AvroEncode enc = field.getAnnotation(AvroEncode.class); if (enc != null) try { return new UnsafeCustomEncodedField(field, enc.using().newInstance() ); } catch (Exception e) { throw new AvroRuntimeException("Could not instantiate custom Encoding"); } Class<?> c = field.getType(); if (c == int.class) return new UnsafeIntField(field); else if (c == long.class) return new UnsafeLongField(field); else if (c == byte.class) return new UnsafeByteField(field); else if (c == float.class) return new UnsafeFloatField(field); else if (c == double.class) return new UnsafeDoubleField(field); else if (c == char.class) return new UnsafeCharField(field); else if (c == boolean.class) return new UnsafeBooleanField(field); else if (c == short.class) return new UnsafeShortField(field); else return new UnsafeObjectField(field); }