Skip to content

Commit

Permalink
remove duplicated @rlp annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Salpadding committed Dec 16, 2019
1 parent e9489c7 commit 39bb1cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# java-rlp

Fast ethereum rlp decode & encode in java.
Fast ethereum rlp encode, decode and object mapping in java.

## Notes

Expand All @@ -26,7 +26,7 @@ Fast ethereum rlp decode & encode in java.

## Examples

- RLP encoding & decoding of POJO.
- RLP object mapping

```java
package org.tdf.rlp;
Expand Down Expand Up @@ -104,14 +104,12 @@ public class Node{

```java
public static class Tree{
@RLP
@RLPDecoding(as = ConcurrentHashMap.class)
/* The decoded type will be java.util.concurrent.ConcurrentHashMap
instead of java.util.HashMap which is the default implementation of java.util.Map. */
public Map<Map<String, Set<String>>, byte[]> tree;

// although ByteArrayMap in ethereumJ is not supported by default, you can enable it by annotation
@RLP(1)
@RLPDecoding(as = ByteArrayMap.class)
public Map<byte[], String> stringMap;
}
Expand Down
19 changes: 1 addition & 18 deletions src/test/java/org/tdf/rlp/RLPTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.lang.reflect.ParameterizedType;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -25,7 +23,6 @@
@RunWith(JUnit4.class)
public class RLPTest {
public static class TestSerializer {
@RLP(0)
public List<String> strings;

public TestSerializer() {
Expand All @@ -37,9 +34,7 @@ public TestSerializer(List<String> strings) {
}

public static class Node {
@RLP(0)
public String name;
@RLP(1)
public List<Node> children;

public Node() {
Expand Down Expand Up @@ -547,7 +542,6 @@ public RLPElement encode(Map<String, String> o) {
}

public static class MapWrapper {
@RLP
@RLPEncoding(MapEncoderDecoder.class)
@RLPDecoding(MapEncoderDecoder.class)
public Map<String, String> map;
Expand Down Expand Up @@ -1211,17 +1205,16 @@ public void testBomb() {
}

private static class Nested {
@RLP
private List<List<List<String>>> nested;

@RLPIgnored
private String hello;

public Nested() {
}
}

private static class NoNested {
@RLP
private List<String> nested;

public NoNested() {
Expand Down Expand Up @@ -1421,7 +1414,6 @@ public void testContainer() throws Exception {
}

public static class MapWrapper2 {
@RLP
@RLPDecoding(as = TreeMap.class)
@RLPEncoding(keyOrdering = StringComparator.class)
public Map<String, Map<String, String>> map = new HashMap<>();
Expand Down Expand Up @@ -1455,7 +1447,6 @@ public void testMapWrapper2() {
}

private static class ByteArraySetWrapper {
@RLP
@RLPDecoding(as = ByteArraySet.class)
@RLPEncoding(keyOrdering = BytesComparator.class)
private Set<byte[]> bytesSet;
Expand Down Expand Up @@ -1498,46 +1489,38 @@ public void testByteArraySet() {
}

private static class ErrorCase {
@RLP
@RLPEncoding(keyOrdering = StringComparator.class)
public List<String> some;
}

private static class ErrorCase1 {
@RLP
@RLPDecoding(as = JUnit4.class)
public long some;
}

private static class ErrorCase2 {
@RLP
@RLPDecoding(as = Map.class)
public long some;
}

private static class ErrorCase3 {
@RLP
@RLPDecoding(as = HashMap.class)
public Set<String> some;
}

private static class ErrorCase4 {
@RLP
public ByteArrayMap<String> some;
}

private static class ErrorCase5 {
@RLP
public ByteArraySet some;
}

private static class ErrorCase6<V> {
@RLP
public Set<V> some;
}

private static class ErrorCase7 {
@RLP
@RLPDecoding(as = AbstractMap.class)
public Map<String, String> some;
}
Expand Down

0 comments on commit 39bb1cb

Please sign in to comment.