Class DefaultResourceTypeMeta.ExtensionPointBuilder<P extends ExtensionPointProfileConfig>
- Type Parameters:
P
- The config object type for the extension point's "profile" configuration. Note that the type-specific "settings" object types are not defined here, but rather on eachExtensionPoint
type.
- Enclosing class:
- DefaultResourceTypeMeta<R>
-
Constructor Summary
ConstructorsConstructorDescriptionExtensionPointBuilder
(Class<P> profileType) Creates a new builder for an extension point resource type. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
buildActionSet
(Consumer<ResourceActionSet.Builder> actionSetBuilder) Builds an entity delegate for the resource type.Allows customization of the gson instance used by theExtensionPointResourceCodec
that will be built.buildProfileValidator
(BiConsumer<P, ValidationErrors.Builder> validator) Helps build a basic profile validator.buildReferenceDelegate
(Consumer<ExtensionPointReferenceDelegate.Builder<P>> builderConsumer) Allows for customization of a reference delegate.buildRouteDelegate
(Consumer<DefaultResourceRouteDelegate.ExtensionPointBuilder<P>> builderConsumer) Builds a route delegate for this resource type.buildScriptDelegate
(Consumer<DefaultResourceScriptDelegate.Builder> builderConsumer) buildStatusDelegate
(Consumer<DefaultResourceStatusDelegate.Builder> builderConsumer) Builds a status delegate for the resource type.categoryName
(String categoryName) Provide a "category name" for your resource, for example "Schedules" or "Module Widgets".categoryNameKey
(String categoryNameKey) Similar to callingcategoryName(String)
but uses an i18n key instead of a raw literal string.description
(String description) Provide a description for your resource.descriptionKey
(String description) Provide a description for your resource.displayNameFunction
(BiFunction<ResourceId, Locale, String> displayNameFunction) Provides a function that can be used to derive the display name of a resource.extensionPointCollection
(ExtensionPointCollection<? extends ExtensionPoint<?>> extensionPointCollection) Sets the extension point collection for this extension point.iconPath
(Function<ResourceId, String> iconPath) preferredResourceCollection
(String preferredResourceCollection) Sets the preferred resource collection for the resource type.resourceType
(ResourceType resourceType) Sets the resource type.withActionSet
(ResourceActionSet actionMap) withAuditDelegate
(ResourceAuditDelegate auditDelegate) Sets an audit delegate for this resource type.withCodec
(ResourceCodec<ExtensionPointConfig<P, ?>> codec) Sets the codec directly.withDefaultProfile
(P defaultProfile) Supplies the default values for this extension point's profile configuration.withEntityDelegate
(ResourceEntityDelegate entityDelegate) Sets an entity delegate for this resource type.withProfileValidator
(ResourceValidator<P> profileValidator) Sets a validator for the extension point profile config object.withReferenceDelegate
(ResourceReferenceDelegate<ExtensionPointConfig<P, ?>> referenceDelegate) Sets a reference delegate for this resource type.withRouteDelegate
(ResourceRouteDelegate<ExtensionPointConfig<P, ?>> routeDelegate) Sets the route delegate for the resource type.withScriptDelegate
(ResourceScriptDelegate scriptDelegate) withStatusDelegate
(ResourceStatusDelegate statusDelegate) Sets a custom status delegate.
-
Constructor Details
-
ExtensionPointBuilder
Creates a new builder for an extension point resource type.- Parameters:
profileType
- The class that represents the profile (shared) configuration object for all instances of this extension point.
-
-
Method Details
-
resourceType
Sets the resource type. Note that the resource type defines the extension point itself, and not an individual extension point type. Extension point types are defined by instances ofExtensionPoint
and exposed byGatewayModuleHook.getExtensionPoints()
.This is required.
-
extensionPointCollection
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> extensionPointCollection(ExtensionPointCollection<? extends ExtensionPoint<?>> extensionPointCollection) Sets the extension point collection for this extension point. This collection contains all the registered extension point types for this extension point. Extension points often have a mix of statically-defined and module-provided types. This collection can be created like this:ExtensionPointCollection<MyExtensionPoint> = ImmutableExtensionPointCollection.build( myExtensionPointResourceType, gatewayContext.getModuleManager(), new MyFirstStaticType(), new MySecondStaticType() );
This is required.
-
categoryName
Provide a "category name" for your resource, for example "Schedules" or "Module Widgets". If you have this string defined in an i18n file, you can use the key version of this method by callingcategoryNameKey(String)
.This (or
categoryNameKey(String)
) is required. -
categoryNameKey
Similar to callingcategoryName(String)
but uses an i18n key instead of a raw literal string.This (or
categoryName(String)
) is required.- See Also:
-
description
Provide a description for your resource. If you have this string defined in an i18n file, you can use the key version of this method by callingdescriptionKey(String)
. -
descriptionKey
Provide a description for your resource. Similar to callingdescription(String)
but uses an i18n key instead of a raw literal string.- See Also:
-
preferredResourceCollection
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> preferredResourceCollection(String preferredResourceCollection) Sets the preferred resource collection for the resource type. Useful in cases where a resource type should always be created in "local".This is optional, and defaults to "core".
-
displayNameFunction
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> displayNameFunction(BiFunction<ResourceId, Locale, String> displayNameFunction) Provides a function that can be used to derive the display name of a resource.This is optional, and the resource's innate name or type (for singletons) will be used if this is not set.
- See Also:
-
iconPath
-
iconPath
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> iconPath(Function<ResourceId, String> iconPath) -
withCodec
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> withCodec(ResourceCodec<ExtensionPointConfig<P, ?>> codec) Sets the codec directly. Use this if you have a custom codec that you want to use. This is not common, you likely want to callbuildGson(Consumer)
and/orwithProfileValidator(ResourceValidator)
instead.This is optional.
If this resource type opts into the route system (e.g. by providing a route delegate), the codec must be a
JsonResourceCodec
. -
buildGson
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> buildGson(Consumer<com.inductiveautomation.ignition.common.gson.GsonBuilder> gsonCustomizer) Allows customization of the gson instance used by theExtensionPointResourceCodec
that will be built. This is the gson instance that will be used to encode and decode the extension point profile config object.Note that this is only half the story for encoding and decoding extension point resources. Each extension point type may also provide a custom gson for encoding/decoding its settings object. This is done through
ExtensionPoint.decode(JsonElement)
If you call this, you shouldn't be calling
withCodec(ResourceCodec)
This is optional.
-
withProfileValidator
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> withProfileValidator(ResourceValidator<P> profileValidator) Sets a validator for the extension point profile config object.Note that this is only half the story for validating extension point resources. Each extension point type can also provide a validator for its settings config object: this is done through
ExtensionPoint.getSettingsValidator()
.If you call this, you shouldn't be calling
withCodec(ResourceCodec)
This is optional.
-
buildProfileValidator
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> buildProfileValidator(BiConsumer<P, ValidationErrors.Builder> validator) Helps build a basic profile validator. Example:.buildProfileValidator((profile, validation) -> validation .requireNonNull(profile.getSomeField(), "someField", "Some field is required") .check(profile.someValidityCheck(), "profile state invalid because reasons"))
If you call this method, do not call
withCodec(ResourceCodec)
.This is optional.
- Parameters:
validator
- Receives the config object and a ValidationErrors.Builder to add errors to. If no errors are added to the builder, the resource "passes" validation.
-
withActionSet
-
buildActionSet
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> buildActionSet(Consumer<ResourceActionSet.Builder> actionSetBuilder) -
withRouteDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> withRouteDelegate(ResourceRouteDelegate<ExtensionPointConfig<P, ?>> routeDelegate) Sets the route delegate for the resource type. By setting a route delegate, you enable CRUD routes for the resources of this type. Typically, you will call #buildrouteDelegate(Consumer) instead of this method (don't call both).This is optional.
-
buildRouteDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> buildRouteDelegate(Consumer<DefaultResourceRouteDelegate.ExtensionPointBuilder<P>> builderConsumer) Builds a route delegate for this resource type. By calling this method (orwithRouteDelegate(ResourceRouteDelegate)
) you enable CRUD routes for the resources of this type.This is optional
-
withScriptDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> withScriptDelegate(ResourceScriptDelegate scriptDelegate) -
buildScriptDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> buildScriptDelegate(Consumer<DefaultResourceScriptDelegate.Builder> builderConsumer) -
withStatusDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> withStatusDelegate(ResourceStatusDelegate statusDelegate) Sets a custom status delegate. Usually these are built, seebuildStatusDelegate(Consumer)
. Don't call both methods.This is optional
-
buildStatusDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> buildStatusDelegate(Consumer<DefaultResourceStatusDelegate.Builder> builderConsumer) Builds a status delegate for the resource type. The status delegate is responsible for looking up metrics and healthchecks for resource instances. If you use this builder method, don't callwithStatusDelegate(ResourceStatusDelegate)
This is optional.
-
withEntityDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> withEntityDelegate(ResourceEntityDelegate entityDelegate) Sets an entity delegate for this resource type. This is used to generate entities for the resource type. If omitted, a default delegate will be used. -
buildEntityDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> buildEntityDelegate(Consumer<DefaultResourceEntityDelegate.Builder> consumer) Builds an entity delegate for the resource type. This is used to generate entities for the resource type. If you use this builder method, don't callwithEntityDelegate(ResourceEntityDelegate)
This is optional.
-
withReferenceDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> withReferenceDelegate(ResourceReferenceDelegate<ExtensionPointConfig<P, ?>> referenceDelegate) Sets a reference delegate for this resource type. Usually reference delegates are built usingbuildReferenceDelegate(Consumer)
. Don't call both methods.This is optional.
-
buildReferenceDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> buildReferenceDelegate(Consumer<ExtensionPointReferenceDelegate.Builder<P>> builderConsumer) Allows for customization of a reference delegate. Reference delegates are used to find references to other resources, so that they can be updated when resources are renamed.Note that each extension point may need to also resolve references for the settings object, and this is done in
ExtensionPoint.getReferenceProperties()
This is optional.
-
withAuditDelegate
public DefaultResourceTypeMeta.ExtensionPointBuilder<P> withAuditDelegate(ResourceAuditDelegate auditDelegate) Sets an audit delegate for this resource type.This is optional.
-
withDefaultProfile
Supplies the default values for this extension point's profile configuration. Note that each extension point type should also provide a default settings object.- See Also:
-
build
-