4141 */
4242final class GroupsMetadata {
4343
44- private final Map <String , DefaultRegistration > groupMap ;
44+ private final Map <String , Registration > groupMap ;
4545
4646 public GroupsMetadata () {
4747 this (Collections .emptyList ());
4848 }
4949
50- GroupsMetadata (Iterable <DefaultRegistration > registrations ) {
50+ GroupsMetadata (Iterable <Registration > registrations ) {
5151 this .groupMap = new LinkedHashMap <>();
5252 registrations .forEach (registration -> this .groupMap .put (registration .name (), registration ));
5353 }
@@ -58,7 +58,7 @@ public GroupsMetadata() {
5858 * types after checking they don't conflict.
5959 */
6060 public Registration getOrCreateGroup (String groupName , HttpServiceGroup .ClientType clientType ) {
61- return this .groupMap .computeIfAbsent (groupName , name -> new DefaultRegistration (name , clientType ))
61+ return this .groupMap .computeIfAbsent (groupName , name -> new Registration (name , clientType ))
6262 .clientType (clientType );
6363 }
6464
@@ -94,71 +94,51 @@ public Collection<HttpServiceGroup> groups(@Nullable ClassLoader classLoader) {
9494 /**
9595 * Return the raw {@link DefaultRegistration registrations}.
9696 */
97- Stream <DefaultRegistration > registrations () {
97+ Stream <Registration > registrations () {
9898 return this .groupMap .values ().stream ();
9999 }
100100
101101
102102 /**
103103 * Registration metadata for an {@link HttpServiceGroup}.
104104 */
105- interface Registration {
106-
107- String name ();
108-
109- HttpServiceGroup .ClientType clientType ();
110-
111- Set <String > httpServiceTypeNames ();
112- }
113-
114-
115- /**
116- * Default implementation of {@link Registration}.
117- */
118- static class DefaultRegistration implements Registration {
105+ static class Registration {
119106
120107 private final String name ;
121108
122109 private HttpServiceGroup .ClientType clientType ;
123110
124- private final Set <String > typeNames ;
111+ private final Set <String > httpServiceTypeNames ;
125112
126- DefaultRegistration (String name , HttpServiceGroup .ClientType clientType ) {
113+ Registration (String name , HttpServiceGroup .ClientType clientType ) {
127114 this (name , clientType , new LinkedHashSet <>());
128115 }
129116
130- DefaultRegistration (String name , HttpServiceGroup .ClientType clientType , Set <String > typeNames ) {
117+ Registration (String name , HttpServiceGroup .ClientType clientType , Set <String > httpServiceTypeNames ) {
131118 this .name = name ;
132119 this .clientType = clientType ;
133- this .typeNames = typeNames ;
120+ this .httpServiceTypeNames = httpServiceTypeNames ;
134121 }
135122
136- @ Override
137- public String name () {
123+ String name () {
138124 return this .name ;
139125 }
140126
141- @ Override
142- public HttpServiceGroup .ClientType clientType () {
127+ HttpServiceGroup .ClientType clientType () {
143128 return this .clientType ;
144129 }
145130
146- @ Override
147- public Set <String > httpServiceTypeNames () {
148- return this .typeNames ;
131+ Set <String > httpServiceTypeNames () {
132+ return this .httpServiceTypeNames ;
149133 }
150134
151135 /**
152136 * Update the client type if it does not conflict with the existing value.
153137 */
154- public DefaultRegistration clientType (HttpServiceGroup .ClientType other ) {
155- if (this .clientType .isUnspecified ()) {
156- this .clientType = other ;
157- }
158- else {
159- Assert .isTrue (this .clientType == other || other .isUnspecified (),
160- "ClientType conflict for HttpServiceGroup '" + this .name + "'" );
161- }
138+ public Registration clientType (HttpServiceGroup .ClientType other ) {
139+ this .clientType = (this .clientType .isUnspecified () ? other : this .clientType );
140+ Assert .isTrue (this .clientType == other || other .isUnspecified (),
141+ "ClientType conflict for HttpServiceGroup '" + this .name + "'" );
162142 return this ;
163143 }
164144
@@ -168,15 +148,16 @@ public DefaultRegistration clientType(HttpServiceGroup.ClientType other) {
168148 public HttpServiceGroup toHttpServiceGroup (@ Nullable ClassLoader classLoader ) {
169149 return new RegisteredGroup (this .name ,
170150 (this .clientType .isUnspecified () ? HttpServiceGroup .ClientType .REST_CLIENT : this .clientType ),
171- this .typeNames .stream ()
151+ this .httpServiceTypeNames .stream ()
172152 .map (typeName -> ClassUtils .resolveClassName (typeName , classLoader ))
173153 .collect (Collectors .toSet ()));
174154 }
175155
176156 @ Override
177157 public String toString () {
178- return "Group '" + this .name + "', ClientType." + this .clientType + ", " + this .typeNames ;
158+ return "Group '" + this .name + "', ClientType." + this .clientType + ", " + this .httpServiceTypeNames ;
179159 }
160+
180161 }
181162
182163
0 commit comments