Skip to content

io microsphere reflect MemberDefinition

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

MemberDefinition

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

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

Overview

The definition class for Java Reflection Member.

This abstract class provides a base implementation to define and resolve members (such as fields, methods, or constructors) from a class. It extends the capabilities of the ReflectiveDefinition class by adding support for member names and lazy resolution of the actual reflection object.

Example Usage

`public class FieldDefinition extends MemberDefinition {

    public FieldDefinition(Version since, String declaredClassName, String name) {
        super(since, null, declaredClassName, name);
    `

### Declaration

```java
public abstract class MemberDefinition extends ReflectiveDefinition
```

**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

```java
public class FieldDefinition extends MemberDefinition {

    public FieldDefinition(Version since, String declaredClassName, String name) {
        super(since, null, declaredClassName, name);
    }

    @Override
    protected Field resolveMember() {
        Class> clazz = getDeclaredClass();
        if (clazz == null) {
            return null;
        }
        try {
            return clazz.getDeclaredField(name);
        } catch (NoSuchFieldException e) {
            return null;
        }
    }
}
```

## Usage

### Maven Dependency

Add the following dependency to your `pom.xml`:

```xml

    io.github.microsphere-projects
    microsphere-java-core
    ${microsphere-java.version}

```

> **Tip:** Use the BOM (`microsphere-java-dependencies`) for consistent version management. See the [Getting Started](https://github.com/microsphere-projects/microsphere-java#getting-started) guide.

### Import

```java
import io.microsphere.reflect.MemberDefinition;
```

## API Reference

### Public Methods

| Method | Description |
|--------|-------------|
| `getName` |  |
| `getDeclaredClassName` | Get the declared class name |
| `getDeclaredClass` | Get the declared class |
| `getMember` | Get the member instance |
| `isPresent` |  |

## See Also

- `Member`
- `ConstructorDefinition`
- `FieldDefinition`
- `MethodDefinition`

---

*This documentation was auto-generated from the source code of [microsphere-java](https://github.com/microsphere-projects/microsphere-java).*

Home

annotation-processor

java-annotations

java-core

java-test

jdk-tools

lang-model

Clone this wiki locally