Skip to content

Commit 527f4e7

Browse files
author
innokenty
committed
add constructors with arguments to browsers beans
1 parent 401f7be commit 527f4e7

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package ru.qatools.gridrouter.config;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45

56
/**
@@ -10,15 +11,15 @@ public interface WithCopy {
1011

1112
List<Host> getHosts();
1213

14+
String getName();
15+
1316
/**
1417
* Creates a copy for the {@link Region} object, which is almost deep:
1518
* the hosts itself are not copied although the list is new.
1619
*
1720
* @return a copy of the object
1821
*/
1922
default Region copy() {
20-
Region result = new Region();
21-
result.getHosts().addAll(getHosts());
22-
return result;
23+
return new Region(new ArrayList<>(getHosts()), getName());
2324
}
2425
}

config/src/test/java/ru/qatools/gridrouter/config/RandomHostSelectionStrategyTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void testRandomness() {
2727
int entriesCount = 5000000;
2828
int keysCount = 10;
2929

30-
Host host1 = newHost("host_1", keysCount - 1);
30+
Host host1 = new Host("host_1", 4444, keysCount - 1);
3131

3232
List<Host> hosts = new ArrayList<>(keysCount);
3333
hosts.add(host1);
@@ -54,14 +54,7 @@ public void testRandomness() {
5454
}
5555

5656
private static Host newHost() {
57-
return newHost(UUID.randomUUID().toString(), 1);
58-
}
59-
60-
private static Host newHost(String name, int count) {
61-
Host host = new Host();
62-
host.setName(name);
63-
host.setCount(count);
64-
return host;
57+
return new Host(UUID.randomUUID().toString(), 4444, 1);
6558
}
6659

6760
private static Matcher<Integer> isAround(int count) {

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,19 @@
112112
<verbose>true</verbose>
113113
<args>
114114
<arg>-Xinheritance</arg>
115+
<arg>-Xvalue-constructor</arg>
115116
</args>
116117
<plugins>
117118
<plugin>
118119
<groupId>org.jvnet.jaxb2_commons</groupId>
119120
<artifactId>jaxb2-basics</artifactId>
120121
<version>0.9.4</version>
121122
</plugin>
123+
<plugin>
124+
<groupId>org.jvnet.jaxb2_commons</groupId>
125+
<artifactId>jaxb2-value-constructor</artifactId>
126+
<version>3.0</version>
127+
</plugin>
122128
</plugins>
123129
</configuration>
124130
</plugin>

0 commit comments

Comments
 (0)