Class Conduits
java.lang.Object
org.geysermc.conduit.Conduits
Utilities for working with conduit instances.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Tas(Value value, Class<T> conduit, ConduitContext context) Views a value through a conduit, such as one found in aSummary.static <T> TwithTypeArgument(T conduit, String className) Views a conduit with a known class standing in for the type variable its target is declared with.
-
Method Details
-
as
Views a value through a conduit, such as one found in aSummary.- Type Parameters:
T- the conduit type- Parameters:
value- the valueconduit- the conduit interfacecontext- the context the value was read from- Returns:
- the conduit, or null if the value can't be viewed as one
-
withTypeArgument
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 fromTstays 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 conduitclassName- the binary name of the class standing in for the type variable- Returns:
- a conduit over the same value, or
conduitunchanged if it is null or not a conduit
-