Package net.kyori.adventure.pointer
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull PointersSupplier.Builder<T>
builder()
Gets a new pointers supplier builder.Returns the resolver for a given pointer (if any).<P> boolean
Checks if this supplier supports a given pointer.@NotNull Pointers
Creates a pointers view for the given instance.
-
Method Details
-
builder
Gets a new pointers supplier builder.- Type Parameters:
T
- the type- Returns:
- the builder
- Since:
- 4.17.0
-
view
Creates a pointers view for the given instance.- Parameters:
instance
- the instance- Returns:
- the view
- Since:
- 4.17.0
-
supports
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
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
-