Skip to content

Commit

Permalink
Implement pair deserialization for eclipse-collections (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
yawkat authored and cowtowncoder committed Oct 31, 2018
1 parent cbb0805 commit e002ec5
Show file tree
Hide file tree
Showing 4 changed files with 578 additions and 4 deletions.
12 changes: 12 additions & 0 deletions eclipse-collections/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@
for v in value_types:
print(" INSTANCES.put("+k+v+"Map.class, "+k.upper()+"_"+v.upper()+");")
print(" }")


print()
print()
print("PairInstantiators:")
for one in value_types:
print(" //region "+one+" -> Primitive")
for two in value_types:
print("""purePrimitiveInstantiator(OneTTwoTPair.class, oneT.class, twoT.class,
(one, two) -> PrimitiveTuples.pair((oneT) one, (twoT) two));"""
.replace("OneT", one).replace("TwoT", two).replace("oneT", one.lower()).replace("twoT", two.lower()))
print(" //endregion")
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.deser.ValueInstantiators;
import com.fasterxml.jackson.datatype.eclipsecollections.deser.pair.PairInstantiators;

/**
* Basic Jackson {@link Module} that adds support for eclipse-collections types.
Expand All @@ -27,6 +29,8 @@ public Version version() {
public void setupModule(SetupContext context) {
context.addDeserializers(new EclipseCollectionsDeserializers());
context.addSerializers(new EclipseCollectionsSerializers());

context.addValueInstantiators(new PairInstantiators());
}

@Override
Expand Down
Loading

0 comments on commit e002ec5

Please sign in to comment.