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) of ConfigurationProperty.

    Implementing classes should typically also implement the Prioritized.getPriority() method to define their priority value. The priority is used to determine ordering via the Prioritized.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
    • Method Detail

      • generate

        @Nonnull
        java.lang.String generate​(ConfigurationProperty configurationProperty)
                           throws java.lang.IllegalArgumentException
        Generates a content of the given ConfigurationProperty.
        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.