1 package org.codehaus.plexus.components.secdispatcher;
2
3 import java.util.Collection;
4 import java.util.List;
5 import java.util.Optional;
6
7 import static java.util.Objects.requireNonNull;
8
9
10
11
12 public interface DispatcherMeta {
13 final class Field {
14 private final String key;
15 private final boolean optional;
16 private final String defaultValue;
17 private final String description;
18 private final List<Field> options;
19
20 private Field(String key, boolean optional, String defaultValue, String description, List<Field> options) {
21 this.key = requireNonNull(key);
22 this.optional = optional;
23 this.defaultValue = defaultValue;
24 this.description = requireNonNull(description);
25 this.options = options;
26 }
27
28
29
30
31 public String getKey() {
32 return key;
33 }
34
35
36
37
38 public boolean isOptional() {
39 return optional;
40 }
41
42
43
44
45 public Optional<String> getDefaultValue() {
46 return Optional.ofNullable(defaultValue);
47 }
48
49
50
51
52 public String getDescription() {
53 return description;
54 }
55
56
57
58
59
60
61
62 public Optional<List<Field>> getOptions() {
63 return Optional.ofNullable(options);
64 }
65
66 public static Builder builder(String key) {
67 return new Builder(key);
68 }
69
70 public static final class Builder {
71 private final String key;
72 private boolean optional;
73 private String defaultValue;
74 private String description;
75 private List<Field> options;
76
77 private Builder(String key) {
78 this.key = requireNonNull(key);
79 }
80
81 public Builder optional(boolean optional) {
82 this.optional = optional;
83 return this;
84 }
85
86 public Builder defaultValue(String defaultValue) {
87 this.defaultValue = defaultValue;
88 return this;
89 }
90
91 public Builder description(String description) {
92 this.description = requireNonNull(description);
93 return this;
94 }
95
96 public Builder options(List<Field> options) {
97 this.options = requireNonNull(options);
98 return this;
99 }
100
101 public Field build() {
102 return new Field(key, optional, defaultValue, description, options);
103 }
104 }
105 }
106
107
108
109
110 default boolean isHidden() {
111 return false;
112 }
113
114
115
116
117 String name();
118
119
120
121
122 String displayName();
123
124
125
126
127 Collection<Field> fields();
128 }