C - The feature configuration type.R - The feature return value type.F - The framework that will install/manage this feature.public interface Feature<C,R,F>
Features are unknown internally and can only be accessed from themselves or from a reference created by them, as a recommendation, a feature must be immutable and preferably inaccessible outside the package of the feature itself, only the reference of that Feature used to install and obtain the instance value must be externally accessible.
The recommended style of building a feature is to use a helper class as an instance value, which will be taken when the Feature is referenced, and the class of the feature itself is private while its key is public for later installation.
Since features are immutable at runtime, there needs to be a way to pre-define their initial values in case it is necessary for them to act together with these values, defined by the user, for that there is the FeatureConfig, which is the first parameter of the Feature interface, which must be a __configuration builder__ and not the configuration itself.
@Builder(builderClassName = "Builder")
@Data
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
final class SampleFeatureConfig {}
It is important to note that features are singleton instances and can only be modified (by themselves) once in their entire lifecycle, which is during their installation. The FeatureInstaller must ensure that this is applied and the Feature instance can also add a second check to ensure that there are not multiple references to a single feature.
| Modifier and Type | Interface and Description |
|---|---|
static class |
Feature.Keys |
| Modifier and Type | Method and Description |
|---|---|
R |
install(F framework,
java.util.function.UnaryOperator<C> configure)
Initializes and installs everything that must be installed within this feature using the
platform and configuration factory as providers.
|
@NotNull java.lang.String |
name()
The name of this feature.
|
void |
uninstall(F framework)
Uninstalls this feature, used to invalidate resources applied on installation.
|
@NotNull @NotNull java.lang.String name()
@NotNull R install(F framework, java.util.function.UnaryOperator<C> configure)
framework - The feature installer platform framework.configure - The feature configuration factory.void uninstall(F framework)
framework - The feature uninstaller framework.install(Object, UnaryOperator)