mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
renamed to putWith() to putMapped()
This commit is contained in:
@@ -38,13 +38,13 @@ public class CHMUseCasesTest {
|
||||
map.put("Hello", "World");
|
||||
assertEquals("World", map.get("Hello"));
|
||||
|
||||
assertEquals("New World", map.mapForKey("Hello", new Function<String, String>() {
|
||||
assertEquals("New World", map.getMapped("Hello", new Function<String, String>() {
|
||||
@Override
|
||||
public String apply(String s) {
|
||||
return "New " + s;
|
||||
}
|
||||
}));
|
||||
assertEquals(null, map.mapForKey("No key", new Function<String, String>() {
|
||||
assertEquals(null, map.getMapped("No key", new Function<String, String>() {
|
||||
@Override
|
||||
public String apply(String s) {
|
||||
return "New " + s;
|
||||
@@ -73,7 +73,7 @@ public class CHMUseCasesTest {
|
||||
map.put("Hello", "World");
|
||||
|
||||
|
||||
map.putWith("Hello", new Mutator<String>() {
|
||||
map.putMapped("Hello", new UnaryOperator<String>() {
|
||||
@Override
|
||||
public String update(String s) {
|
||||
return "New " + s;
|
||||
@@ -109,14 +109,14 @@ public class CHMUseCasesTest {
|
||||
assertNull(map.getUsing(key, value));
|
||||
|
||||
|
||||
assertEquals("New World", map.mapForKey("Hello", new
|
||||
assertEquals("New World", map.getMapped("Hello", new
|
||||
Function<CharSequence, CharSequence>() {
|
||||
@Override
|
||||
public CharSequence apply(CharSequence s) {
|
||||
return "New " + s;
|
||||
}
|
||||
}));
|
||||
assertEquals(null, map.mapForKey("No key", new
|
||||
assertEquals(null, map.getMapped("No key", new
|
||||
Function<CharSequence, CharSequence>() {
|
||||
@Override
|
||||
public CharSequence apply(CharSequence s) {
|
||||
@@ -124,8 +124,8 @@ public class CHMUseCasesTest {
|
||||
}
|
||||
}));
|
||||
|
||||
assertEquals("New World !!", map.putWith("Hello", new
|
||||
Mutator<CharSequence>() {
|
||||
assertEquals("New World !!", map.putMapped("Hello", new
|
||||
UnaryOperator<CharSequence>() {
|
||||
@Override
|
||||
public CharSequence update(CharSequence s) {
|
||||
((StringBuilder) s).append(" !!");
|
||||
@@ -135,8 +135,8 @@ public class CHMUseCasesTest {
|
||||
|
||||
assertEquals("New World !!", map.get("Hello").toString());
|
||||
|
||||
assertEquals(null, map.putWith("no-key", new
|
||||
Mutator<CharSequence>() {
|
||||
assertEquals(null, map.putMapped("no-key", new
|
||||
UnaryOperator<CharSequence>() {
|
||||
@Override
|
||||
public CharSequence update(CharSequence s) {
|
||||
((StringBuilder) s).append("!!");
|
||||
@@ -268,13 +268,13 @@ public class CHMUseCasesTest {
|
||||
assertEquals(null, map.get(3));
|
||||
assertEquals(null, map.get(4));
|
||||
|
||||
assertEquals((Integer) 110, map.mapForKey(1, new Function<Integer, Integer>() {
|
||||
assertEquals((Integer) 110, map.getMapped(1, new Function<Integer, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Integer s) {
|
||||
return 10 * s;
|
||||
}
|
||||
}));
|
||||
assertEquals(null, map.mapForKey(-1, new Function<Integer, Integer>() {
|
||||
assertEquals(null, map.getMapped(-1, new Function<Integer, Integer>() {
|
||||
@Override
|
||||
public Integer apply(Integer s) {
|
||||
return 10 * s;
|
||||
@@ -282,7 +282,7 @@ public class CHMUseCasesTest {
|
||||
}));
|
||||
|
||||
try {
|
||||
map.putWith(1, new Mutator<Integer>() {
|
||||
map.putMapped(1, new UnaryOperator<Integer>() {
|
||||
@Override
|
||||
public Integer update(Integer s) {
|
||||
return s + 1;
|
||||
@@ -311,13 +311,13 @@ public class CHMUseCasesTest {
|
||||
assertEquals(null, map.get(3L));
|
||||
assertEquals(null, map.get(4L));
|
||||
|
||||
assertEquals((Long) 110L, map.mapForKey(1L, new Function<Long, Long>() {
|
||||
assertEquals((Long) 110L, map.getMapped(1L, new Function<Long, Long>() {
|
||||
@Override
|
||||
public Long apply(Long s) {
|
||||
return 10 * s;
|
||||
}
|
||||
}));
|
||||
assertEquals(null, map.mapForKey(-1L, new Function<Long, Long>() {
|
||||
assertEquals(null, map.getMapped(-1L, new Function<Long, Long>() {
|
||||
@Override
|
||||
public Long apply(Long s) {
|
||||
return 10 * s;
|
||||
@@ -325,7 +325,7 @@ public class CHMUseCasesTest {
|
||||
}));
|
||||
|
||||
try {
|
||||
map.putWith(1L, new Mutator<Long>() {
|
||||
map.putMapped(1L, new UnaryOperator<Long>() {
|
||||
@Override
|
||||
public Long update(Long s) {
|
||||
return s + 1;
|
||||
@@ -354,13 +354,13 @@ public class CHMUseCasesTest {
|
||||
assertEquals(null, map.get(3.0));
|
||||
assertEquals(null, map.get(4.0));
|
||||
|
||||
assertEquals((Double) 110.0, map.mapForKey(1.0, new Function<Double, Double>() {
|
||||
assertEquals((Double) 110.0, map.getMapped(1.0, new Function<Double, Double>() {
|
||||
@Override
|
||||
public Double apply(Double s) {
|
||||
return 10 * s;
|
||||
}
|
||||
}));
|
||||
assertEquals(null, map.mapForKey(-1.0, new Function<Double, Double>() {
|
||||
assertEquals(null, map.getMapped(-1.0, new Function<Double, Double>() {
|
||||
@Override
|
||||
public Double apply(Double s) {
|
||||
return 10 * s;
|
||||
@@ -368,7 +368,7 @@ public class CHMUseCasesTest {
|
||||
}));
|
||||
|
||||
try {
|
||||
map.putWith(1.0, new Mutator<Double>() {
|
||||
map.putMapped(1.0, new UnaryOperator<Double>() {
|
||||
@Override
|
||||
public Double update(Double s) {
|
||||
return s + 1;
|
||||
@@ -401,20 +401,20 @@ public class CHMUseCasesTest {
|
||||
map.put(key1, value1);
|
||||
|
||||
|
||||
assertTrue(Arrays.equals(new byte[]{11, 11}, map.mapForKey(key1, new Function<byte[], byte[]>() {
|
||||
assertTrue(Arrays.equals(new byte[]{11, 11}, map.getMapped(key1, new Function<byte[], byte[]>() {
|
||||
@Override
|
||||
public byte[] apply(byte[] s) {
|
||||
return Arrays.copyOf(s, 2);
|
||||
}
|
||||
})));
|
||||
assertEquals(null, map.mapForKey(key2, new Function<byte[], byte[]>() {
|
||||
assertEquals(null, map.getMapped(key2, new Function<byte[], byte[]>() {
|
||||
@Override
|
||||
public byte[] apply(byte[] s) {
|
||||
return Arrays.copyOf(s, 2);
|
||||
}
|
||||
}));
|
||||
|
||||
assertTrue(Arrays.equals(new byte[]{12, 10}, map.putWith(key1, new Mutator<byte[]>() {
|
||||
assertTrue(Arrays.equals(new byte[]{12, 10}, map.putMapped(key1, new UnaryOperator<byte[]>() {
|
||||
@Override
|
||||
public byte[] update(byte[] s) {
|
||||
s[0]++;
|
||||
@@ -458,10 +458,10 @@ public class CHMUseCasesTest {
|
||||
};
|
||||
|
||||
map.put(key1, value1);
|
||||
assertBBEquals(ByteBuffer.wrap(new byte[]{11, 11}), map.mapForKey(key1, function));
|
||||
assertEquals(null, map.mapForKey(key2, function));
|
||||
assertBBEquals(ByteBuffer.wrap(new byte[]{11, 11}), map.getMapped(key1, function));
|
||||
assertEquals(null, map.getMapped(key2, function));
|
||||
|
||||
assertBBEquals(ByteBuffer.wrap(new byte[]{12, 10}), map.putWith(key1, new Mutator<ByteBuffer>() {
|
||||
assertBBEquals(ByteBuffer.wrap(new byte[]{12, 10}), map.putMapped(key1, new UnaryOperator<ByteBuffer>() {
|
||||
@Override
|
||||
public ByteBuffer update(ByteBuffer s) {
|
||||
s.put(0, (byte) (s.get(0) + 1));
|
||||
@@ -568,10 +568,10 @@ public class CHMUseCasesTest {
|
||||
return slice;
|
||||
}
|
||||
};
|
||||
assertBBEquals(ByteBuffer.wrap(new byte[]{11, 11}), map.mapForKey(key1, function));
|
||||
assertEquals(null, map.mapForKey(key2, function));
|
||||
assertBBEquals(ByteBuffer.wrap(new byte[]{11, 11}), map.getMapped(key1, function));
|
||||
assertEquals(null, map.getMapped(key2, function));
|
||||
|
||||
assertBBEquals(ByteBuffer.wrap(new byte[]{12, 10}), map.putWith(key1, new Mutator<ByteBuffer>() {
|
||||
assertBBEquals(ByteBuffer.wrap(new byte[]{12, 10}), map.putMapped(key1, new UnaryOperator<ByteBuffer>() {
|
||||
@Override
|
||||
public ByteBuffer update(ByteBuffer s) {
|
||||
s.put(0, (byte) (s.get(0) + 1));
|
||||
|
||||
@@ -218,13 +218,13 @@ public class ReplicationCheckingMap<K, V> implements ChronicleMap<K, V> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> R mapForKey(K key, @NotNull Function<? super V, R> function) {
|
||||
return map1.mapForKey(key, function);
|
||||
public <R> R getMapped(K key, @NotNull Function<? super V, R> function) {
|
||||
return map1.getMapped(key, function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V putWith(K key, @NotNull Mutator<V> mutator) {
|
||||
return map1.putWith(key, mutator);
|
||||
public V putMapped(K key, @NotNull UnaryOperator<V> unaryOperator) {
|
||||
return map1.putMapped(key, unaryOperator);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -111,7 +111,7 @@ public class StatelessClientTest {
|
||||
.class, StringBuilder.class)
|
||||
.putReturnsNull(true)
|
||||
.statelessClient(new InetSocketAddress("localhost", port)).create()) {
|
||||
String actual = statelessMap.mapForKey(10, ToString.INSTANCE);
|
||||
String actual = statelessMap.getMapped(10, ToString.INSTANCE);
|
||||
|
||||
assertEquals("Hello World", actual);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class StatelessClientTest {
|
||||
try (ChronicleMap<Integer, StringBuilder> statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, StringBuilder.class)
|
||||
.statelessClient(new InetSocketAddress("localhost", port)).create()) {
|
||||
String actual = statelessMap.mapForKey(11, ToString.INSTANCE);
|
||||
String actual = statelessMap.getMapped(11, ToString.INSTANCE);
|
||||
|
||||
assertEquals(null, actual);
|
||||
}
|
||||
|
||||
@@ -170,13 +170,13 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> R mapForKey(K key, @NotNull Function<? super V, R> function) {
|
||||
return d.mapForKey(key, function);
|
||||
public <R> R getMapped(K key, @NotNull Function<? super V, R> function) {
|
||||
return d.getMapped(key, function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V putWith(K key, @NotNull Mutator<V> mutator) {
|
||||
return d.putWith(key, mutator);
|
||||
public V putMapped(K key, @NotNull UnaryOperator<V> unaryOperator) {
|
||||
return d.putMapped(key, unaryOperator);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user