Class PojoTypeInfo<T>

  • Type Parameters:
    T - The type represented by this type information.
    All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    AvroTypeInfo

    @Public
    public class PojoTypeInfo<T>
    extends CompositeType<T>
    TypeInformation for "Java Beans"-style types. Flink refers to them as POJOs, since the conditions are slightly different from Java Beans. A type is considered a Flink POJO type, if it fulfills the conditions below.
    • It is a public class, and standalone (not a non-static inner class)
    • It has a public no-argument constructor.
    • All non-static, non-transient fields in the class (and all superclasses) are either public (and non-final) or have a public getter and a setter method that follows the Java beans naming conventions for getters and setters.
    • It is a fixed-length, null-aware composite type with non-deterministic field order. Every field can be null independent of the field's type.
    Java Record classes can also be used as valid POJOs (even though they don't fulfill some of the above criteria). In this case Flink will use the record canonical constructor to create the objects.
    See Also:
    Serialized Form
    • Method Detail

      • isBasicType

        @PublicEvolving
        public boolean isBasicType()
        Description copied from class: TypeInformation
        Checks if this type information represents a basic type. Basic types are defined in BasicTypeInfo and are primitives, their boxing types, Strings, Date, Void, ...
        Specified by:
        isBasicType in class TypeInformation<T>
        Returns:
        True, if this type information describes a basic type, false otherwise.
      • isTupleType

        @PublicEvolving
        public boolean isTupleType()
        Description copied from class: TypeInformation
        Checks if this type information represents a Tuple type. Tuple types are subclasses of the Java API tuples.
        Specified by:
        isTupleType in class TypeInformation<T>
        Returns:
        True, if this type information describes a tuple type, false otherwise.
      • getArity

        @PublicEvolving
        public int getArity()
        Description copied from class: TypeInformation
        Gets the arity of this type - the number of fields without nesting.
        Specified by:
        getArity in class TypeInformation<T>
        Returns:
        Gets the number of fields in this type without nesting.
      • getTotalFields

        @PublicEvolving
        public int getTotalFields()
        Description copied from class: TypeInformation
        Gets the number of logical fields in this type. This includes its nested and transitively nested fields, in the case of composite types. In the example above, the OuterType type has three fields in total.

        The total number of fields must be at least 1.

        Specified by:
        getTotalFields in class TypeInformation<T>
        Returns:
        The number of fields in this type, including its sub-fields (for composite types)
      • getFlatFields

        @PublicEvolving
        public void getFlatFields​(String fieldExpression,
                                  int offset,
                                  List<CompositeType.FlatFieldDescriptor> result)
        Description copied from class: CompositeType
        Computes the flat field descriptors for the given field expression with the given offset.
        Specified by:
        getFlatFields in class CompositeType<T>
        Parameters:
        fieldExpression - The field expression for which the FlatFieldDescriptors are computed.
        offset - The offset to use when computing the positions of the flat fields.
        result - The list into which all flat field descriptors are inserted.
      • getTypeAt

        @PublicEvolving
        public <X> TypeInformation<X> getTypeAt​(String fieldExpression)
        Description copied from class: CompositeType
        Returns the type of the (nested) field at the given field expression position. Wildcards are not allowed.
        Specified by:
        getTypeAt in class CompositeType<T>
        Parameters:
        fieldExpression - The field expression for which the field of which the type is returned.
        Returns:
        The type of the field at the given field expression.
      • getTypeAt

        @PublicEvolving
        public <X> TypeInformation<X> getTypeAt​(int pos)
        Description copied from class: CompositeType
        Returns the type of the (unnested) field at the given field position.
        Specified by:
        getTypeAt in class CompositeType<T>
        Parameters:
        pos - The position of the (unnested) field in this composite type.
        Returns:
        The type of the field at the given position.
      • getFieldNames

        @PublicEvolving
        public String[] getFieldNames()
        Description copied from class: CompositeType
        Returns the names of the composite fields of this type. The order of the returned array must be consistent with the internal field index ordering.
        Specified by:
        getFieldNames in class CompositeType<T>
      • getFieldIndex

        @PublicEvolving
        public int getFieldIndex​(String fieldName)
        Description copied from class: CompositeType
        Returns the field index of the composite field of the given name.
        Specified by:
        getFieldIndex in class CompositeType<T>
        Returns:
        The field index or -1 if this type does not have a field of the given name.
      • canEqual

        public boolean canEqual​(Object obj)
        Description copied from class: TypeInformation
        Returns true if the given object can be equaled with this object. If not, it returns false.
        Overrides:
        canEqual in class CompositeType<T>
        Parameters:
        obj - Object which wants to take part in the equality relation
        Returns:
        true if obj can be equaled with this, otherwise false