/** * Builds a {@link Type} and returns the parent builder, if given, or the * {@code Type} that was built. If returning a parent object that is a * GroupBuilder, the constructed type will be added to it as a field. * <p> * <em>Note:</em> Any configuration for this type builder should be done * before calling this method. * * @param name a name for the constructed type * @return the parent {@code GroupBuilder} or the constructed {@code Type} */ public P named(String name) { Preconditions.checkNotNull(name, "Name is required"); Preconditions.checkNotNull(repetition, "Repetition is required"); Type type = build(name); if (parent != null) { // if the parent is a GroupBuilder, add type to it if (GroupBuilder.class.isAssignableFrom(parent.getClass())) { GroupBuilder.class.cast(parent).addField(type); } return parent; } else { // no parent indicates that the Type object should be returned // the constructor check guarantees that returnClass is a Type return returnClass.cast(type); } }
/** * Adds a type annotation ({@link OriginalType}) to the type being built. * <p> * Type annotations are used to extend the types that parquet can store, by * specifying how the primitive types should be interpreted. This keeps the * set of primitive types to a minimum and reuses parquet's efficient * encodings. For example, strings are stored as byte arrays (binary) with * a UTF8 annotation. * * @param type an {@code OriginalType} * @return this builder for method chaining */ public T as(OriginalType type) { this.originalType = type; return self(); }
/** * adds an id annotation to the type being built. * <p> * ids are used to capture the original id when converting from models using ids (thrift, protobufs) * * @param id the id of the field * @return this builder for method chaining */ public T id(int id) { this.id = new ID(id); return self(); }
protected final T repetition(Type.Repetition repetition) { Preconditions.checkArgument(!repetitionAlreadySet, "Repetition has already been set"); Preconditions.checkNotNull(repetition, "Repetition cannot be null"); this.repetition = repetition; this.repetitionAlreadySet = true; return self(); }