Class GroupType

  • Direct Known Subclasses:
    MessageType

    public class GroupType
    extends Type
    Represents a group type: a list of fields
    • Constructor Detail

      • GroupType

        public GroupType​(Type.Repetition repetition,
                         String name,
                         List<Type> fields)
        Parameters:
        repetition - OPTIONAL, REPEATED, REQUIRED
        name - the name of the field
        fields - the contained fields
      • GroupType

        public GroupType​(Type.Repetition repetition,
                         String name,
                         Type... fields)
        Parameters:
        repetition - OPTIONAL, REPEATED, REQUIRED
        name - the name of the field
        fields - the contained fields
      • GroupType

        @Deprecated
        public GroupType​(Type.Repetition repetition,
                         String name,
                         OriginalType originalType,
                         Type... fields)
        Deprecated.
        Parameters:
        repetition - OPTIONAL, REPEATED, REQUIRED
        name - the name of the field
        originalType - (optional) the original type to help with cross schema conversion (LIST, MAP, ...)
        fields - the contained fields
      • GroupType

        @Deprecated
        public GroupType​(Type.Repetition repetition,
                         String name,
                         OriginalType originalType,
                         List<Type> fields)
        Deprecated.
        Parameters:
        repetition - OPTIONAL, REPEATED, REQUIRED
        name - the name of the field
        originalType - (optional) the original type to help with cross schema conversion (LIST, MAP, ...)
        fields - the contained fields
    • Method Detail

      • withId

        public GroupType withId​(int id)
        Specified by:
        withId in class Type
        Parameters:
        id - the field id
        Returns:
        a new GroupType with the same fields and a new id
      • withNewFields

        public GroupType withNewFields​(List<Type> newFields)
        Parameters:
        newFields - a list of types to use as fields in a copy of this group
        Returns:
        a group with the same attributes and new fields.
      • withNewFields

        public GroupType withNewFields​(Type... newFields)
        Parameters:
        newFields - an array of types to use as fields in a copy of this group
        Returns:
        a group with the same attributes and new fields.
      • getFieldName

        public String getFieldName​(int index)
        returns the name of the corresponding field
        Parameters:
        index - the index of the desired field in this type
        Returns:
        the name of the field at this index
      • containsField

        public boolean containsField​(String name)
        Parameters:
        name - the requested name
        Returns:
        whether this type contains a field with that name
      • getFieldIndex

        public int getFieldIndex​(String name)
        Parameters:
        name - string name of a field
        Returns:
        the index of the field with that name
      • getFields

        public List<Type> getFields()
        Returns:
        the fields contained in this type
      • getFieldCount

        public int getFieldCount()
        Returns:
        the number of fields in this type
      • isPrimitive

        public boolean isPrimitive()
        Specified by:
        isPrimitive in class Type
        Returns:
        false
      • getType

        public Type getType​(String fieldName)
        Parameters:
        fieldName - string name of a field
        Returns:
        the type of this field by name
      • getType

        public Type getType​(int index)
        Parameters:
        index - integer index of a field
        Returns:
        the type of this field by index
      • writeToStringBuilder

        public void writeToStringBuilder​(StringBuilder sb,
                                         String indent)
        Writes a string representation to the provided StringBuilder
        Specified by:
        writeToStringBuilder in class Type
        Parameters:
        sb - the StringBuilder to write itself to
        indent - indentation level
      • accept

        public void accept​(TypeVisitor visitor)
        Visits this type with the given visitor
        Specified by:
        accept in class Type
        Parameters:
        visitor - the visitor to visit this type
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Type
      • equals

        protected boolean equals​(Type otherType)
        Overrides:
        equals in class Type
      • containsPath

        protected boolean containsPath​(String[] path,
                                       int depth)
        Specified by:
        containsPath in class Type
      • union

        protected Type union​(Type toMerge)
        Specified by:
        union in class Type
        Parameters:
        toMerge - the type to merge into this one
        Returns:
        the union result of merging toMerge into this
      • union

        protected Type union​(Type toMerge,
                             boolean strict)
        Specified by:
        union in class Type
        Parameters:
        toMerge - the type to merge into this one
        strict - should schema primitive types match
        Returns:
        the union result of merging toMerge into this