https://github.com/victornoel/eo-envelopes
Elegant Objects Envelopes
https://github.com/victornoel/eo-envelopes
annotation-processing java java-library oop oop-library oop-principles
Last synced: 9 months ago
JSON representation
Elegant Objects Envelopes
- Host: GitHub
- URL: https://github.com/victornoel/eo-envelopes
- Owner: victornoel
- License: other
- Created: 2018-04-01T14:53:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T22:47:09.000Z (over 2 years ago)
- Last Synced: 2025-03-22T22:05:39.436Z (9 months ago)
- Topics: annotation-processing, java, java-library, oop, oop-library, oop-principles
- Language: Java
- Homepage:
- Size: 70.3 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README

[](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.victornoel.eo%22%20AND%20a%3A%22eo-envelopes%22)

# Elegant Objects Envelopes
Distributed under the GPL 3.0.
Note that the output of the processor is not covered by this license and can be used without any restrictions.
## Why
See http://www.yegor256.com/2017/01/31/decorating-envelopes.html for an explanation of the requirements.
## How
For the latest version, see the Maven Central badge at the top, SNAPSHOTs are deployed to OSS Sonatype.
Add the following dependency:
```xml
com.github.victornoel.eo
eo-envelopes-annotations
provided
```
And the processor:
```xml
maven-compiler-plugin
com.github.victornoel.eo
eo-envelopes
```
Enable Annotation Processing in your IDE to take advantage of it during development.
Simply annotate your interfaces with `@GenerateEnvelope` and an envelope class will be generated for it.
You can now extend it to write a decorating envelope without managing the delegation yourself.
## What
```java
package test;
import com.github.victornoel.eo.GenerateEnvelope;
@GenerateEnvelope
public interface Test {
String lol(int ab);
void lol(Double a) throws Exception;
}
```
Gives you:
```java
package test;
import java.lang.Double;
import java.lang.Exception;
import java.lang.Override;
import java.lang.String;
public abstract class TestEnvelope implements Test {
protected final Test wrapped;
public TestEnvelope(Test wrapped) {
this.wrapped = wrapped;
}
@Override
public final String lol(int ab) {
return wrapped.lol(ab);
}
@Override
public final void lol(Double a) throws Exception {
wrapped.lol(a);
}
}
```
Inner interfaces are also supported:
```java
package test;
import com.github.victornoel.eo.GenerateEnvelope;
public class AClass {
@GenerateEnvelope
public interface Test {
String lol(int ab);
void lol(Double a) throws Exception;
}
}
```
Gives you
```java
package test;
import java.lang.Double;
import java.lang.Exception;
import java.lang.Override;
import java.lang.String;
import javax.annotation.Generated;
@Generated("com.github.victornoel.eo.apt.GenerateEnvelopeProcessor")
public abstract class AClassTestEnvelope implements AClass.Test {
protected final AClass.Test wrapped;
public AClassTestEnvelope(AClass.Test wrapped) {
this.wrapped = wrapped;
}
@Override
public final String lol(int ab) {
return wrapped.lol(ab);
}
@Override
public final void lol(Double a) throws Exception {
wrapped.lol(a);
}
}
```