extensions/servlet/src/com/google/inject/servlet/ServletScopes.java
private static Object validateAndCanonicalizeValue(Key<?> key, Object object) {
    if (object == null || object == NullObject.INSTANCE) {
      return NullObject.INSTANCE;
    }

    if (!key.getTypeLiteral().getRawType().isInstance(object)) {
      throw new IllegalArgumentException(
          "Value["
              + object
              + "] of type["
              + object.getClass().getName()
              + "] is not compatible with key["
              + key
              + "]");
    }

    return object;
  }
private static Object validateAndCanonicalizeValue(Key<?> key, Object object) {
    if (object == null || object == NullObject.INSTANCE) {
      return NullObject.INSTANCE;
    }

    if (!key.getTypeLiteral().getRawType().isInstance(object)) {
      throw new IllegalArgumentException(
          "Value["
              + object
              + "] of type["
              + object.getClass().getName()
              + "] is not compatible with key["
              + key
              + "]");
    }

    return object;
  }
private static Object validateAndCanonicalizeValue ( Key < ? > key , Object object ) { if ( object == null || object == NullObject . INSTANCE ) { return NullObject . INSTANCE ; } if ( ! key . getTypeLiteral ( ) . getRawType ( ) . isInstance ( object ) ) { throw new IllegalArgumentException ( "Value[" + object + "] of type[" + object . getClass ( ) . getName ( ) + "] is not compatible with key[" + key + "]" ) ; } return object ; }
Validates the key and object, ensuring the value matches the key type, and canonicalizing null
objects to the null sentinel.
Validates the key and object ensuring the value matches the key type and canonicalizing null objects to the null sentinel .