Skip to content

io microsphere reflect FieldDefinition

github-actions[bot] edited this page Mar 24, 2026 · 3 revisions

FieldDefinition

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

Source: microsphere-java-core/src/main/java/io/microsphere/reflect/FieldDefinition.java

Overview

The definition class of Field

Example Usage

`// Create a FieldDefinition for the 'name' field of the User class, introduced in version 1.0.0.
FieldDefinition fieldDef = new FieldDefinition("1.0.0", "com.example.User", "name");

// Get the resolved Field object (null if not found or not resolvable)
Field field = fieldDef.getResolvedField();

// Access and modify the field value on an instance
User user = new User();
fieldDef.set(user, "John Doe"); // Set the 'name' field to "John Doe"
String name = fieldDef.get(user); // Retrieve the value of 'name' field
`

This class provides utilities to define, resolve, and manipulate fields reflectively, with support for versioning and deprecation information inherited from MemberDefinition.

Declaration

public final class FieldDefinition extends MemberDefinition<Field>

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.2-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

// Create a FieldDefinition for the 'name' field of the User class, introduced in version 1.0.0.
FieldDefinition fieldDef = new FieldDefinition("1.0.0", "com.example.User", "name");

// Get the resolved Field object (null if not found or not resolvable)
Field field = fieldDef.getResolvedField();

// Access and modify the field value on an instance
User user = new User();
fieldDef.set(user, "John Doe"); // Set the 'name' field to "John Doe"
String name = fieldDef.get(user); // Retrieve the value of 'name' field

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.reflect.FieldDefinition;

API Reference

Public Methods

Method Description
get
set Set the field value

See Also

  • Field

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

Home

annotation-processor

java-annotations

java-core

java-test

jdk-tools

lang-model

Clone this wiki locally