Annotation Interface Conduit.Bind
- Enclosing class:
Conduit
@Retention(RUNTIME)
@Target(METHOD)
@Repeatable(Conduit.Binds.class)
public static @interface Conduit.Bind
Describes one place a conduit method's value can come from.
Repeat the annotation to describe more than one. Entries are tried in the order they are declared and the first that produces something wins, so a single method can read an object however the scanned code happened to build it:
@Conduit("com.example.Mesh")
public interface Mesh {
// new Mesh(root)
@Conduit.Bind(arg = 0, descriptor = "(Lcom/example/Part;)V", producer = "<init>")
// Mesh.create(); mesh.getRoot()...
@Conduit.Bind(calls = "getRoot")
Part root();
}
An entry first picks the calls it applies to, then picks a value out of each one:
- With
calls()orchain(), the matching calls on or behind the value. - Otherwise, the call that produced the value itself, such as its constructor or factory.
From each call, arg() selects an argument, or the call itself when unset. A
List return collects one result per call, a Map return is keyed by
key(), a boolean return reports whether any call matched, and any other
type takes the first call that resolves.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintThe index of the argument holding the value, counted from zero.Matches calls made on the value after it was built, by method name.Matches calls in the fluent chain that produced the value, by method name.The JVM descriptor of the method or constructor this entry describes, such as"(FFF)V".intStarts from an argument of this conduit's value rather than the value itself.intFor aMapreturn, the argument of each call to use as the entry's key.The name of the method that must have produced the value for this entry to apply, or"<init>"for a constructor.intHow many arguments, starting atarg(), make up the value.
-
Element Details
-
arg
int argThe index of the argument holding the value, counted from zero. Unset (-1) means the matched call itself.- Returns:
- the argument index
- Default:
-1
-
span
int spanHow many arguments, starting atarg(), make up the value. When more than one, they are gathered as if passed to the return type's own constructor, so three floats can be read back as a vector conduit.- Returns:
- the number of arguments
- Default:
1
-
from
int fromStarts from an argument of this conduit's value rather than the value itself. Useful when the data was attached to something the value was given, rather than to the value.- Returns:
- the argument index to start from, or
-1for the value itself
- Default:
-1
-
key
int keyFor aMapreturn, the argument of each call to use as the entry's key.- Returns:
- the argument index of the key
- Default:
-1
-
calls
String callsMatches calls made on the value after it was built, by method name. For examplecalls = "addChild"matches eachvalue.addChild(...).- Returns:
- the method name
- Default:
""
-
chain
String chainMatches calls in the fluent chain that produced the value, by method name. For a value built asBuilder.create().size(4).name("a"),chain = "size"matches thesize(4)call. The root of the chain can be matched too, by name for a static factory or as"<init>"for a constructor.- Returns:
- the method name
- Default:
""
-
descriptor
String descriptorThe JVM descriptor of the method or constructor this entry describes, such as"(FFF)V". Calls taking a different number of arguments are skipped, which keeps overloads with different shapes from answering for each other.- Returns:
- the descriptor
- Default:
""
-
producer
String producerThe name of the method that must have produced the value for this entry to apply, or"<init>"for a constructor. Overloads and sibling factories often share a descriptor, so this is what tellsoffset(x, y, z)apart fromrotation(x, y, z).- Returns:
- the producing method's name
- Default:
""
-