java_src/src/main/java/com/google/crypto/tink/Registry.java
/**
   * Tries to register {@code wrapper} as a new SetWrapper for primitive {@code P}.
   *
   * <p>If no SetWrapper is registered for {@code P}, registers the given one. If there already is a
   * SetWrapper registered which is of the same class ass the passed in set wrapper, the call is
   * silently ignored. If the new set wrapper is of a different type, the call fails with a {@code
   * GeneralSecurityException}.
   *
   * @throws GeneralSecurityException if there's an existing key manager and it is not an instance
   *     of the class of {@code manager}, or the registration tries to re-enable the generation of
   *     new keys.
   */
Tries to register  wrapper as a new SetWrapper for primitive  P.
If no SetWrapper is registered for  P, registers the given one. If there already is a
SetWrapper registered which is of the same class ass the passed in set wrapper, the call is
silently ignored. If the new set wrapper is of a different type, the call fails with a {@code
GeneralSecurityException}.

@throws GeneralSecurityException if there's an existing key manager and it is not an instance
of the class of  manager, or the registration tries to re-enable the generation of
new keys.
Tries to register wrapper as a new SetWrapper for primitive P . If no SetWrapper is registered for P registers the given one . If there already is a SetWrapper registered which is of the same class ass the passed in set wrapper the call is silently ignored . If the new set wrapper is of a different type the call fails with a { @code GeneralSecurityException } . @throws GeneralSecurityException if there ' s an existing key manager and it is not an instance of the class of manager or the registration tries to re - enable the generation of new keys .
public static synchronized <B, P> void registerPrimitiveWrapper(
      final PrimitiveWrapper<B, P> wrapper) throws GeneralSecurityException {
    if (wrapper == null) {
      throw new IllegalArgumentException("wrapper must be non-null");
    }
    Class<P> classObject = wrapper.getPrimitiveClass();
    if (primitiveWrapperMap.containsKey(classObject)) {
      @SuppressWarnings("unchecked") 
      PrimitiveWrapper<?, P> existingWrapper =
          (PrimitiveWrapper<?, P>) primitiveWrapperMap.get(classObject);
      if (!wrapper.getClass().getName().equals(existingWrapper.getClass().getName())) {
        logger.warning(
            "Attempted overwrite of a registered PrimitiveWrapper for type " + classObject);
        throw new GeneralSecurityException(
            String.format(
                "PrimitiveWrapper for primitive (%s) is already registered to be %s, "
                    + "cannot be re-registered with %s",
                classObject.getName(),
                existingWrapper.getClass().getName(),
                wrapper.getClass().getName()));
      }
    }
    primitiveWrapperMap.put(classObject, wrapper);
  }
public static synchronized < B , P > void registerPrimitiveWrapper ( final PrimitiveWrapper < B , P > wrapper ) throws GeneralSecurityException { if ( wrapper == null ) { throw new IllegalArgumentException ( "wrapper must be non-null" ) ; } Class < P > classObject = wrapper . getPrimitiveClass ( ) ; if ( primitiveWrapperMap . containsKey ( classObject ) ) { @ SuppressWarnings ( "unchecked" ) PrimitiveWrapper < ? , P > existingWrapper = ( PrimitiveWrapper < ? , P > ) primitiveWrapperMap . get ( classObject ) ; if ( ! wrapper . getClass ( ) . getName ( ) . equals ( existingWrapper . getClass ( ) . getName ( ) ) ) { logger . warning ( "Attempted overwrite of a registered PrimitiveWrapper for type " + classObject ) ; throw new GeneralSecurityException ( String . format ( "PrimitiveWrapper for primitive (%s) is already registered to be %s, " + "cannot be re-registered with %s" , classObject . getName ( ) , existingWrapper . getClass ( ) . getName ( ) , wrapper . getClass ( ) . getName ( ) ) ) ; } } primitiveWrapperMap . put ( classObject , wrapper ) ; }
Tries to register {@code wrapper} as a new SetWrapper for primitive {@code P}.
Tries to register { @code wrapper } as a new SetWrapper for primitive { @code P } .
// We know that we only inserted objects of the correct type.