-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9ea56c
commit b4eac54
Showing
3 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/test/java/com/fasterxml/jackson/databind/type/RecursiveType938Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.fasterxml.jackson.databind.type; | ||
|
||
import java.util.*; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
// for [databind#938] | ||
public class RecursiveType938Test extends BaseMapTest | ||
{ | ||
public static interface Ability<T> { } | ||
|
||
public static final class ImmutablePair<L, R> implements Map.Entry<L, R>, Ability<ImmutablePair<L, R>> { | ||
public final L key; | ||
public final R value; | ||
|
||
public ImmutablePair(final L key, final R value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public L getKey() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public R getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public R setValue(final R value) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
static <L, R> ImmutablePair<L, R> of(final L left, final R right) { | ||
return new ImmutablePair<L, R>(left, right); | ||
} | ||
} | ||
|
||
private final ObjectMapper MAPPER = new ObjectMapper(); | ||
|
||
public void testRecursivePair() throws Exception | ||
{ | ||
JavaType t = MAPPER.constructType(ImmutablePair.class); | ||
|
||
assertNotNull(t); | ||
assertEquals(ImmutablePair.class, t.getRawClass()); | ||
|
||
/* | ||
List<ImmutablePair<String, Double>> list = new ArrayList<ImmutablePair<String, Double>>(); | ||
list.add(ImmutablePair.of("Hello World!", 123d)); | ||
String json = MAPPER.writeValueAsString(list); | ||
assertNotNull(json); | ||
*/ | ||
} | ||
} |