Class DataType

java.lang.Object
io.xpipe.core.data.type.DataType
Direct Known Subclasses:
ArrayType, TupleType, ValueType, WildcardType

public abstract class DataType extends Object
Represents the type of a DataStructureNode object. To check whether a DataStructureNode instance conforms to the specified type, the method matches(DataStructureNode) can be used.
  • Constructor Details

    • DataType

      public DataType()
  • Method Details

    • getName

      public abstract String getName()
      Returns the readable name of this data type that can be used for error messages.
    • convert

      public abstract Optional<DataStructureNode> convert(DataStructureNode node)
      Checks whether a node can be converted to this data type.
    • matches

      public abstract boolean matches(DataStructureNode node)
      Checks whether a node conforms to this data type.
    • isTuple

      public boolean isTuple()
      Checks whether this type is a tuple.
    • isWildcard

      public boolean isWildcard()
      Checks whether this type is a wildcard.
    • isArray

      public boolean isArray()
      Checks whether this type is an array.
    • isValue

      public boolean isValue()
      Checks whether this type is a value.
    • asWildcard

      public final WildcardType asWildcard()
      Casts this type to a wildcard type if possible.
      Throws:
      UnsupportedOperationException - if the type is not a wildcard type
    • asValue

      public final ValueType asValue()
      Casts this type to a value type if possible.
      Throws:
      UnsupportedOperationException - if the type is not a value type
    • asTuple

      public final TupleType asTuple()
      Casts this type to a tuple type if possible.
      Throws:
      UnsupportedOperationException - if the type is not a tuple type
    • asArray

      public final ArrayType asArray()
      Casts this type to an array type if possible.
      Throws:
      UnsupportedOperationException - if the type is not an array type
    • visit

      public abstract void visit(DataTypeVisitor visitor)
      Visits this type using a DataTypeVisitor instance.