Skip to content

Commit 0ebd10e

Browse files
committed
Moves RoutingType to stand alone class
1 parent f89e010 commit 0ebd10e

File tree

4 files changed

+53
-34
lines changed

4 files changed

+53
-34
lines changed

rsocket-routing-client/src/test/java/io/rsocket/routing/client/RoutingRSocketClientTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.rsocket.routing.common.MimeTypes;
2424
import io.rsocket.routing.frames.Address;
2525
import io.rsocket.routing.frames.AddressFlyweight;
26+
import io.rsocket.routing.frames.RoutingType;
2627
import io.rsocket.transport.local.LocalClientTransport;
2728
import org.junit.jupiter.api.Test;
2829

@@ -66,7 +67,7 @@ private Address assertAddress(CompositeByteBuf composite) {
6667
assertThat(address).isNotNull();
6768
assertThat(address.getOriginRouteId()).isEqualTo(ORIGIN_ID);
6869
assertThat(address.getTags().get(SERVICE_NAME)).isEqualTo("remoteservice");
69-
assertThat(address.getRoutingType()).isEqualTo(Address.RoutingType.MULTICAST);
70+
assertThat(address.getRoutingType()).isEqualTo(RoutingType.MULTICAST);
7071
return address;
7172
}
7273

rsocket-routing-frames/src/main/java/io/rsocket/routing/frames/Address.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package io.rsocket.routing.frames;
1818

19-
import java.util.HashMap;
20-
import java.util.Map;
2119
import java.util.Objects;
2220
import java.util.StringJoiner;
2321

@@ -89,36 +87,6 @@ public static Address from(ByteBuf byteBuf, int flags) {
8987
.with(tags(byteBuf)).flags(flags).build();
9088
}
9189

92-
public enum RoutingType {
93-
UNICAST(AddressFlyweight.FLAGS_U),
94-
MULTICAST(AddressFlyweight.FLAGS_M),
95-
SHARD(AddressFlyweight.FLAGS_S);
96-
97-
private static Map<Integer, RoutingType> routingTypesByFlag;
98-
99-
static {
100-
routingTypesByFlag = new HashMap<>();
101-
102-
for (RoutingType routingType : values()) {
103-
routingTypesByFlag.put(routingType.getFlag(), routingType);
104-
}
105-
}
106-
107-
private int flag;
108-
109-
RoutingType(int flag) {
110-
this.flag = flag;
111-
}
112-
113-
public int getFlag() {
114-
return this.flag;
115-
}
116-
117-
public static RoutingType from(int flag) {
118-
return routingTypesByFlag.get(flag);
119-
}
120-
}
121-
12290
public static final class Builder extends Tags.Builder<Builder> {
12391
private final Id originRouteId;
12492

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2020 the original author or authors.
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+
* https://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+
17+
package io.rsocket.routing.frames;
18+
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
22+
public enum RoutingType {
23+
UNICAST(AddressFlyweight.FLAGS_U),
24+
MULTICAST(AddressFlyweight.FLAGS_M),
25+
SHARD(AddressFlyweight.FLAGS_S);
26+
27+
private static Map<Integer, RoutingType> routingTypesByFlag;
28+
29+
static {
30+
routingTypesByFlag = new HashMap<>();
31+
32+
for (RoutingType routingType : values()) {
33+
routingTypesByFlag.put(routingType.getFlag(), routingType);
34+
}
35+
}
36+
37+
private int flag;
38+
39+
RoutingType(int flag) {
40+
this.flag = flag;
41+
}
42+
43+
public int getFlag() {
44+
return this.flag;
45+
}
46+
47+
public static RoutingType from(int flag) {
48+
return routingTypesByFlag.get(flag);
49+
}
50+
}

rsocket-routing-frames/src/test/java/io/rsocket/routing/frames/AddressTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.junit.jupiter.api.Assertions;
2121
import org.junit.jupiter.api.Test;
2222

23-
import static io.rsocket.routing.frames.Address.RoutingType.MULTICAST;
23+
import static io.rsocket.routing.frames.RoutingType.MULTICAST;
2424
import static org.assertj.core.api.Assertions.assertThat;
2525

2626
class AddressTests {

0 commit comments

Comments
 (0)