Interface PointersSupplier<T>

Type Parameters:
T - the type

public sealed interface PointersSupplier<T>
A supplier of Pointers that allows for the implementation of pointers in a static context without having to manually create a new pointers instance for each instance of a given type.

An example of how this could be implemented is as follows:

public class MyPointeredObject extends SomePointeredParent implements Pointered {
  private static final PointersSupplier<MyPointeredObject> POINTERS = PointersSupplier.builder()
    .parent(SomePointeredParent.POINTERS) // Fallback to the parent to get pointers from.
    .resolving(Identity.UUID, MyPointeredObject::getUniqueId)
    .resolving(Identity.DISPLAY_NAME, MyPointeredObject::getDisplayName)
    .build();

  @Override
  public Pointers pointers() {
    return POINTERS.view(this);
  }
}
Since:
4.17.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A builder for PointersSupplier.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets a new pointers supplier builder.
    <P> @Nullable Function<? super T, P>
    resolver(Pointer<P> pointer)
    Returns the resolver for a given pointer (if any).
    <P> boolean
    supports(Pointer<P> pointer)
    Checks if this supplier supports a given pointer.
    view(T instance)
    Creates a pointers view for the given instance.
  • Method Details

    • builder

      static <T> PointersSupplier.Builder<T> builder()
      Gets a new pointers supplier builder.
      Type Parameters:
      T - the type
      Returns:
      the builder
      Since:
      4.17.0
    • view

      Pointers view(T instance)
      Creates a pointers view for the given instance.
      Parameters:
      instance - the instance
      Returns:
      the view
      Since:
      4.17.0
    • supports

      <P> boolean supports(Pointer<P> pointer)
      Checks if this supplier supports a given pointer.
      Type Parameters:
      P - the type of the pointer
      Parameters:
      pointer - the pointer
      Returns:
      if this supplier supports a given pointer
      Since:
      4.17.0
    • resolver

      <P> @Nullable Function<? super T, P> resolver(Pointer<P> pointer)
      Returns the resolver for a given pointer (if any).
      Type Parameters:
      P - the type of the pointer
      Parameters:
      pointer - the pointer
      Returns:
      the resolver, if any
      Since:
      4.17.0