Package io.microsphere.metadata
Class ReflectiveConfigurationPropertyGenerator
- java.lang.Object
-
- io.microsphere.metadata.ReflectiveConfigurationPropertyGenerator
-
- All Implemented Interfaces:
Prioritized
,ConfigurationPropertyGenerator
,java.lang.Comparable<Prioritized>
public class ReflectiveConfigurationPropertyGenerator extends java.lang.Object implements ConfigurationPropertyGenerator
ConfigurationPropertyGenerator
class based on Java Reflection APIExample Usage
ConfigurationProperty property = new ConfigurationProperty("server.port", Integer.class); property.setValue(8080); property.setDefaultValue(8080); property.setRequired(true); property.setDescription("The port number for the server"); ConfigurationProperty.Metadata metadata = property.getMetadata(); metadata.getSources().add("application.properties"); metadata.getTargets().add("server"); metadata.setDeclaredClass("com.example.ServerConfig"); metadata.setDeclaredField("port");
The JSON representation of the above ConfigurationProperty object would be:
{ "name": "server.port", "type": "java.lang.Integer", "value": 8080, "defaultValue": 8080, "required": true, "description": "The port number for the server", "metadata": { "sources": [ "application.properties" ], "targets": [ "server" ], "declaredClass": "com.example.ServerConfig", "declaredField": "port" } }
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ConfigurationPropertyGenerator
,JSONObject
,BeanUtils.resolvePropertiesAsMap(Object)
-
-
Field Summary
-
Fields inherited from interface io.microsphere.lang.Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description ReflectiveConfigurationPropertyGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
generate(ConfigurationProperty configurationProperty)
Generates a content of the givenConfigurationProperty
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.microsphere.lang.Prioritized
compareTo, getPriority
-
-
-
-
Method Detail
-
generate
public java.lang.String generate(ConfigurationProperty configurationProperty) throws java.lang.IllegalArgumentException
Description copied from interface:ConfigurationPropertyGenerator
Generates a content of the givenConfigurationProperty
.- Specified by:
generate
in interfaceConfigurationPropertyGenerator
- Parameters:
configurationProperty
- the configuration property to be the some content.- Returns:
- a JSON string representation of the configuration property.
- Throws:
java.lang.IllegalArgumentException
- if the configurationProperty is null.
-
-