Annotation Interface Conduit
Conduit never loads or runs the classes it scans, so a value it reconstructs (a constructor call, a factory call, a builder chain) is not an instance of anything. A conduit gives that value a typed face. Each method on the interface reads one piece of it, worked out from the bytecode that built it.
@Conduit("com.example.Color")
public interface Color {
int red();
int green();
int blue();
}
A conduit can be returned from another conduit, or taken as a parameter by an
Intercept handler, and is wrapped as needed.
Resolving a method
Each call on a conduit is resolved against the reconstructed value, in this order:
Conduit.Implementationreturns the class the value resolves to.Conduit.Bindentries, tried in the order they are declared.Method.CallsandMethod.Chain, narrowed byArgument.Index.Method.Index, thenArgument.Indexon its own.- Otherwise the method name (or
Argument.Named) is looked up on the target class as a field assigned in its constructor, or as a method whose return value can be evaluated. Agetorisprefix is dropped when looking for a field. - Failing all of that, the method's position in the interface is used as an argument index into the constructor or factory call.
A method that cannot be resolved returns null, or an empty List, Set
or Map for collection types. Boxed types such as Integer over
int are preferred since a primitive cannot hold the missing case.
Conduits are usually generated from the real class rather than written by hand. See
org.geysermc.conduit.generate.ConduitGenerator.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceDescribes one place a conduit method's value can come from.static @interfaceContainer for repeatedConduit.Bindentries.static @interfaceMarks a method that returns the binary name of the class implementing this conduit's target, ornullif it cannot be told. -
Required Element Summary
Required Elements
-
Element Details
-
value
String valueThe binary name of the class this conduit mirrors, such as"com.example.Color"or"com.example.Outer$Inner".- Returns:
- the target class name
-