Class ConstructorConstructor.ThrowingObjectConstructor<T>

java.lang.Object
com.google.gson.internal.ConstructorConstructor.ThrowingObjectConstructor<T>
All Implemented Interfaces:
ObjectConstructor<T>
Enclosing class:
ConstructorConstructor

private static final class ConstructorConstructor.ThrowingObjectConstructor<T> extends Object implements ObjectConstructor<T>
ObjectConstructor which always throws an exception.

This keeps backward compatibility, compared to using a null ObjectConstructor, which would then choose another way of creating the object. And it supports types which are only serialized but not deserialized (compared to directly throwing an exception when the ObjectConstructor is requested), e.g. when the runtime type of an object is inaccessible, but the compile-time type is accessible.

  • Field Details

    • exceptionMessage

      private final String exceptionMessage
  • Constructor Details

    • ThrowingObjectConstructor

      ThrowingObjectConstructor(String exceptionMessage)
  • Method Details