Class AppDef<APP extends OpenemsApp,PROPERTY extends Nameable,PARAMETER>
- Type Parameters:
APP
- the type of the appPROPERTY
- the type of the propertyPARAMETER
- the type of the paramters
- All Implemented Interfaces:
OnlyIf<AppDef<APP,
,PROPERTY, PARAMETER>> Self<AppDef<APP,
PROPERTY, PARAMETER>>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
Functional interface with field values and a extra parameter.static interface
Functional interface with field values and a extra parameter and and return value.static interface
static interface
Functional interface function with field values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExecutes the givenConsumer
with the current instance.appendIsAllowedToEdit
(AppDef.FieldValuesBiPredicate<? super APP, ? super PROPERTY, ? super PARAMETER, ? super User>... isAllowedToEditPredicates) Appends the given predicates and collections them into one which checks that every predicate returns true to determine if the current field can be edited.appendIsAllowedToSee
(AppDef.FieldValuesBiPredicate<? super APP, ? super PROPERTY, ? super PARAMETER, ? super User>... isAllowedToSeePredicate) Appends the given predicates and collections them into one which checks that every predicate returns true to determine if the current field should be show.bidirectional
(PROPERTY propOfComponentId, String property, Function<? super APP, ComponentManager> componentManagerFunction) Binds a property bidirectional.bidirectional
(PROPERTY propOfComponentId, String property, Function<? super APP, ComponentManager> componentManagerFunction, Function<? super com.google.gson.JsonElement, com.google.gson.JsonElement> mapper) Binds a property bidirectional.static final <APP extends OpenemsApp,
PROPERTY extends Nameable, PARAMETER>
AppDef<APP,PROPERTY, PARAMETER> componentId
(String componentId) Creates aAppDef
with the componentId as the default value.static final <APP extends AbstractOpenemsAppWithProps<APP,
PROPERTY, PARAMETER> & OpenemsApp, PROPERTY extends Nameable & Type<PROPERTY, APP, PARAMETER>, PARAMETER extends Type.Parameter.BundleParameter>
AppDef<APP,PROPERTY, PARAMETER> copyOf
(Class<PROPERTY> propertyClass, AppDef<OpenemsApp, Nameable, Type.Parameter.BundleParameter> otherDef) Creates a copy of the otherDef.static final <APP extends APPO,
PROPERTY extends PROPERTYO, PARAMETER extends PARAMETERO, APPO extends OpenemsApp, PROPERTYO extends Nameable, PARAMETERO>
AppDef<APP,PROPERTY, PARAMETER> copyOfGeneric
(AppDef<APPO, PROPERTYO, PARAMETERO> otherDef) Creates a copy of the otherDef.static final <APP extends APPO,
PROPERTY extends PROPERTYO, PARAMETER extends PARAMETERO, APPO extends OpenemsApp, PROPERTYO extends Nameable, PARAMETERO>
AppDef<APP,PROPERTY, PARAMETER> copyOfGeneric
(AppDef<APPO, PROPERTYO, PARAMETERO> otherDef, Consumer<AppDef<APP, PROPERTY, PARAMETER>> consumer) Creates a copy of the otherDef.static final <APP extends OpenemsApp,
PROPERTY extends Nameable & Type<? extends PROPERTY, ? extends APP, ? extends PARAMETER>, PARAMETER extends Type.Parameter>
AppDef<APP,PROPERTY, PARAMETER> Creates aAppDef
of a subclass of anOpenemsApp
.AppDef.FieldValuesFunction<? super APP,
? super PROPERTY, ? super PARAMETER, com.google.gson.JsonObject, com.google.gson.JsonElement> Gets the function to get the bidirectional value.final AppDef.FieldValuesSupplier<? super APP,
? super PROPERTY, ? super PARAMETER, com.google.gson.JsonElement> Gets the function to get the label.AppDef.FieldValuesSupplier<? super APP,
? super PROPERTY, ? super PARAMETER, String> Gets the function to get the description.final AppDef.FieldValuesSupplier<? super APP,
? super PROPERTY, ? super PARAMETER, FormlyBuilder<?>> getField()
Gets the function to get theFormlyBuilder
.AppDef.FieldValuesBiPredicate<? super APP,
? super PROPERTY, ? super PARAMETER, ? super User> AppDef.FieldValuesBiPredicate<? super APP,
? super PROPERTY, ? super PARAMETER, ? super User> AppDef.FieldValuesSupplier<? super APP,
? super PROPERTY, ? super PARAMETER, String> getLabel()
Gets the function to get the label.boolean
Gets if the property is allowed to be saved.static Function<? super com.google.gson.JsonElement,
com.google.gson.JsonElement> multiplyWith
(double multiplicator) Creates a simple mapper if the inputJsonElement
is a number it gets multiplied with the given multiplicator.static final <APP extends OpenemsApp,
PROPERTY extends Nameable, PARAMETER>
AppDef<APP,PROPERTY, PARAMETER> of()
Creates aAppDef
of a subclass of anAbstractOpenemsAppWithProps
.static final <APP extends AbstractOpenemsAppWithProps<APP,
PROPERTY, PARAMETER>, PROPERTY extends Type<PROPERTY, APP, PARAMETER> & Nameable, PARAMETER extends Type.Parameter.BundleProvider>
AppDef<APP,PROPERTY, PARAMETER> Creates aAppDef
of a subclass of anAbstractOpenemsAppWithProps
.static AppDef.FieldValuesBiPredicate<? super Object,
? super Object, ? super Object, User> ofLeastRole
(Role role) Creates aAppDef.FieldValuesBiPredicate
to check if theRole
of the user is at least the givenRole
.self()
Gets itself.setAllowedToSave
(boolean isAllowedToSave) Sets if the property is allowed to be saved.setAutoGenerateField
(boolean autoGenerateField) setDefaultValue
(AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, com.google.gson.JsonElement> defaultValue) Sets the function as the defaultValue.Wraps theBoolean
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.Wraps theCharacter
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.setDefaultValue
(Enum<?> e) Wraps the name of theEnum
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.Wraps theNumber
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.Wraps theString
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.setDefaultValueBoolean
(AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, Boolean> defaultValue) Sets the function as the defaultValue.setDefaultValueCharacter
(AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, Character> defaultValue) Sets the function as the defaultValue.setDefaultValueNumber
(AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, Number> defaultValue) Sets the function as the defaultValue.setDefaultValueString
(AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, String> defaultValue) Sets the function as the defaultValue.Sets a function as the default value which returns the result ofOpenemsApp.getName(Language)
.setDescription
(AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, String> description) Sets the function as the description.final <T extends FormlyBuilder<?>>
AppDef<APP,PROPERTY, PARAMETER> Sets the field of the input.final <T extends FormlyBuilder<?>>
AppDef<APP,PROPERTY, PARAMETER> setField
(Function<PROPERTY, T> fieldSupplier, AppDef.FieldValuesConsumer<APP, PROPERTY, PARAMETER, T> additionalSettings) Sets the field of the input.setFieldFunction
(AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, FormlyBuilder<?>> field) setIsAllowedToSee
(AppDef.FieldValuesBiPredicate<? super APP, ? super PROPERTY, ? super PARAMETER, User> isAllowedToSee) Sets the function as the label.Sets the given string label as the return of the function label.Sets the value of the translation as the description.setTranslatedDescriptionWithAppPrefix
(String key, Object... params) Sets the value of the translation with theOpenemsApp.getAppId()
as prefixed as the description.setTranslatedLabel
(String key, Object... params) Sets the value of the translation as the label.setTranslatedLabelWithAppPrefix
(String key, Object... params) Sets the value of the translation with theOpenemsApp.getAppId()
as prefixed as the label.setTranslationBundleSupplier
(Function<PARAMETER, ResourceBundle> bundleSupplier) wrapField
(AppDef.FieldValuesConsumer<? super APP, ? super PROPERTY, ? super PARAMETER, FormlyBuilder<?>> wrapper) Wraps the existing field.
-
Constructor Details
-
AppDef
public AppDef()
-
-
Method Details
-
componentId
public static final <APP extends OpenemsApp,PROPERTY extends Nameable, AppDef<APP,PARAMETER> PROPERTY, componentIdPARAMETER> (String componentId) Creates aAppDef
with the componentId as the default value.- Type Parameters:
APP
- the type of theOpenemsApp
PROPERTY
- the type of theNameable
PARAMETER
- the type of theType.Parameter
- Parameters:
componentId
- the id of the component- Returns:
- the
AppDef
-
of
public static final <APP extends OpenemsApp,PROPERTY extends Nameable, AppDef<APP,PARAMETER> PROPERTY, of()PARAMETER> Creates aAppDef
of a subclass of anAbstractOpenemsAppWithProps
.- Type Parameters:
APP
- the type of the appPROPERTY
- the type of the propertyPARAMETER
- the type of the parameter- Returns:
- the
AppDef
-
of
public static final <APP extends AbstractOpenemsAppWithProps<APP,PROPERTY, AppDef<APP,PARAMETER>, PROPERTY extends Type<PROPERTY, APP, PARAMETER> & Nameable, PARAMETER extends Type.Parameter.BundleProvider> PROPERTY, ofPARAMETER> (Class<APP> clazz) Creates aAppDef
of a subclass of anAbstractOpenemsAppWithProps
.- Type Parameters:
APP
- the type of the appPROPERTY
- the type of the propertyPARAMETER
- the type of the parameter- Parameters:
clazz
- theClass
of theAbstractOpenemsAppWithProps
- Returns:
- the
AppDef
-
genericOf
public static final <APP extends OpenemsApp,PROPERTY extends Nameable & Type<? extends PROPERTY, AppDef<APP,? extends APP, ? extends PARAMETER>, PARAMETER extends Type.Parameter> PROPERTY, genericOfPARAMETER> (Class<PROPERTY> propertyClass) Creates aAppDef
of a subclass of anOpenemsApp
. -
copyOf
public static final <APP extends AbstractOpenemsAppWithProps<APP,PROPERTY, AppDef<APP,PARAMETER> & OpenemsApp, PROPERTY extends Nameable & Type<PROPERTY, APP, PARAMETER>, PARAMETER extends Type.Parameter.BundleParameter> PROPERTY, copyOfPARAMETER> (Class<PROPERTY> propertyClass, AppDef<OpenemsApp, Nameable, Type.Parameter.BundleParameter> otherDef) Creates a copy of the otherDef. -
copyOfGeneric
public static final <APP extends APPO,PROPERTY extends PROPERTYO, AppDef<APP,PARAMETER extends PARAMETERO, APPO extends OpenemsApp, PROPERTYO extends Nameable, PARAMETERO> PROPERTY, copyOfGenericPARAMETER> (AppDef<APPO, PROPERTYO, PARAMETERO> otherDef, Consumer<AppDef<APP, PROPERTY, PARAMETER>> consumer) Creates a copy of the otherDef. This method is often used instead of thecopyOfGeneric(AppDef)
because the return type doesn't have to be set explicit if a method call is appended to the result of the method.- Type Parameters:
APP
- the type of the appPROPERTY
- the type of the propertyPARAMETER
- the type of the parameterAPPO
- the type of the app from the otherDefPROPERTYO
- the type of the property from the otherDefPARAMETERO
- the type of the parameter from the otherDef- Parameters:
otherDef
- the otherAppDef
consumer
- theConsumer
to set attributes of theAppDef
- Returns:
- the new
AppDef
-
copyOfGeneric
public static final <APP extends APPO,PROPERTY extends PROPERTYO, AppDef<APP,PARAMETER extends PARAMETERO, APPO extends OpenemsApp, PROPERTYO extends Nameable, PARAMETERO> PROPERTY, copyOfGenericPARAMETER> (AppDef<APPO, PROPERTYO, PARAMETERO> otherDef) Creates a copy of the otherDef.- Type Parameters:
APP
- the type of the appPROPERTY
- the type of the propertyPARAMETER
- the type of the parameterAPPO
- the type of the app from the otherDefPROPERTYO
- the type of the property from the otherDefPARAMETERO
- the type of the parameter from the otherDef- Parameters:
otherDef
- the otherAppDef
- Returns:
- the new
AppDef
-
setAllowedToSave
Sets if the property is allowed to be saved. May be used for passwords and apiKeys.DefaultValue:
Boolean.TRUE
- Parameters:
isAllowedToSave
- if the property is allowed to be saved- Returns:
- this
-
setTranslationBundleSupplier
-
isAllowedToSave
public boolean isAllowedToSave()Gets if the property is allowed to be saved.- Returns:
- if the property is allowed to be saved
-
setLabel
public final AppDef<APP,PROPERTY, setLabelPARAMETER> (AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, String> label) Sets the function as the label.- Parameters:
label
- the function to get the label- Returns:
- this
-
setLabel
Sets the given string label as the return of the function label.- Parameters:
label
- the label to set- Returns:
- this
-
setTranslatedLabel
Sets the value of the translation as the label.Note: If this method is used
Type.translationBundleSupplier()
must be overridden and return a non null value.- Parameters:
key
- the key of the translationparams
- the parameter of the translation- Returns:
- this
-
setTranslatedLabelWithAppPrefix
public final AppDef<APP,PROPERTY, setTranslatedLabelWithAppPrefixPARAMETER> (String key, Object... params) Sets the value of the translation with theOpenemsApp.getAppId()
as prefixed as the label.Note: If this method is used
Type.translationBundleSupplier()
must be overridden and return a non null value.- Parameters:
key
- the key of the translationparams
- the parameter of the translation- Returns:
- this
-
setDescription
public final AppDef<APP,PROPERTY, setDescriptionPARAMETER> (AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, String> description) Sets the function as the description.- Parameters:
description
- the function to get the description- Returns:
- this
-
setTranslatedDescription
Sets the value of the translation as the description.Note: If this method is used
Type.translationBundleSupplier()
must be overridden and return a non null value.- Parameters:
key
- the key of the translation- Returns:
- this
-
setTranslatedDescriptionWithAppPrefix
public final AppDef<APP,PROPERTY, setTranslatedDescriptionWithAppPrefixPARAMETER> (String key, Object... params) Sets the value of the translation with theOpenemsApp.getAppId()
as prefixed as the description.Note: If this method is used
Type.translationBundleSupplier()
must be overridden and return a non null value.- Parameters:
key
- the key of the translationparams
- the parameter of the translation- Returns:
- this
-
setDefaultValue
public final AppDef<APP,PROPERTY, setDefaultValuePARAMETER> (AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, com.google.gson.JsonElement> defaultValue) Sets the function as the defaultValue.- Parameters:
defaultValue
- the function to get the defaultValue- Returns:
- this
-
setDefaultValue
Wraps theString
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.- Parameters:
s
- theString
as the default value- Returns:
- this
-
setDefaultValue
Wraps the name of theEnum
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.- Parameters:
e
- theEnum
as the default value- Returns:
- this
-
setDefaultValue
Wraps theBoolean
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.- Parameters:
b
- theBoolean
as the default value- Returns:
- this
-
setDefaultValue
Wraps theNumber
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.- Parameters:
n
- theNumber
as the default value- Returns:
- this
-
setDefaultValue
Wraps theCharacter
in aJsonPrimitive
and sets it as the default value withAppDef#setDefaultValue(Function)
.- Parameters:
c
- theCharacter
as the default value- Returns:
- this
-
setDefaultValueString
public final AppDef<APP,PROPERTY, setDefaultValueStringPARAMETER> (AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, String> defaultValue) Sets the function as the defaultValue.- Parameters:
defaultValue
- the function to get the defaultValue- Returns:
- this
-
setDefaultValueNumber
public final AppDef<APP,PROPERTY, setDefaultValueNumberPARAMETER> (AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, Number> defaultValue) Sets the function as the defaultValue.- Parameters:
defaultValue
- the function to get the defaultValue- Returns:
- this
-
setDefaultValueBoolean
public final AppDef<APP,PROPERTY, setDefaultValueBooleanPARAMETER> (AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, Boolean> defaultValue) Sets the function as the defaultValue.- Parameters:
defaultValue
- the function to get the defaultValue- Returns:
- this
-
setDefaultValueCharacter
public final AppDef<APP,PROPERTY, setDefaultValueCharacterPARAMETER> (AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, Character> defaultValue) Sets the function as the defaultValue.- Parameters:
defaultValue
- the function to get the defaultValue- Returns:
- this
-
setDefaultValueToAppName
Sets a function as the default value which returns the result ofOpenemsApp.getName(Language)
.- Returns:
- this
-
setFieldFunction
public AppDef<APP,PROPERTY, setFieldFunctionPARAMETER> (AppDef.FieldValuesSupplier<? super APP, ? super PROPERTY, ? super PARAMETER, FormlyBuilder<?>> field) -
setField
public final <T extends FormlyBuilder<?>> AppDef<APP,PROPERTY, setFieldPARAMETER> (Function<PROPERTY, T> fieldSupplier, AppDef.FieldValuesConsumer<APP, PROPERTY, PARAMETER, T> additionalSettings) Sets the field of the input.- Type Parameters:
T
- the type of the input- Parameters:
fieldSupplier
- the supplier to get theFormlyBuilder
additionalSettings
- the additional settings on the input- Returns:
- this
-
setField
public final <T extends FormlyBuilder<?>> AppDef<APP,PROPERTY, setFieldPARAMETER> (Function<PROPERTY, T> fieldSupplier) Sets the field of the input.- Type Parameters:
T
- the type of the input- Parameters:
fieldSupplier
- the supplier to get theFormlyBuilder
- Returns:
- this
-
setAutoGenerateField
-
setIsAllowedToSee
-
appendIsAllowedToSee
@SafeVarargs public final AppDef<APP,PROPERTY, appendIsAllowedToSeePARAMETER> (AppDef.FieldValuesBiPredicate<? super APP, ? super PROPERTY, ? super PARAMETER, ? super User>... isAllowedToSeePredicate) Appends the given predicates and collections them into one which checks that every predicate returns true to determine if the current field should be show.- Parameters:
isAllowedToSeePredicate
- theAppDef.FieldValuesBiPredicate
- Returns:
- this
-
appendIsAllowedToEdit
@SafeVarargs public final AppDef<APP,PROPERTY, appendIsAllowedToEditPARAMETER> (AppDef.FieldValuesBiPredicate<? super APP, ? super PROPERTY, ? super PARAMETER, ? super User>... isAllowedToEditPredicates) Appends the given predicates and collections them into one which checks that every predicate returns true to determine if the current field can be edited.- Parameters:
isAllowedToEditPredicates
- theAppDef.FieldValuesBiPredicate
- Returns:
- this
-
getIsAllowedToEdit
public AppDef.FieldValuesBiPredicate<? super APP,? super PROPERTY, getIsAllowedToEdit()? super PARAMETER, ? super User> -
getIsAllowedToSee
public AppDef.FieldValuesBiPredicate<? super APP,? super PROPERTY, getIsAllowedToSee()? super PARAMETER, ? super User> -
wrapField
public final AppDef<APP,PROPERTY, wrapFieldPARAMETER> (AppDef.FieldValuesConsumer<? super APP, ? super PROPERTY, ? super PARAMETER, FormlyBuilder<?>> wrapper) Wraps the existing field. If the existing field is not set the wrapper will not be executed.- Parameters:
wrapper
- the wrapper of the current field- Returns:
- this
-
getLabel
Gets the function to get the label.- Returns:
- the function
-
getDescription
public AppDef.FieldValuesSupplier<? super APP,? super PROPERTY, getDescription()? super PARAMETER, String> Gets the function to get the description.- Returns:
- the function
-
getDefaultValue
public final AppDef.FieldValuesSupplier<? super APP,? super PROPERTY, getDefaultValue()? super PARAMETER, com.google.gson.JsonElement> Gets the function to get the label.- Returns:
- the function
-
getField
public final AppDef.FieldValuesSupplier<? super APP,? super PROPERTY, getField()? super PARAMETER, FormlyBuilder<?>> Gets the function to get theFormlyBuilder
.- Returns:
- the function
-
getBidirectionalValue
public AppDef.FieldValuesFunction<? super APP,? super PROPERTY, getBidirectionalValue()? super PARAMETER, com.google.gson.JsonObject, com.google.gson.JsonElement> Gets the function to get the bidirectional value.This value may be obtained from a component
- Returns:
- the function to get the value
-
self
Description copied from interface:Self
Gets itself.- Specified by:
self
in interfaceSelf<APP extends OpenemsApp>
- Returns:
- this
-
also
Executes the givenConsumer
with the current instance.- Parameters:
consumer
- theConsumer
to be executed with this instance- Returns:
- this
-
bidirectional
public AppDef<APP,PROPERTY, bidirectionalPARAMETER> (PROPERTY propOfComponentId, String property, Function<? super APP, ComponentManager> componentManagerFunction) Binds a property bidirectional.The property itself will not be stored in the app configuration only in the component. If the user doesn't provide the value of a property and there is a bidirectional binding for it it will be filled up with the value of the bidirectional binding. If there is no component id in the configuration or the component doesn't exist or the property of the value is null then null is returned inside the bidirectional function.
- Parameters:
propOfComponentId
- the key to get the component id from a configurationproperty
- the property of the componentcomponentManagerFunction
- the function to get the component manager- Returns:
- this
-
bidirectional
public AppDef<APP,PROPERTY, bidirectionalPARAMETER> (PROPERTY propOfComponentId, String property, Function<? super APP, ComponentManager> componentManagerFunction, Function<? super com.google.gson.JsonElement, com.google.gson.JsonElement> mapper) Binds a property bidirectional.The property itself will not be stored in the app configuration only in the component. If the user doesn't provide the value of a property and there is a bidirectional binding for it it will be filled up with the value of the bidirectional binding. If there is no component id in the configuration or the component doesn't exist or the property of the value is null then null is returned inside the bidirectional function.
- Parameters:
propOfComponentId
- the key to get the component id from a configurationproperty
- the property of the componentcomponentManagerFunction
- the function to get the component managermapper
- the mapperFunction
from the component to the actual value- Returns:
- this
-
multiplyWith
public static Function<? super com.google.gson.JsonElement,com.google.gson.JsonElement> multiplyWith(double multiplicator) Creates a simple mapper if the inputJsonElement
is a number it gets multiplied with the given multiplicator.- Parameters:
multiplicator
- the multiplicator to be applied to theJsonElement
- Returns:
- the converter
Function
-
ofLeastRole
public static AppDef.FieldValuesBiPredicate<? super Object,? super Object, ofLeastRole? super Object, User> (Role role) Creates aAppDef.FieldValuesBiPredicate
to check if theRole
of the user is at least the givenRole
.- Parameters:
role
- the compared Role- Returns:
- the
AppDef.FieldValuesBiPredicate
-