Class PropertySpecImpl
- All Implemented Interfaces:
PropertySpec
PropertySpec
.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: PropertySpecImpl.java 1053 2023-03-11 00:10:49Z tquadrat $
- Since:
- 0.1.0
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.ap.impl.PropertySpecImpl"
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.tquadrat.foundation.config.ap.PropertySpec
PropertySpec.PropertyFlag
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Name
The name for the 'add' method's argument.private MethodSpec.Builder
The builder for the 'add' method of this property.private BiFunction
<CodeBuilder, PropertySpecImpl, MethodSpec> The method that creates the 'add' method for this property.private Name
The name for the 'add'' method.private int
The argument index.private String
The special CLI format.private String
The CLI meta variable.The names for a CLI option.private String
The CLI usage text.private String
The CLI usage key.private TypeName
The CLI value handler class.private CollectionKind
The kind of collection for this property.private BiFunction
<CodeBuilder, PropertySpecImpl, CodeBlock> The method that creates the constructor fragment for the initialisation of this property.private String
The default value for environment variables or system properties.private String
The name of the environment variable that is used to initialise this property.private BiFunction
<CodeBuilder, PropertySpecImpl, FieldSpec> The method that creates the field for this property.private String
The name of the field for the property.private MethodSpec.Builder
The builder for the getter of this property.private BiFunction
<CodeBuilder, PropertySpecImpl, MethodSpec> The method that creates the getter for this property.private Name
The name for the getter method.private TypeName
The return type for the getter method.private String
The comment for this property when stored in anINI
file.private String
The group for this property when stored in anINI
file.private String
The key for this property when stored in anINI
file.private boolean
The flag that indicates whether the property type is anenum
type.private TypeName
ThePreferences
accessor class.private String
ThePreferences
key.private final EnumSet
<PropertySpec.PropertyFlag> The property flags.private final String
The name of the property.private TypeName
The type of the property.private Name
The name for the setter's argument.private MethodSpec.Builder
The builder for the setter of this property.private BiFunction
<CodeBuilder, PropertySpecImpl, MethodSpec> The method that creates the setter for this property.private Name
The name for the setter method.private SpecialPropertyType
The speciality type for this property; usually, this isnull
.private TypeName
The class that implements the String converter for the type of this property.private String
The path for the SYSTEM preferences node that holds the initialisation data for this property.private String
The name of the system property that is used to initialise this property. -
Constructor Summary
ConstructorsConstructorDescriptionPropertySpecImpl
(String propertyName) Creates a newPropertySpecImpl
instance. -
Method Summary
Modifier and TypeMethodDescriptionfinal Optional
<MethodSpec> createAddMethod
(CodeBuilder codeBuilder) Creates the specification of the 'add' method for this property.createConstructorFragment
(CodeBuilder codeBuilder) Creates a code block that is a fragment for the constructor of the new configuration bean and that initialises this property.createField
(CodeBuilder codeBuilder) Creates the field specification for this property.createGetter
(CodeBuilder codeBuilder) Creates the specification of the getter for this property.createSetter
(CodeBuilder codeBuilder) Creates the specification of the setter for this property.final Name
Returns the name of the 'add' method's argument.final Optional
<MethodSpec.Builder> Returns a builder for the 'add' method for this property.Returns the name of the 'add' method for this property.final OptionalInt
Returns the index for an argument on the command line.Returns the special CLI format.Returns the name of the CLI meta variable for this property.Returns the CLI option names.Returns the CLI usage text for this property.Returns the CLI usage key for this property.Returns the CLI value handler class for this property.final CollectionKind
Returns the kind of collection for this property.Returns the default value for an environment variable or a system property.Returns the name of the environment variable that is used to initialise this property.final String
Returns the name of the field for the property.final Optional
<MethodSpec.Builder> Returns a builder for the getter for this property.Returns the name of the getter method name.final TypeName
Returns the return type of the getter.Returns the comment for this property in theINI
file.Returns the group for this property in theINI
file.Returns the key for this property in theINI
file.Returns thePreferences
accessor class.Returns thePreferences
key for this property.final String
Returns the name of the configuration property.final TypeName
Returns the property type.final Name
Returns the name of the setter's argument.final Optional
<MethodSpec.Builder> Returns a builder for the setter for this property.Returns the name of the setter method name.final Optional
<SpecialPropertyType> Return the 'speciality' type for this property.Returns the class that implements the String converter for the type of this property.Returns the path to the SYSTEMPreferences
node that holds the data for the initialisation of this property.Returns the name of the system property that is used to initialise this property.final boolean
Checks whether the given flag is set for this property.final boolean
isEnum()
Returns the flag that indicates whether the property is anenum
type.final PropertySpec
merge()
'Merges' the attributes from a special property with the attributes retrieved from the configuration bean specification and returns a new instance ofPropertySpec
.final void
setAddMethodArgumentName
(Name name) Sets the name for the 'add' method's argument.final void
setAddMethodBuilder
(MethodSpec.Builder builder) Sets the builder for the 'add' method of this property.final void
setAddMethodName
(Name name) Sets the name of the 'add'' method for this property.final void
setCLIArgumentIndex
(int index) Sets the index for an argument on the command line.final void
setCLIFormat
(String format) Sets the special CLI format.final void
setCLIMetaVar
(String metaVar) Sets the CLI meta variable.final void
setCLIOptionNames
(List<String> names) Sets the CLI option names.final void
setCLIUsage
(String text) Sets the CLI usage text.final void
setCLIUsageKey
(String key) Sets the CLI usage key.final void
setCLIValueHandlerClass
(TypeName handlerClass) Sets the CLI value handler class.final void
setCollectionKind
(CollectionKind collectionKind) Sets the kind of collection for this property.final void
setEnvironmentDefaultValue
(String value) Sets the default value for an environment variable or a system property.final void
Sets the name of the environment variable that provides the (initial) value for this property.final void
setFieldName
(String name) Sets the name of the field for the property.final void
setFlag
(PropertySpec.PropertyFlag... flag) Sets the given flags to the property.final void
setGetterBuilder
(MethodSpec.Builder builder) Sets the builder for the getter of this property.final void
setGetterMethodName
(Name name) Sets the method name for the getter.final void
setGetterReturnType
(TypeName type) Sets the return type for the getter.final void
setINIConfiguration
(String group, String key, String comment) Sets theINI
file configuration for this property.void
setINIConfiguration
(INIValue configuration) Sets theINI
file configuration for this property.final void
setIsEnum
(boolean flag) Sets the flag that indicates whether the property is anenum
type.final void
setPrefsAccessorClass
(TypeName accessorClass) Sets the preferences accessor class for this property.final void
setPrefsKey
(String preferenceKey) Sets the preferences key for this property.final void
setPropertyType
(TypeName type) Sets the property type.final void
setSetterArgumentName
(Name name) Sets the name for the setter's argument.final void
setSetterBuilder
(MethodSpec.Builder builder) Sets the builder for the setter of this property.void
setSetterMethodName
(Name name) Sets the name of the setter method for this property.final void
Sets the speciality type for this property.final void
setStringConverterClass
(TypeName typeName) Sets the name for the class that implementsStringConverter
for the type of this property.final void
setSystemPrefsPath
(String path) Sets the path for the SYSTEMPreferences
node that holds the initialisation data for this property.final void
setSystemPropertyName
(String name) Sets the name of the system property that provides the (initial) value for this property.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.tquadrat.foundation.config.ap.PropertySpec
getElementType, isCollection, isOnCLI
-
Field Details
-
m_AddMethodArgumentName
The name for the 'add' method's argument. -
m_AddMethodBuilder
The builder for the 'add' method of this property. -
m_AddMethodComposer
The method that creates the 'add' method for this property. -
m_AddMethodName
The name for the 'add'' method. -
m_CLIArgumentIndex
The argument index.- See Also:
-
m_CLIFormat
The special CLI format.- See Also:
-
m_CLIMetaVar
The CLI meta variable.- See Also:
-
m_CLIOptionNames
The names for a CLI option.- See Also:
-
m_CLIValueHandlerClass
The CLI value handler class.- See Also:
-
m_CLIUsage
The CLI usage text.- See Also:
-
m_CLIUsageKey
The CLI usage key.- See Also:
-
m_CollectionKind
The kind of collection for this property. -
m_ConstructorFragmentComposer
The method that creates the constructor fragment for the initialisation of this property. -
m_EnvironmentDefaultValue
The default value for environment variables or system properties. -
m_EnvironmentVariableName
The name of the environment variable that is used to initialise this property. -
m_FieldComposer
The method that creates the field for this property. -
m_FieldName
The name of the field for the property. -
m_GetterBuilder
The builder for the getter of this property. -
m_GetterComposer
The method that creates the getter for this property. -
m_GetterMethodName
The name for the getter method. -
m_GetterReturnType
The return type for the getter method. -
m_INIComment
The comment for this property when stored in anINI
file. -
m_INIGroup
The group for this property when stored in anINI
file. -
m_INIKey
The key for this property when stored in anINI
file. -
m_IsEnum
The flag that indicates whether the property type is anenum
type. -
m_PrefsAccessorClass
The
Preferences
accessor class.This is used when this property is linked to a preference, but also to initialise it from a SYSTEM preference.
- See Also:
-
m_PrefsKey
The
Preferences
key.This is used when this property is linked to a preference, but also to initialise it from a SYSTEM preference. In first case, the name is defaulted to the property name, while it is mandatory otherwise.
- See Also:
-
m_PropertyFlags
The property flags. -
m_PropertyName
The name of the property. -
m_PropertyType
The type of the property. -
m_SetterArgumentName
The name for the setter's argument. -
m_SetterBuilder
The builder for the setter of this property. -
m_SetterComposer
The method that creates the setter for this property. -
m_SetterMethodName
The name for the setter method. -
m_SpecialPropertyType
The speciality type for this property; usually, this isnull
. -
m_StringConverterClass
The class that implements the String converter for the type of this property. -
m_SystemPrefsPath
The path for the SYSTEM preferences node that holds the initialisation data for this property.- See Also:
-
m_SystemPropertyName
The name of the system property that is used to initialise this property.
-
-
Constructor Details
-
PropertySpecImpl
Creates a newPropertySpecImpl
instance.- Parameters:
propertyName
- The name of the property.
-
-
Method Details
-
createAddMethod
Creates the specification of the 'add' method for this property.- Specified by:
createAddMethod
in interfacePropertySpec
- Parameters:
codeBuilder
- The factory for the code generation.- Returns:
- An instance of
Optional
that holds the method specification.
-
createConstructorFragment
Creates a code block that is a fragment for the constructor of the new configuration bean and that initialises this property.- Specified by:
createConstructorFragment
in interfacePropertySpec
- Parameters:
codeBuilder
- The factory for the code generation.- Returns:
- An instance of
Optional
that holds the code block.
-
createField
Creates the field specification for this property.- Specified by:
createField
in interfacePropertySpec
- Parameters:
codeBuilder
- The factory for the code generation.- Returns:
- An instance of
Optional
that holds the field specification.
-
createGetter
Creates the specification of the getter for this property.- Specified by:
createGetter
in interfacePropertySpec
- Parameters:
codeBuilder
- The factory for the code generation.- Returns:
- An instance of
Optional
that holds the method specification.
-
createSetter
Creates the specification of the setter for this property.- Specified by:
createSetter
in interfacePropertySpec
- Parameters:
codeBuilder
- The factory for the code generation.- Returns:
- An instance of
Optional
that holds the method specification.
-
getAddMethodArgumentName
Returns the name of the 'add' method's argument.- Specified by:
getAddMethodArgumentName
in interfacePropertySpec
- Returns:
- The argument name; is probable
null
whenPropertySpec.getAddMethodName()
returnsOptional.empty()
.
-
getAddMethodBuilder
Returns a builder for the 'add' method for this property.
This is a convenience method that allows to benefit from
JavaComposer.createMethod(ExecutableElement)
.- Returns:
- An instance of
Optional
that holds the builder.
-
getAddMethodName
Returns the name of the 'add' method for this property.- Specified by:
getAddMethodName
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the name of the add method.
-
getCLIArgumentIndex
Returns the index for an argument on the command line.
The return value will be empty if the property is not a CLI argument.
- Specified by:
getCLIArgumentIndex
in interfacePropertySpec
- Returns:
- An instance of
OptionalInt
that holds the index. - See Also:
-
getCLIFormat
Returns the special CLI format.- Specified by:
getCLIFormat
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the format. - See Also:
-
getCLIMetaVar
Returns the name of the CLI meta variable for this property.- Specified by:
getCLIMetaVar
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the name of the meta variable. - See Also:
-
getCLIOptionNames
Returns the CLI option names. The mandatory first name in the list is the primary name, the optional others are the aliases.
The return value will be empty if the property is not a CLI option.
- Specified by:
getCLIOptionNames
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the option names. - See Also:
-
getCLIUsage
Returns the CLI usage text for this property. This text will not be localised.- Specified by:
getCLIUsage
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the usage text. - See Also:
-
getCLIUsageKey
Returns the CLI usage key for this property. This key is used to retrieve a localised usage text.- Specified by:
getCLIUsageKey
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the usage key. - See Also:
-
getCLIValueHandlerClass
Returns the CLI value handler class for this property.- Specified by:
getCLIValueHandlerClass
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds theTypeName
for the handler class. - See Also:
-
getCollectionKind
Returns the kind of collection for this property.- Specified by:
getCollectionKind
in interfacePropertySpec
- Returns:
- The collection kind.
-
getEnvironmentDefaultValue
Returns the default value for an environment variable or a system property. This is used to initialise this property when it has the annotation
@EnvironmentVariable
or@EnvironmentVariable
, but no value is provided.A default value is mandatory when the annotated property has a primitive type.
- Specified by:
getEnvironmentDefaultValue
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the default value.
-
getEnvironmentVariableName
Returns the name of the environment variable that is used to initialise this property.- Specified by:
getEnvironmentVariableName
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the environment variable name. - See Also:
-
getFieldName
Returns the name of the field for the property.- Specified by:
getFieldName
in interfacePropertySpec
- Returns:
- The field name.
-
getGetterBuilder
Returns a builder for the getter for this property.- Specified by:
getGetterBuilder
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the builder.
-
getGetterMethodName
Returns the name of the getter method name. If there is no name for the method, it will not be generated.- Specified by:
getGetterMethodName
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the name of the getter method.
-
getGetterReturnType
Returns the return type of the getter. This is not necessarily the same as the property type.- Specified by:
getGetterReturnType
in interfacePropertySpec
- Returns:
- The getter's return type.
-
getINIComment
Returns the comment for this property in theINI
file.- Specified by:
getINIComment
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the comment.
-
getINIGroup
Returns the group for this property in theINI
file.- Specified by:
getINIGroup
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the group name.
-
getINIKey
Returns the key for this property in theINI
file.- Specified by:
getINIKey
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the key.
-
getPrefsAccessorClass
Returns the
Preferences
accessor class.This is used when this property is linked to a preference, but also to initialise it from a SYSTEM preference.
- Specified by:
getPrefsAccessorClass
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds theTypeName
for the accessor class. - See Also:
-
getPrefsKey
Returns the
Preferences
key for this property.This is used when this property is linked to a preference, but also to initialise it from a SYSTEM preference. In first case, the name is defaulted to the property name, while it is mandatory otherwise.
- Specified by:
getPrefsKey
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the preferences key for this property. - See Also:
-
getPropertyName
Returns the name of the configuration property.- Specified by:
getPropertyName
in interfacePropertySpec
- Returns:
- The name.
-
getPropertyType
Returns the property type.- Specified by:
getPropertyType
in interfacePropertySpec
- Returns:
- The property type.
-
getSetterArgumentName
Returns the name of the setter's argument.- Specified by:
getSetterArgumentName
in interfacePropertySpec
- Returns:
- The argument name; is probably
null
whenPropertySpec.getSetterMethodName()
returnsOptional.empty()
.
-
getSetterBuilder
Returns a builder for the setter for this property.- Specified by:
getSetterBuilder
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the builder.
-
getSetterMethodName
Returns the name of the setter method name. If there is no name for the method, it will not be generated.- Specified by:
getSetterMethodName
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the name of the setter method.
-
getSpecialPropertyType
Return the 'speciality' type for this property.- Specified by:
getSpecialPropertyType
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the speciality type.
-
getStringConverterClass
Returns the class that implements the String converter for the type of this property.- Specified by:
getStringConverterClass
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the implementation class forStringConverter
.
-
getSystemPrefsPath
Returns the path to the SYSTEMPreferences
node that holds the data for the initialisation of this property.- Specified by:
getSystemPrefsPath
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the path. - See Also:
-
getSystemPropertyName
Returns the name of the system property that is used to initialise this property.- Specified by:
getSystemPropertyName
in interfacePropertySpec
- Returns:
- An instance of
Optional
that holds the system property name. - See Also:
-
isEnum
Returns the flag that indicates whether the property is anenum
type.- Specified by:
isEnum
in interfacePropertySpec
- Returns:
true
if the property type is anenum
,false
otherwise.
-
hasFlag
Checks whether the given flag is set for this property.- Specified by:
hasFlag
in interfacePropertySpec
- Parameters:
flag
- The flag to test for.- Returns:
true
if the flag is set,false
otherwise.
-
merge
'Merges' the attributes from a special property with the attributes retrieved from the configuration bean specification and returns a new instance of
PropertySpec
. The original instance remains unchanged.If the property is not a special property (the flag
PropertySpec.PropertyFlag.PROPERTY_IS_SPECIAL
is not set), this instance will be returned.- Specified by:
merge
in interfacePropertySpec
- Returns:
- The effective property specification.
-
setAddMethodArgumentName
Sets the name for the 'add' method's argument.- Parameters:
name
- The name of the argument.
-
setAddMethodBuilder
Sets the builder for the 'add' method of this property.- Parameters:
builder
- The builder; can benull
.
-
setAddMethodName
Sets the name of the 'add'' method for this property.- Parameters:
name
- The name of the setter method.
-
setCLIArgumentIndex
Sets the index for an argument on the command line.- Parameters:
index
- The index, starting by 0. A negative value indicates, that the value was not set.- See Also:
-
setCLIFormat
Sets the special CLI format.- Parameters:
format
- The format String; can benull
.- See Also:
-
setCLIMetaVar
Sets the CLI meta variable.- Parameters:
metaVar
- The meta variable; can benull
.- See Also:
-
setCLIOptionNames
Sets the CLI option names.
The first entry of the list is the option name, the others are the aliases.
- Parameters:
names
- The name and the aliases for the CLI option for this property; can benull
, but may not be empty.- See Also:
-
setCLIUsage
Sets the CLI usage text.- Parameters:
text
- The usage text; can benull
.- See Also:
-
setCLIUsageKey
Sets the CLI usage key.- Parameters:
key
- The usage key; can benull
.- See Also:
-
setCLIValueHandlerClass
Sets the CLI value handler class.- Parameters:
handlerClass
- TheTypeName
for the value handler class; can benull
.- See Also:
-
setCollectionKind
Sets the kind of collection for this property.- Parameters:
collectionKind
- The kind of collection.
-
setEnvironmentDefaultValue
Sets the default value for an environment variable or a system property. This is used to initialise this property when it has the annotation
@EnvironmentVariable
or@EnvironmentVariable
, but no value is provided.A default value is mandatory when the annotated property has a primitive type.
A String with the only the
NUL
character is treated asnull
.- Parameters:
value
- The default value.
-
setEnvironmentVariableName
Sets the name of the environment variable that provides the (initial) value for this property.- Parameters:
name
- The name of the environment variable.
-
setFieldName
Sets the name of the field for the property.- Parameters:
name
- The field name.
-
setFlag
Sets the given flags to the property.- Parameters:
flag
- The flags to set.
-
setGetterBuilder
Sets the builder for the getter of this property.- Parameters:
builder
- The builder; can benull
.
-
setGetterMethodName
Sets the method name for the getter.- Parameters:
name
- The method name.
-
setGetterReturnType
Sets the return type for the getter.- Parameters:
type
- The getter's return type.
-
setINIConfiguration
Sets theINI
file configuration for this property.- Parameters:
group
- The group.key
- The key.comment
- The comment; can benull
.
-
setINIConfiguration
Sets theINI
file configuration for this property.- Parameters:
configuration
- The configuration annotation.
-
setIsEnum
Sets the flag that indicates whether the property is anenum
type.- Parameters:
flag
-true
if the property type is anenum
type,false
otherwise.
-
setPrefsAccessorClass
Sets the preferences accessor class for this property.- Parameters:
accessorClass
- The accessor class; can benull
.
-
setPrefsKey
Sets the preferences key for this property.- Parameters:
preferenceKey
- The key.
-
setPropertyType
Sets the property type.- Parameters:
type
- The type of the property.
-
setSetterArgumentName
Sets the name for the setter's argument.- Parameters:
name
- The name of the argument.
-
setSetterBuilder
Sets the builder for the setter of this property.- Parameters:
builder
- The builder; can benull
.
-
setSetterMethodName
Sets the name of the setter method for this property.- Parameters:
name
- The name of the setter method.
-
setSpecialPropertyType
Sets the speciality type for this property.- Parameters:
type
- The speciality type.
-
setStringConverterClass
Sets the name for the class that implementsStringConverter
for the type of this property.- Parameters:
typeName
- The String converter class; can benull
.
-
setSystemPrefsPath
Sets the path for the SYSTEMPreferences
node that holds the initialisation data for this property.- Parameters:
path
- The path.
-
setSystemPropertyName
Sets the name of the system property that provides the (initial) value for this property.- Parameters:
name
- The name of the system property.
-