Class JDACPropertyProvider<T>
- Type Parameters:
T- the type returned by the supplier
A JDACPropertyProvider supplies the values for a property.
Each JDACPropertyProvider is bound to one property for which it can provide values.
Based on the Property.Source of the property, property providers can be registered via different ways. Visit the documentation
of Property.Source for more information on that matter.
The possibly returned types vary based on the type of the property:
- for
JDACSingletonProperty, a provider can "return" one instance - for
JDACEnumerationProperty, a provider can "return" an instance ofCollection - for
JDACMappingProperty, a provider can "return" an instance ofMap
The values are "provided" by the supplier, which is called during resolution. The supplier must be threadsafe and side effect free, as it could be called multiple times during resolution simultaneously. Although that, only one value is stored finally (using a "check-then-act" pattern).
Furthermore, each JDACPropertyProvider has a priority stating which providers take
precedence over others. For more information on that, visit the documentation of JDACSingletonProperty, JDACEnumerationProperty
and JDACMappingProperty.
Following priorities have a special meaning in JDA-Commands:
- priority =
Priority.FALLBACKare all fallback/default values provided by JDA-Commands - priority =
Priority.BUILDERare all values set by the user manually inJDACBuilder - priority between 1 and 100 are reserved for internal usage.
Usage of reserved priorities will result in an exception causing JDA-Commands to stop itself.
For debugging purpose, JDACPropertyProviders store their "owner", which is the class or "logical unit"
(for example the library providing an extension for some property), that can be used to identify an JDACPropertyProvider
during runtime.
Dependencies on other properties
The supplier allows access to the JDACIntrospection instance used to resolve this
property. This can be used to retrieve the values of other properties needed by this JDACPropertyProvider, thus creating
a dependency on that other property.
JDA-Commands checks for cycling dependencies during runtime and will provide all needed information to identify the cycle.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJDACPropertyProvider(JDACProperty<T> property, dev.goldmensch.propane.property.Priority priority, Class<?> owner, Function<JDACIntrospection, T> supplier) -
Method Summary
Methods inherited from class dev.goldmensch.propane.property.PropertyProviderSkeleton
equals, hashCode, owner, priority, property, supplier, toString
-
Constructor Details
-
JDACPropertyProvider
public JDACPropertyProvider(JDACProperty<T> property, dev.goldmensch.propane.property.Priority priority, Class<?> owner, Function<JDACIntrospection, T> supplier)
-