Skip to content

Commit 17eace1

Browse files
committed
declare envlopes to ease the decorator pattern
1 parent e67e95f commit 17eace1

File tree

3 files changed

+299
-0
lines changed

3 files changed

+299
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* Copyright 2014-2025 TNG Technology Consulting GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.tngtech.archunit.library.adr.envelopes;
17+
18+
import com.tngtech.archunit.PublicAPI;
19+
import com.tngtech.archunit.library.adr.Adr;
20+
import com.tngtech.archunit.library.adr.Metadata;
21+
import com.tngtech.archunit.library.adr.OptionProsAndCons;
22+
23+
import java.util.List;
24+
import java.util.Optional;
25+
26+
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS;
27+
import static com.tngtech.archunit.PublicAPI.Usage.INHERITANCE;
28+
29+
@PublicAPI(usage = INHERITANCE)
30+
public abstract class AdrEnvelope implements Adr {
31+
private final Adr delegate;
32+
33+
@PublicAPI(usage = ACCESS)
34+
public AdrEnvelope(final Adr delegate) {
35+
this.delegate = delegate;
36+
}
37+
38+
@PublicAPI(usage = ACCESS)
39+
@Override
40+
public Optional<Metadata> metadata() {
41+
return this.delegate.metadata();
42+
}
43+
44+
@PublicAPI(usage = ACCESS)
45+
@Override
46+
public Adr withMetadata(final Metadata metadata) {
47+
return this.delegate.withMetadata(metadata);
48+
}
49+
50+
@PublicAPI(usage = ACCESS)
51+
@Override
52+
public String contextAndProblemStatement() {
53+
return this.delegate.contextAndProblemStatement();
54+
}
55+
56+
@PublicAPI(usage = ACCESS)
57+
@Override
58+
public String title() {
59+
return this.delegate.title();
60+
}
61+
62+
@PublicAPI(usage = ACCESS)
63+
@Override
64+
public Optional<List<String>> decisionDrivers() {
65+
return this.delegate.decisionDrivers();
66+
}
67+
68+
@PublicAPI(usage = ACCESS)
69+
@Override
70+
public Adr withDecisionDrivers(final List<String> decisionDrivers) {
71+
return this.delegate.withDecisionDrivers(decisionDrivers);
72+
}
73+
74+
@PublicAPI(usage = ACCESS)
75+
@Override
76+
public List<String> consideredOptions() {
77+
return this.delegate.consideredOptions();
78+
}
79+
80+
@PublicAPI(usage = ACCESS)
81+
@Override
82+
public String decisionOutcome() {
83+
return this.delegate.decisionOutcome();
84+
}
85+
86+
@PublicAPI(usage = ACCESS)
87+
@Override
88+
public Optional<List<String>> consequences() {
89+
return this.delegate.consequences();
90+
}
91+
92+
@PublicAPI(usage = ACCESS)
93+
@Override
94+
public Adr withConsequences(final List<String> consequences) {
95+
return this.delegate.withConsequences(consequences);
96+
}
97+
98+
@PublicAPI(usage = ACCESS)
99+
@Override
100+
public Optional<String> confirmation() {
101+
return this.delegate.confirmation();
102+
}
103+
104+
@PublicAPI(usage = ACCESS)
105+
@Override
106+
public Adr withConfirmation(final String confirmation) {
107+
return this.delegate.withConfirmation(confirmation);
108+
}
109+
110+
@PublicAPI(usage = ACCESS)
111+
@Override
112+
public Optional<List<OptionProsAndCons>> optionProsAndCons() {
113+
return this.delegate.optionProsAndCons();
114+
}
115+
116+
@PublicAPI(usage = ACCESS)
117+
@Override
118+
public Adr withOptionProsAndCons(final List<OptionProsAndCons> optionProsAndCons) {
119+
return this.delegate.withOptionProsAndCons(optionProsAndCons);
120+
}
121+
122+
@PublicAPI(usage = ACCESS)
123+
@Override
124+
public Optional<String> moreInformation() {
125+
return this.delegate.moreInformation();
126+
}
127+
128+
@PublicAPI(usage = ACCESS)
129+
@Override
130+
public Adr withMoreInformation(final String moreInformation) {
131+
return this.delegate.withMoreInformation(moreInformation);
132+
}
133+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright 2014-2025 TNG Technology Consulting GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.tngtech.archunit.library.adr.envelopes;
17+
18+
import com.tngtech.archunit.PublicAPI;
19+
import com.tngtech.archunit.library.adr.Metadata;
20+
21+
import java.util.List;
22+
import java.util.Optional;
23+
24+
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS;
25+
import static com.tngtech.archunit.PublicAPI.Usage.INHERITANCE;
26+
27+
@PublicAPI(usage = INHERITANCE)
28+
public abstract class MetadataEnvelope implements Metadata {
29+
private final Metadata delegate;
30+
31+
@PublicAPI(usage = ACCESS)
32+
public MetadataEnvelope(final Metadata delegate) {
33+
this.delegate = delegate;
34+
}
35+
36+
@PublicAPI(usage = ACCESS)
37+
@Override
38+
public Optional<String> status() {
39+
return this.delegate.status();
40+
}
41+
42+
@PublicAPI(usage = ACCESS)
43+
@Override
44+
public Metadata withStatus(final String status) {
45+
return this.delegate.withStatus(status);
46+
}
47+
48+
@PublicAPI(usage = ACCESS)
49+
@Override
50+
public Optional<String> date() {
51+
return this.delegate.date();
52+
}
53+
54+
@PublicAPI(usage = ACCESS)
55+
@Override
56+
public Metadata withDate(final String date) {
57+
return this.delegate.withDate(date);
58+
}
59+
60+
@PublicAPI(usage = ACCESS)
61+
@Override
62+
public Optional<List<String>> decisionMakers() {
63+
return this.delegate.decisionMakers();
64+
}
65+
66+
@PublicAPI(usage = ACCESS)
67+
@Override
68+
public Metadata withDecisionMakers(final List<String> decisionMakers) {
69+
return this.delegate.withDecisionMakers(decisionMakers);
70+
}
71+
72+
@PublicAPI(usage = ACCESS)
73+
@Override
74+
public Optional<List<String>> consulted() {
75+
return this.delegate.consulted();
76+
}
77+
78+
@PublicAPI(usage = ACCESS)
79+
@Override
80+
public Metadata withConsulted(final List<String> consulted) {
81+
return this.delegate.withConsulted(consulted);
82+
}
83+
84+
@PublicAPI(usage = ACCESS)
85+
@Override
86+
public Optional<List<String>> informed() {
87+
return this.delegate.informed();
88+
}
89+
90+
@PublicAPI(usage = ACCESS)
91+
@Override
92+
public Metadata withInformed(final List<String> informed) {
93+
return this.delegate.withInformed(informed);
94+
}
95+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2014-2025 TNG Technology Consulting GmbH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.tngtech.archunit.library.adr.envelopes;
17+
18+
import com.tngtech.archunit.PublicAPI;
19+
import com.tngtech.archunit.library.adr.OptionProsAndCons;
20+
21+
import java.util.List;
22+
import java.util.Optional;
23+
24+
import static com.tngtech.archunit.PublicAPI.Usage.ACCESS;
25+
import static com.tngtech.archunit.PublicAPI.Usage.INHERITANCE;
26+
27+
@PublicAPI(usage = INHERITANCE)
28+
public abstract class OptionProsAndConsEnvelope implements OptionProsAndCons {
29+
private final OptionProsAndCons delegate;
30+
31+
@PublicAPI(usage = ACCESS)
32+
public OptionProsAndConsEnvelope(final OptionProsAndCons delegate) {
33+
this.delegate = delegate;
34+
}
35+
36+
@PublicAPI(usage = ACCESS)
37+
@Override
38+
public String title() {
39+
return this.delegate.title();
40+
}
41+
42+
@PublicAPI(usage = ACCESS)
43+
@Override
44+
public Optional<String> description() {
45+
return this.delegate.description();
46+
}
47+
48+
@PublicAPI(usage = ACCESS)
49+
@Override
50+
public OptionProsAndCons withDescription(final String description) {
51+
return this.delegate.withDescription(description);
52+
}
53+
54+
@PublicAPI(usage = ACCESS)
55+
@Override
56+
public Optional<String> example() {
57+
return this.delegate.example();
58+
}
59+
60+
@PublicAPI(usage = ACCESS)
61+
@Override
62+
public OptionProsAndCons withExample(final String example) {
63+
return this.delegate.withExample(example);
64+
}
65+
66+
@PublicAPI(usage = ACCESS)
67+
@Override
68+
public List<String> prosAndCons() {
69+
return this.delegate.prosAndCons();
70+
}
71+
}

0 commit comments

Comments
 (0)