|
| 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.simples; |
| 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 | + |
| 28 | +@PublicAPI(usage = ACCESS) |
| 29 | +public final class SimpleAdr implements Adr { |
| 30 | + |
| 31 | + private Metadata metadata; |
| 32 | + private final String title; |
| 33 | + private final String contextAndProblemStatement; |
| 34 | + private List<String> decisionDrivers; |
| 35 | + private final List<String> consideredOptions; |
| 36 | + private final String decisionOutcome; |
| 37 | + private List<String> consequences; |
| 38 | + private String confirmation; |
| 39 | + private List<OptionProsAndCons> optionProsAndCons; |
| 40 | + private String moreInformation; |
| 41 | + |
| 42 | + @PublicAPI(usage = ACCESS) |
| 43 | + public SimpleAdr(final String title, final String contextAndProblemStatement, final List<String> consideredOptions, final String decisionOutcome) { |
| 44 | + this.title = title; |
| 45 | + this.contextAndProblemStatement = contextAndProblemStatement; |
| 46 | + this.consideredOptions = consideredOptions; |
| 47 | + this.decisionOutcome = decisionOutcome; |
| 48 | + } |
| 49 | + |
| 50 | + @PublicAPI(usage = ACCESS) |
| 51 | + @Override |
| 52 | + public Optional<Metadata> metadata() { |
| 53 | + return Optional.ofNullable(this.metadata); |
| 54 | + } |
| 55 | + |
| 56 | + @PublicAPI(usage = ACCESS) |
| 57 | + @Override |
| 58 | + public Adr withMetadata(final Metadata metadata) { |
| 59 | + this.metadata = metadata; |
| 60 | + return this; |
| 61 | + } |
| 62 | + |
| 63 | + @PublicAPI(usage = ACCESS) |
| 64 | + @Override |
| 65 | + public String title() { |
| 66 | + return this.title; |
| 67 | + } |
| 68 | + |
| 69 | + @PublicAPI(usage = ACCESS) |
| 70 | + @Override |
| 71 | + public String contextAndProblemStatement() { |
| 72 | + return this.contextAndProblemStatement; |
| 73 | + } |
| 74 | + |
| 75 | + @PublicAPI(usage = ACCESS) |
| 76 | + @Override |
| 77 | + public Optional<List<String>> decisionDrivers() { |
| 78 | + return Optional.ofNullable(this.decisionDrivers); |
| 79 | + } |
| 80 | + |
| 81 | + @PublicAPI(usage = ACCESS) |
| 82 | + @Override |
| 83 | + public Adr withDecisionDrivers(final List<String> decisionDrivers) { |
| 84 | + this.decisionDrivers = decisionDrivers; |
| 85 | + return this; |
| 86 | + } |
| 87 | + |
| 88 | + @PublicAPI(usage = ACCESS) |
| 89 | + @Override |
| 90 | + public List<String> consideredOptions() { |
| 91 | + return this.consideredOptions; |
| 92 | + } |
| 93 | + |
| 94 | + @PublicAPI(usage = ACCESS) |
| 95 | + @Override |
| 96 | + public String decisionOutcome() { |
| 97 | + return this.decisionOutcome; |
| 98 | + } |
| 99 | + |
| 100 | + @PublicAPI(usage = ACCESS) |
| 101 | + @Override |
| 102 | + public Optional<List<String>> consequences() { |
| 103 | + return Optional.ofNullable(this.consequences); |
| 104 | + } |
| 105 | + |
| 106 | + @PublicAPI(usage = ACCESS) |
| 107 | + @Override |
| 108 | + public Adr withConsequences(final List<String> consequences) { |
| 109 | + this.consequences = consequences; |
| 110 | + return this; |
| 111 | + } |
| 112 | + |
| 113 | + @PublicAPI(usage = ACCESS) |
| 114 | + @Override |
| 115 | + public Optional<String> confirmation() { |
| 116 | + return Optional.ofNullable(this.confirmation); |
| 117 | + } |
| 118 | + |
| 119 | + @PublicAPI(usage = ACCESS) |
| 120 | + @Override |
| 121 | + public Adr withConfirmation(final String confirmation) { |
| 122 | + this.confirmation = confirmation; |
| 123 | + return this; |
| 124 | + } |
| 125 | + |
| 126 | + @PublicAPI(usage = ACCESS) |
| 127 | + @Override |
| 128 | + public Optional<List<OptionProsAndCons>> optionProsAndCons() { |
| 129 | + return Optional.ofNullable(this.optionProsAndCons); |
| 130 | + } |
| 131 | + |
| 132 | + @PublicAPI(usage = ACCESS) |
| 133 | + @Override |
| 134 | + public Adr withOptionProsAndCons(final List<OptionProsAndCons> optionProsAndCons) { |
| 135 | + this.optionProsAndCons = optionProsAndCons; |
| 136 | + return this; |
| 137 | + } |
| 138 | + |
| 139 | + @PublicAPI(usage = ACCESS) |
| 140 | + @Override |
| 141 | + public Optional<String> moreInformation() { |
| 142 | + return Optional.ofNullable(this.moreInformation); |
| 143 | + } |
| 144 | + |
| 145 | + @PublicAPI(usage = ACCESS) |
| 146 | + @Override |
| 147 | + public Adr withMoreInformation(final String moreInformation) { |
| 148 | + this.moreInformation = moreInformation; |
| 149 | + return this; |
| 150 | + } |
| 151 | +} |
0 commit comments