Class ConfigurationProperty


  • public class ConfigurationProperty
    extends java.lang.Object
    ConfigurationProperty is a class that represents a configuration property with its name, type, value, default value, requirement status, description, and metadata.

    Example 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");
    
     System.out.println(property.getName());        // server.port
     System.out.println(property.getType());        // class java.lang.Integer
     System.out.println(property.getValue());       // 8080
     System.out.println(property.getDefaultValue()); // 8080
     System.out.println(property.isRequired());     // true
     System.out.println(property.getDescription()); // The port number for the server
     System.out.println(metadata.getSources());     // [application.properties]
     System.out.println(metadata.getTargets());     // [server]
     System.out.println(metadata.getDeclaredClass()); // com.example.ServerConfig
     System.out.println(metadata.getDeclaredField()); // port
     
    Since:
    1.0.0
    Author:
    Mercy
    • Constructor Detail

      • ConfigurationProperty

        public ConfigurationProperty​(java.lang.String name)
      • ConfigurationProperty

        public ConfigurationProperty​(java.lang.String name,
                                     java.lang.Class<?> type)
    • Method Detail

      • getDescription

        @Nonnull
        public java.lang.String getDescription()
      • setDescription

        public void setDescription​(java.lang.String description)
      • getName

        @Nonnull
        public java.lang.String getName()
      • getType

        @Nonnull
        public java.lang.String getType()
      • setType

        public void setType​(@Nonnull
                            java.lang.Class<?> type)
      • setType

        public void setType​(java.lang.String type)
      • getValue

        @Nullable
        public java.lang.Object getValue()
      • setValue

        public void setValue​(@Nullable
                             java.lang.Object value)
      • getDefaultValue

        @Nullable
        public java.lang.Object getDefaultValue()
      • setDefaultValue

        public void setDefaultValue​(@Nullable
                                    java.lang.Object defaultValue)
      • isRequired

        public boolean isRequired()
      • setRequired

        public void setRequired​(boolean required)
      • equals

        public final boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object