Class Conduits

java.lang.Object
org.geysermc.conduit.Conduits

public final class Conduits extends Object
Utilities for working with conduit instances.
  • Method Details

    • as

      public static <T> T as(Value value, Class<T> conduit, ConduitContext context)
      Views a value through a conduit, such as one found in a Summary.
      Type Parameters:
      T - the conduit type
      Parameters:
      value - the value
      conduit - the conduit interface
      context - the context the value was read from
      Returns:
      the conduit, or null if the value can't be viewed as one
    • withTypeArgument

      public static <T> T withTypeArgument(T conduit, String className)
      Views a conduit with a known class standing in for the type variable its target is declared with.

      A generic class shared between several types, such as a Handler<T> registered once per type, can't say which type a value belongs to, so anything it reads from T stays unresolved. The code registering it usually does know, and this passes that on.

      Handler handler = Conduits.withTypeArgument(registration.handler(), "com.example.Sheep");
      List<String> textures = handler.texture();
      

      A type argument the class declares itself, such as Handler<Sheep>, takes precedence.

      Type Parameters:
      T - the conduit type
      Parameters:
      conduit - the conduit
      className - the binary name of the class standing in for the type variable
      Returns:
      a conduit over the same value, or conduit unchanged if it is null or not a conduit