Package net.kyori.adventure.pointer
Interface PointersSupplier<T>
-
- Type Parameters:
T- the type
public interface PointersSupplier<T>A supplier ofPointersthat 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 interfacePointersSupplier.Builder<T>A builder forPointersSupplier.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <T> @NotNull PointersSupplier.Builder<T>builder()Gets a new pointers supplier builder.<P> @Nullable java.util.function.Function<? super T,P>resolver(@NotNull Pointer<P> pointer)Returns the resolver for a given pointer (if any).<P> booleansupports(@NotNull Pointer<P> pointer)Checks if this supplier supports a given pointer.@NotNull Pointersview(T instance)Creates a pointers view for the given instance.
-
-
-
Method Detail
-
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
-
-