Skip to content

Commit

Permalink
Update juniper, add the one new class.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyettinger committed Sep 9, 2022
1 parent 7bb7434 commit f48e23e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 59 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ org.gradle.configureondemand=false
SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true

digitalVersion=0.1.0
juniperVersion=0.1.2
jdkgdxdsVersion=1.0.3
digitalVersion=0.1.2
juniperVersion=0.1.4
jdkgdxdsVersion=1.0.4
gdxVersion=1.11.0

GROUP=com.github.tommyettinger
POM_ARTIFACT_ID=jdkgdxds_interop
VERSION_NAME=1.0.3.3
VERSION_NAME=1.0.4.0-SNAPSHOT

POM_NAME=jdkgdxds_interop
POM_DESCRIPTION=Inter-operate between libGDX and jdkgdxds.
Expand Down
79 changes: 24 additions & 55 deletions src/main/java/com/github/tommyettinger/ds/interop/JsonSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,7 @@
import com.badlogic.gdx.utils.reflect.ReflectionException;
import com.github.tommyettinger.digital.Base;
import com.github.tommyettinger.digital.Hasher;
import com.github.tommyettinger.ds.BinaryHeap;
import com.github.tommyettinger.ds.BooleanDeque;
import com.github.tommyettinger.ds.BooleanList;
import com.github.tommyettinger.ds.ByteDeque;
import com.github.tommyettinger.ds.ByteList;
import com.github.tommyettinger.ds.CaseInsensitiveMap;
import com.github.tommyettinger.ds.CaseInsensitiveOrderedMap;
import com.github.tommyettinger.ds.CaseInsensitiveOrderedSet;
import com.github.tommyettinger.ds.CaseInsensitiveSet;
import com.github.tommyettinger.ds.CharDeque;
import com.github.tommyettinger.ds.CharList;
import com.github.tommyettinger.ds.DoubleDeque;
import com.github.tommyettinger.ds.DoubleList;
import com.github.tommyettinger.ds.FloatDeque;
import com.github.tommyettinger.ds.FloatList;
import com.github.tommyettinger.ds.IdentityObjectMap;
import com.github.tommyettinger.ds.IntDeque;
import com.github.tommyettinger.ds.IntFloatMap;
import com.github.tommyettinger.ds.IntFloatOrderedMap;
import com.github.tommyettinger.ds.IntIntMap;
import com.github.tommyettinger.ds.IntIntOrderedMap;
import com.github.tommyettinger.ds.IntList;
import com.github.tommyettinger.ds.IntLongMap;
import com.github.tommyettinger.ds.IntLongOrderedMap;
import com.github.tommyettinger.ds.IntObjectMap;
import com.github.tommyettinger.ds.IntObjectOrderedMap;
import com.github.tommyettinger.ds.IntOrderedSet;
import com.github.tommyettinger.ds.IntSet;
import com.github.tommyettinger.ds.LongDeque;
import com.github.tommyettinger.ds.LongFloatMap;
import com.github.tommyettinger.ds.LongFloatOrderedMap;
import com.github.tommyettinger.ds.LongIntMap;
import com.github.tommyettinger.ds.LongIntOrderedMap;
import com.github.tommyettinger.ds.LongList;
import com.github.tommyettinger.ds.LongLongMap;
import com.github.tommyettinger.ds.LongLongOrderedMap;
import com.github.tommyettinger.ds.LongObjectMap;
import com.github.tommyettinger.ds.LongObjectOrderedMap;
import com.github.tommyettinger.ds.LongOrderedSet;
import com.github.tommyettinger.ds.LongSet;
import com.github.tommyettinger.ds.NumberedSet;
import com.github.tommyettinger.ds.ObjectDeque;
import com.github.tommyettinger.ds.ObjectFloatMap;
import com.github.tommyettinger.ds.ObjectFloatOrderedMap;
import com.github.tommyettinger.ds.ObjectIntMap;
import com.github.tommyettinger.ds.ObjectIntOrderedMap;
import com.github.tommyettinger.ds.ObjectList;
import com.github.tommyettinger.ds.ObjectLongMap;
import com.github.tommyettinger.ds.ObjectLongOrderedMap;
import com.github.tommyettinger.ds.ObjectObjectMap;
import com.github.tommyettinger.ds.ObjectObjectOrderedMap;
import com.github.tommyettinger.ds.ObjectOrderedSet;
import com.github.tommyettinger.ds.ObjectSet;
import com.github.tommyettinger.ds.ShortDeque;
import com.github.tommyettinger.ds.ShortList;
import com.github.tommyettinger.ds.*;
import com.github.tommyettinger.ds.support.util.BooleanIterator;
import com.github.tommyettinger.ds.support.util.ByteIterator;
import com.github.tommyettinger.ds.support.util.CharIterator;
Expand Down Expand Up @@ -2383,6 +2329,28 @@ public LogNormalDistribution read(Json json, JsonValue jsonData, Class type) {
});
}

/**
* Registers LumpDistribution with the given Json object, so LumpDistribution can be written to and read from JSON.
*
* @param json a libGDX Json object that will have a serializer registered
*/
public static void registerLumpDistribution(@Nonnull Json json) {
json.addClassTag("Lump", LumpDistribution.class);
json.setSerializer(LumpDistribution.class, new Json.Serializer<LumpDistribution>() {
@Override
public void write(Json json, LumpDistribution object, Class knownType) {
json.writeValue(object.stringSerialize(BASE));
}

@Override
public LumpDistribution read(Json json, JsonValue jsonData, Class type) {
LumpDistribution r = new LumpDistribution();
r.stringDeserialize(jsonData.asString(), BASE);
return r;
}
});
}

/**
* Registers NormalDistribution with the given Json object, so NormalDistribution can be written to and read from JSON.
*
Expand Down Expand Up @@ -2612,6 +2580,7 @@ public static void registerDistribution(@Nonnull Json json) {
registerLogCauchyDistribution(json);
registerLogisticDistribution(json);
registerLogNormalDistribution(json);
registerLumpDistribution(json);
registerNormalDistribution(json);
registerParetoDistribution(json);
registerPoissonDistribution(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,21 @@ public void testLogNormalDistribution() {
Assert.assertEquals(dist.nextDouble(), dist2.nextDouble(), 0.0);
}

@Test
public void testLumpDistribution() {
JsonSupport.setNumeralBase(Base.scrambledBase(new DistinctRandom()));
//JsonSupport.setNumeralBase(Base.BASE16);
Json json = new Json(JsonWriter.OutputType.minimal);
JsonSupport.registerLumpDistribution(json);
LumpDistribution dist = new LumpDistribution(new DistinctRandom(123456789), 0.0, 0.25);
dist.nextDouble();
String data = json.toJson(dist);
System.out.println(data);
LumpDistribution dist2 = json.fromJson(LumpDistribution.class, data);
System.out.println(JsonSupport.getNumeralBase().unsigned(dist2.generator.getSelectedState(0)));
Assert.assertEquals(dist.nextDouble(), dist2.nextDouble(), 0.0);
}

@Test
public void testNormalDistribution() {
JsonSupport.setNumeralBase(Base.scrambledBase(new DistinctRandom()));
Expand Down

0 comments on commit f48e23e

Please sign in to comment.