Annotation Interface SchemaFieldNumber


@Documented @Retention(RUNTIME) @Target({FIELD,METHOD}) public @interface SchemaFieldNumber
When used on a POJO field, a Java Bean getter, or an AutoValue getter, the generated field will have the specified index. There cannot be "gaps" in field numbers, or schema inference will fail. If used, all fields (or getters in the case of a bean) must be annotated.

The annotation takes a String as an argument, but this has to be an Integer-parsable String. Otherwise the pipeline will throw a RuntimeException.

For example, say we have a Java POJO with a field that we want in our schema but under a different name:


  @DefaultSchema(JavaFieldSchema.class)
   class MyClass {
     @SchemaFieldNumber("1")
     public String user;

    @SchemaFieldNumber("0")
     public int ageInYears;
   }
 

The resulting schema will have ageInYears first followed by user.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name to use for the generated schema field.
  • Element Details

    • value

      The name to use for the generated schema field.