Skip to content

io microsphere lang DelegatingWrapper

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

DelegatingWrapper

Type: Interface | Module: microsphere-java-core | Package: io.microsphere.lang | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/lang/DelegatingWrapper.java

Overview

A delegating Wrapper interface that provides default implementations for unwrapping and checking wrapped object types. This interface is designed to be extended by classes that want to provide a delegated implementation of the wrapper pattern.

The main purpose of this interface is to simplify the implementation of the Wrapper interface by delegating the actual wrapping and unwrapping logic to the #getDelegate() method, which must be implemented by subclasses.

Example Usage

`public class MyWrapper implements DelegatingWrapper {
    private final Object delegate;

    public MyWrapper(Object delegate) {
        this.delegate = delegate;
    `

### Declaration

```java
public interface DelegatingWrapper extends Wrapper
```

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

### Example 1

```java
public class MyWrapper implements DelegatingWrapper {
    private final Object delegate;

    public MyWrapper(Object delegate) {
        this.delegate = delegate;
    }

    @Override
    public Object getDelegate() {
        return delegate;
    }
}
```

### Example 2

```java
MyWrapper wrapper = new MyWrapper(new SomeImplementation());
SomeImplementation impl = wrapper.unwrap(SomeImplementation.class);
```

### Example 3

```java
if (wrapper.isWrapperFor(SomeImplementation.class)) {
    SomeImplementation impl = wrapper.unwrap(SomeImplementation.class);
}
```

## 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.lang.DelegatingWrapper;
```

---

*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