Class MethodYield

java.lang.Object
space.arim.dazzleconf.reflect.MethodYield

@API(status=MAINTAINED) public final class MethodYield extends Object
Bank of values yielded when calling an instantiated proxy.

This class is mutable: it is designed to be passed from its producer to its consumer. If defensive copies are needed, see copy().

  • Constructor Details

    • MethodYield

      public MethodYield()
      Creates an empty yield.
  • Method Details

    • forImplementable

      public MethodYield.ForImplementable forImplementable(@NonNull Class<?> implementable)
      Begins adding yield values for the given interface.

      The returned MethodYield.ForImplementable must be used, and closed, before this method can be called again. Additionally, this method cannot be used more than once with the same implementable argument.

      Parameters:
      implementable - the interface being implemented
      Returns:
      a handler to attach return values for it
    • clear

      public void clear()
      Clears all added values and starts over again
    • valuesFor

      public Map<@NonNull MethodId,@NonNull Object> valuesFor(@NonNull Class<?> implementable)
      Gets the yieldable values
      Parameters:
      implementable - the interface being implemented
      Returns:
      the values for method calls on that interface's methods, immutable
    • entries

      public @NonNull Iterable<@NonNull MethodYield.Entry> entries()
      Gets all entries added. Each entry represents a single return value instruction
      Returns:
      the iterable entries
    • sizeEstimate

      public int sizeEstimate()
      Gets the estimated number of entries
      Returns:
      the estimated size of this MethodYield
    • copy

      public @NonNull MethodYield copy()
      Returns a deep copy of this method yield's contents.

      Mutating this MethodYield, such as by adding or clearing values, will not affect the copy; likewise mutating the copy will not affect this instance.

      Returns:
      a copy of this method yield's contents
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object