diff --git a/CHANGELOG.md b/CHANGELOG.md index 68f04fea..6a907172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Latest] +## [3.1.0] + +### Added +- UUIDs can now be serialized to representation. ## [3.0.1] @@ -66,7 +70,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release -[Latest]: https://github.com/cryptimeleon/math/compare/v3.0.1...HEAD +[Latest]: https://github.com/cryptimeleon/math/compare/v3.1.0...HEAD +[3.1.0]: https://github.com/cryptimeleon/math/compare/v3.0.0...v3.0.1 [3.0.1]: https://github.com/cryptimeleon/math/compare/v3.0.0...v3.0.1 [3.0.0]: https://github.com/cryptimeleon/math/compare/v2.1.0...v3.0.0 [2.1.0]: https://github.com/cryptimeleon/math/compare/v2.0.0...v2.1.0 diff --git a/build.gradle b/build.gradle index e33ef7f2..329be140 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { group = 'org.cryptimeleon' archivesBaseName = project.name boolean isRelease = project.hasProperty("release") -version = '3.0.3' + (isRelease ? "" : "-SNAPSHOT") +version = '3.1.0' + (isRelease ? "" : "-SNAPSHOT") sourceCompatibility = 1.8 targetCompatibility = 1.8 diff --git a/src/main/java/org/cryptimeleon/math/serialization/annotations/ReprUtil.java b/src/main/java/org/cryptimeleon/math/serialization/annotations/ReprUtil.java index f21d6534..29e00372 100644 --- a/src/main/java/org/cryptimeleon/math/serialization/annotations/ReprUtil.java +++ b/src/main/java/org/cryptimeleon/math/serialization/annotations/ReprUtil.java @@ -58,6 +58,7 @@ * For more information, consult the documentation. */ public class ReprUtil { + static final String[] primitiveTypes = new String[] {"byte", "short", "int", "long", "float", "double", "boolean", "char"}; static Pattern methodCallSeparator = Pattern.compile("::"); /** * Maps representation restorer identifiers to the corresponding {@code RepresentationRestorer} instances. @@ -438,6 +439,9 @@ protected static RepresentationHandler getHandlerWithRestorerString(Type type, S ); } + if (Arrays.asList(primitiveTypes).contains(type.getTypeName())) + throw new IllegalArgumentException("Cannot handle primitive type "+type.getTypeName()+". Use object wrapper types instead (like Integer or Boolean)"); + throw new IllegalArgumentException("Don't know how to handle type " + type.getTypeName() + " using restorer String \"" + restorerString + "\""); } @@ -451,7 +455,6 @@ protected static RepresentationHandler getHandlerWithRestorerString(Type type, S protected static RepresentationHandler getHandlerWithoutRestorerString(Type type) { // For generic type we need to extract the raw type. Only for StandaloneRepresentable though, as stuff // like list and map handling can handle generic types by themselves. - // TODO: What about DependentRepresentations? Type rawType = type; if (type instanceof ParameterizedType) { rawType = ((ParameterizedType) type).getRawType(); @@ -478,8 +481,11 @@ protected static RepresentationHandler getHandlerWithoutRestorerString(Type type return new MapRepresentationHandler(getHandlerWithoutRestorerString(keyType), getHandlerWithoutRestorerString(valueType), type); } + if (Arrays.asList(primitiveTypes).contains(type.getTypeName())) + throw new IllegalArgumentException("Cannot handle primitive type "+type.getTypeName()+". Use object wrapper types instead (like Integer or Boolean)"); + throw new IllegalArgumentException("Don't know how to handle type " + type.getTypeName() - + " using empty restorer String (you can add one within the @Represented annotation)"); + + " using empty restorer String (you can add one within the @Represented annotation to manually specify how to recreate this type)"); } /** diff --git a/src/main/java/org/cryptimeleon/math/serialization/annotations/StandaloneRepresentationHandler.java b/src/main/java/org/cryptimeleon/math/serialization/annotations/StandaloneRepresentationHandler.java index 836a57fb..425fb080 100644 --- a/src/main/java/org/cryptimeleon/math/serialization/annotations/StandaloneRepresentationHandler.java +++ b/src/main/java/org/cryptimeleon/math/serialization/annotations/StandaloneRepresentationHandler.java @@ -5,6 +5,7 @@ import java.lang.reflect.Type; import java.math.BigInteger; +import java.util.UUID; import java.util.function.Function; /** @@ -17,7 +18,7 @@ class StandaloneRepresentationHandler implements RepresentationHandler { // that's not null is already set (and int is auto-initialized with 0) private static final Class[] supportedTypes = new Class[] { StandaloneRepresentable.class, BigInteger.class, Integer.class, String.class, Boolean.class, - byte[].class, Enum.class + byte[].class, UUID.class, Enum.class }; /** * Type of the represented object. @@ -79,6 +80,10 @@ public Object deserializeFromRepresentation(Representation repr, Function