Package com.djrapitops.plan.extension
Interface ExtensionService
public interface ExtensionService
Interface for registering
DataExtensions.
Obtaining instance:
- Obtain instance with getInstance().
- Make sure to catch a possible NoClassDefFoundError in case Plan is not installed
- Catch IllegalStateException in case ExtensionService is not enabled
Registering DataExtension:
- Register your DataExtension with register(DataExtension)
- Catch a possible IllegalArgumentException in case the DataExtension implementation is invalid.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic ExtensionServiceObtain instance of ExtensionService.newExtensionDataBuilder(DataExtension extension) Obtain a newExtensionDataBuilder, it is recommended to useDataExtension.newExtensionDataBuilder().register(DataExtension extension) Register yourDataExtensionimplementation.voidunregister(DataExtension extension) Unregister yourDataExtensionimplementation.
-
Method Details
-
getInstance
Obtain instance of ExtensionService.- Returns:
- ExtensionService implementation.
- Throws:
NoClassDefFoundError- If Plan is not installed and this class can not be found or if older Plan version is installed.IllegalStateException- If Plan is installed, but not enabled.
-
register
Register yourDataExtensionimplementation.You can use
ExtensionExtractor.validateAnnotations()in your Unit Tests to prevent IllegalArgumentExceptions here at runtime.- Parameters:
extension- Your DataExtension implementation, seeDataExtensionfor requirements.- Returns:
- Optional
Callerthat can be used to call for data update in Plan database manually - If the Optional is not present the user has disabled the extension in Plan config. - Throws:
IllegalArgumentException- If an implementation violation is found.
-
newExtensionDataBuilder
Obtain a newExtensionDataBuilder, it is recommended to useDataExtension.newExtensionDataBuilder().Requires Capability DATA_EXTENSION_BUILDER_API
- Parameters:
extension- Extension for which this builder is.- Returns:
- a new builder.
-
unregister
Unregister yourDataExtensionimplementation.This method should be used if calling methods on the DataExtension suddenly becomes unavailable, due to plugin disable for example.
- Parameters:
extension- Your DataExtension implementation that was registered before.
-