Package io.microsphere.metadata
Interface ConfigurationPropertyGenerator
-
- All Superinterfaces:
java.lang.Comparable<Prioritized>
,Prioritized
- All Known Implementing Classes:
DefaultConfigurationPropertyGenerator
,ReflectiveConfigurationPropertyGenerator
public interface ConfigurationPropertyGenerator extends Prioritized
ConfigurationPropertyGenerator
interface can be implemented by objects that generate string representations (e.g., JSON, XML, Properties) ofConfigurationProperty
.Implementing classes should typically also implement the
Prioritized.getPriority()
method to define their priority value. The priority is used to determine ordering via thePrioritized.compareTo(Prioritized)
method.Example Usage
public class JsonPropertyGenerator implements ConfigurationPropertyGenerator { public int getPriority() { return 1; } public String generate(ConfigurationProperty property) { // Implementation to generate JSON representation return "{\"" + property.getName() + "\":\"" + property.getValue() + "\"}"; } } // Registering and using generators List<ConfigurationPropertyGenerator> generators = new ArrayList<>(); generators.add(new JsonPropertyGenerator()); Collections.sort(generators); // Sort by priority
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ConfigurationProperty
,Prioritized
-
-
Field Summary
-
Fields inherited from interface io.microsphere.lang.Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
generate(ConfigurationProperty configurationProperty)
Generates a content of the givenConfigurationProperty
.-
Methods inherited from interface io.microsphere.lang.Prioritized
compareTo, getPriority
-
-
-
-
Method Detail
-
generate
@Nonnull java.lang.String generate(ConfigurationProperty configurationProperty) throws java.lang.IllegalArgumentException
Generates a content of the givenConfigurationProperty
.- 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.
-
-