Package me.nemo_64.betterinputs.api
Class BetterInputs<P>
- java.lang.Object
-
- me.nemo_64.betterinputs.api.BetterInputs<P>
-
public abstract class BetterInputs<P> extends Object
-
-
Constructor Summary
Constructors Constructor Description BetterInputs()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> InputBuilder<T>
createInput(Class<T> type)
Creates a new input builder<T> InputProvider<T>
createProvider(InputBuilder<T> builder)
Creates a new input provider based on thebuilder
abstract <E> Optional<IPlatformActor<E>>
getActor(E actor)
Gets a wrapped instance of the provided actorabstract Optional<InputFactory<?,?>>
getInputFactory(String namespacedKey)
Gets a factory by keyabstract <T> Optional<InputFactory<T,? extends AbstractInput<T>>>
getInputFactory(String namespacedKey, Class<T> inputType)
Gets a factory by key and input typeabstract IPlatformKeyProvider
getKeyProvider(P platformIdentifiable)
Gets a key provider for the platform identifiable objectabstract List<String>
getKeys()
Gets all known input factory keys asjava.lang.String
static BetterInputs<?>
getPlatform()
abstract <T> void
registerInputFactory(InputFactory<T,? extends AbstractInput<T>> factory)
Registers a new input factoryOptional<IPlatformKeyProvider>
tryGetKeyProvider(Object object)
Gets the key provider for the provided object which is supposed to be a platform identifiable objectabstract boolean
unregisterInputFactory(IPlatformKey platformKey)
Unregisters a input factory based on the provided key
-
-
-
Method Detail
-
getPlatform
public static BetterInputs<?> getPlatform()
-
getKeys
public abstract List<String> getKeys()
Gets all known input factory keys asjava.lang.String
- Returns:
- the list of all keys
-
tryGetKeyProvider
public final Optional<IPlatformKeyProvider> tryGetKeyProvider(Object object)
Gets the key provider for the provided object which is supposed to be a platform identifiable object- Parameters:
object
- the object that is supposed to be a platform identifiable object- Returns:
- an
java.lang.Optional
containing the key provider for the platform identifiable object ornull
if the object was not a platform identifiable object - Throws:
IllegalArgumentException
- if the platform identifiable is not valid for this platform
-
getKeyProvider
public abstract IPlatformKeyProvider getKeyProvider(P platformIdentifiable) throws NullPointerException, IllegalArgumentException
Gets a key provider for the platform identifiable object- Parameters:
platformIdentifiable
- the platform identifiable object- Returns:
- the key provider for the
platformIdentifiable
- Throws:
NullPointerException
- if the platform identifiable isnull
IllegalArgumentException
- if the platform identifiable is not valid for this platform
-
getActor
public abstract <E> Optional<IPlatformActor<E>> getActor(E actor)
Gets a wrapped instance of the provided actor- Type Parameters:
E
- the type of the actor- Parameters:
actor
- the provided actor- Returns:
- an
java.util.Optional
containing the wrapped actor ornull
if the actor is not supported or if the actor wasnull
-
getInputFactory
public abstract Optional<InputFactory<?,?>> getInputFactory(String namespacedKey)
Gets a factory by key- Parameters:
namespacedKey
- the key of the input factory- Returns:
- an
java.util.Optional
containing the requested input factory ornull
- Throws:
NullPointerException
- ifnamespacedKey
isnull
-
getInputFactory
public abstract <T> Optional<InputFactory<T,? extends AbstractInput<T>>> getInputFactory(String namespacedKey, Class<T> inputType) throws NullPointerException
Gets a factory by key and input type- Type Parameters:
T
- the provided input type- Parameters:
namespacedKey
- the key of the input factoryinputType
- the input type provided by the input provider type that the factory is creating- Returns:
- an
java.util.Optional
containing the requested input factory ornull
- Throws:
NullPointerException
- if eithernamespacedKey
orinputType
arenull
-
registerInputFactory
public abstract <T> void registerInputFactory(InputFactory<T,? extends AbstractInput<T>> factory) throws NullPointerException, IllegalArgumentException, IllegalStateException
Registers a new input factory- Type Parameters:
T
- the input type of the input provider type- Parameters:
factory
- the factory for the input provider type- Throws:
NullPointerException
- iffactory
isnull
IllegalArgumentException
- if the provided key of the factory was not created by this apiIllegalStateException
- if there is already a input factory with the provided key
-
unregisterInputFactory
public abstract boolean unregisterInputFactory(IPlatformKey platformKey) throws NullPointerException, IllegalArgumentException
Unregisters a input factory based on the provided key- Parameters:
platformKey
- the key of the input factory- Returns:
true
if the input factory was successfully unregistered otherwisefalse
- Throws:
NullPointerException
- if no key is providedIllegalArgumentException
- if the provided key was not created by this api
-
createInput
public final <T> InputBuilder<T> createInput(Class<T> type)
Creates a new input builder- Type Parameters:
T
- the provided input type- Parameters:
type
- the input type class- Returns:
- the new input builder
-
createProvider
public final <T> InputProvider<T> createProvider(InputBuilder<T> builder) throws NullPointerException, IllegalArgumentException, NotEnoughArgumentsException
Creates a new input provider based on thebuilder
- Type Parameters:
T
- the provided input type- Parameters:
builder
- the input builder that describes the input process- Returns:
- the new input provider
- Throws:
NullPointerException
- if the set actor was invalid or wasn't set at allIllegalArgumentException
- if there is no InputFactory with the set keyNotEnoughArgumentsException
- if the provided parameters were not enough to create the requested input provider type
-
-