5858 * For more information, consult the <a href="https://upbcuk.github.io/docs/representations.html">documentation</a>.
5959 */
6060public class ReprUtil {
61+ static final String [] primitiveTypes = new String [] {"byte" , "short" , "int" , "long" , "float" , "double" , "boolean" , "char" };
6162 static Pattern methodCallSeparator = Pattern .compile ("::" );
6263 /**
6364 * Maps representation restorer identifiers to the corresponding {@code RepresentationRestorer} instances.
@@ -438,6 +439,9 @@ protected static RepresentationHandler getHandlerWithRestorerString(Type type, S
438439 );
439440 }
440441
442+ if (Arrays .asList (primitiveTypes ).contains (type .getTypeName ()))
443+ throw new IllegalArgumentException ("Cannot handle primitive type " +type .getTypeName ()+". Use object wrapper types instead (like Integer or Boolean)" );
444+
441445 throw new IllegalArgumentException ("Don't know how to handle type " + type .getTypeName ()
442446 + " using restorer String \" " + restorerString + "\" " );
443447 }
@@ -451,7 +455,6 @@ protected static RepresentationHandler getHandlerWithRestorerString(Type type, S
451455 protected static RepresentationHandler getHandlerWithoutRestorerString (Type type ) {
452456 // For generic type we need to extract the raw type. Only for StandaloneRepresentable though, as stuff
453457 // like list and map handling can handle generic types by themselves.
454- // TODO: What about DependentRepresentations?
455458 Type rawType = type ;
456459 if (type instanceof ParameterizedType ) {
457460 rawType = ((ParameterizedType ) type ).getRawType ();
@@ -478,8 +481,11 @@ protected static RepresentationHandler getHandlerWithoutRestorerString(Type type
478481 return new MapRepresentationHandler (getHandlerWithoutRestorerString (keyType ), getHandlerWithoutRestorerString (valueType ), type );
479482 }
480483
484+ if (Arrays .asList (primitiveTypes ).contains (type .getTypeName ()))
485+ throw new IllegalArgumentException ("Cannot handle primitive type " +type .getTypeName ()+". Use object wrapper types instead (like Integer or Boolean)" );
486+
481487 throw new IllegalArgumentException ("Don't know how to handle type " + type .getTypeName ()
482- + " using empty restorer String (you can add one within the @Represented annotation)" );
488+ + " using empty restorer String (you can add one within the @Represented annotation to manually specify how to recreate this type )" );
483489 }
484490
485491 /**
0 commit comments