Class PeripheralType

java.lang.Object
dan200.computercraft.api.peripheral.PeripheralType

public final class PeripheralType extends Object
The type of a GenericPeripheral.

When determining the final type of the resulting peripheral, the union of all types is taken, with the lexicographically smallest non-empty name being chosen.

  • Constructor Details

    • PeripheralType

      public PeripheralType(@Nullable String type, Set<String> additionalTypes)
  • Method Details

    • untyped

      public static PeripheralType untyped()
      An empty peripheral type, used when a GenericPeripheral does not have an explicit type.
      Returns:
      The empty peripheral type.
    • ofType

      public static PeripheralType ofType(String type)
      Create a new non-empty peripheral type.
      Parameters:
      type - The name of the type.
      Returns:
      The constructed peripheral type.
    • ofType

      public static PeripheralType ofType(String type, Collection<String> additionalTypes)
      Create a new non-empty peripheral type with additional traits.
      Parameters:
      type - The name of the type.
      additionalTypes - Additional types, or "traits" of this peripheral. For instance, "inventory".
      Returns:
      The constructed peripheral type.
    • ofType

      public static PeripheralType ofType(String type, String... additionalTypes)
      Create a new non-empty peripheral type with additional traits.
      Parameters:
      type - The name of the type.
      additionalTypes - Additional types, or "traits" of this peripheral. For instance, "inventory".
      Returns:
      The constructed peripheral type.
    • ofAdditional

      public static PeripheralType ofAdditional(Collection<String> additionalTypes)
      Create a new peripheral type with no primary type but additional traits.
      Parameters:
      additionalTypes - Additional types, or "traits" of this peripheral. For instance, "inventory".
      Returns:
      The constructed peripheral type.
    • ofAdditional

      public static PeripheralType ofAdditional(String... additionalTypes)
      Create a new peripheral type with no primary type but additional traits.
      Parameters:
      additionalTypes - Additional types, or "traits" of this peripheral. For instance, "inventory".
      Returns:
      The constructed peripheral type.
    • getPrimaryType

      @Nullable public String getPrimaryType()
      Get the name of this peripheral type. This may be null.
      Returns:
      The type of this peripheral.
    • getAdditionalTypes

      public Set<String> getAdditionalTypes()
      Get any additional types or "traits" of this peripheral. These effectively act as a standard set of interfaces a peripheral might have.
      Returns:
      All additional types.