Interface PointersSupplier<T>

Type Parameters:
T - the type

public 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
    static <T> @NotNull PointersSupplier.Builder<T>
    Gets a new pointers supplier builder.
    <P> @Nullable Function<? super T,P>
    resolver(@NotNull Pointer<P> pointer)
    Returns the resolver for a given pointer (if any).
    <P> boolean
    supports(@NotNull Pointer<P> pointer)
    Checks if this supplier supports a given pointer.
    @NotNull Pointers
    view(T instance)
    Creates a pointers view for the given instance.
  • Method Details

    • builder

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

      @NotNull @NotNull Pointers view(@NotNull 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(@NotNull @NotNull 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

      @Nullable <P> @Nullable Function<? super T,P> resolver(@NotNull @NotNull 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