Skip to content

io microsphere beans ConfigurationProperty

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

ConfigurationProperty

Type: Class | Module: microsphere-java-core | Package: io.microsphere.beans | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/beans/ConfigurationProperty.java

Overview

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
`

Declaration

public class ConfigurationProperty

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

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

Method Examples

getSources

ConfigurationProperty.Metadata metadata = new ConfigurationProperty.Metadata();
metadata.getSources().add("source1");
metadata.getSources().add("source2");

// Retrieving the sources
Set<String> sources = metadata.getSources(); // contains "source1", "source2"

getTargets

ConfigurationProperty.Metadata metadata = new ConfigurationProperty.Metadata();
metadata.getTargets().add("target1");
metadata.getTargets().add("target2");

// Retrieving the targets
Set<String> targets = metadata.getTargets(); // contains "target1", "target2"

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.beans.ConfigurationProperty;

API Reference

Public Methods

Method Description
getSources The name of the property
getTargets Retrieves the set of targets associated with this configuration property.
getDeclaredClass Get the declared class name.
getDeclaredField Get the declared field name.
setDeclaredClass Set the declared class name.
setDeclaredField Set the declared field name.

Method Details

getTargets

public Set<String> getTargets()

Retrieves the set of targets associated with this configuration property. If the targets set is null, it will be initialized with an empty linked hash set.

Example Usage

`ConfigurationProperty.Metadata metadata = new ConfigurationProperty.Metadata();
metadata.getTargets().add("target1");
metadata.getTargets().add("target2");

// Retrieving the targets
Set targets = metadata.getTargets(); // contains "target1", "target2"
`

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally