Interface Union

  • All Superinterfaces:
    Field, Serializable
    All Known Implementing Classes:
    BaseUnion

    public interface Union
    extends Field
    Reflection interface for an union field.
    Author:
    mse
    • Method Detail

      • getField

        Field getField​(String fieldName)
        Get the Field for the specified fieldName
        Parameters:
        fieldName - the name of the field
        Returns:
        the Field that describes the field
      • getFieldIndex

        int getFieldIndex​(String fieldName)
        Get the index of the specified field.
        Parameters:
        fieldName - the name of the field
        Returns:
        the index or -1 if fieldName is not a field in the union
      • getFields

        Field[] getFields()
        Get a list of union fields (members).
        Returns:
        an array of fields (can be empty), non-null
      • getField

        Field getField​(int fieldIndex)
        Get a sub fields by index.
        Parameters:
        fieldIndex - the field index
        Returns:
        the field at specified index
      • getField

        <T extends Field> T getField​(Class<T> c,
                                     String fieldName)
        Get the Field for the specified fieldName
        Type Parameters:
        T - the expected type of the Field of the requested field
        Parameters:
        c - class object modeling the class T of expected type of the requested field
        fieldName - the fieldName
        Returns:
        the Field or null if the field does not exist, or the field is not of c type
      • getField

        <T extends Field> T getField​(Class<T> c,
                                     int fieldIndex)
        Get a subfield by index.
        Type Parameters:
        T - the expected type of the Field of the requested field
        Parameters:
        c - class object modeling the class T of expected type of the requested field
        fieldIndex - the index
        Returns:
        the Field or null if the index is invalid, or the field is not of c type
      • getFieldNames

        String[] getFieldNames()
        Get the array of the subfield names
        Returns:
        the array of the subfield names
      • getFieldName

        String getFieldName​(int fieldIndex)
        Get the name of the subfield by index.
        Parameters:
        fieldIndex - the field index
        Returns:
        the name of the field
      • isVariant

        boolean isVariant()
        Check if this union is variant union (aka any type).
        Returns:
        true if this union is variant union, otherwise false