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() or chain(), 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 Elements
    Modifier and Type
    Optional Element
    Description
    int
    The 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".
    int
    Starts from an argument of this conduit's value rather than the value itself.
    int
    For a Map return, 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.
    int
    How many arguments, starting at arg(), make up the value.
  • Element Details

    • arg

      int arg
      The 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 span
      How many arguments, starting at arg(), 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 from
      Starts 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 -1 for the value itself
      Default:
      -1
    • key

      int key
      For a Map return, the argument of each call to use as the entry's key.
      Returns:
      the argument index of the key
      Default:
      -1
    • calls

      String calls
      Matches calls made on the value after it was built, by method name. For example calls = "addChild" matches each value.addChild(...).
      Returns:
      the method name
      Default:
      ""
    • chain

      String chain
      Matches calls in the fluent chain that produced the value, by method name. For a value built as Builder.create().size(4).name("a"), chain = "size" matches the size(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 descriptor
      The 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 producer
      The 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 tells offset(x, y, z) apart from rotation(x, y, z).
      Returns:
      the producing method's name
      Default:
      ""