java_src/src/main/java/com/google/crypto/tink/Registry.java
/**
   * Looks up the globally registered PrimitiveWrapper for this primitive and wraps the given
   * PrimitiveSet with it.
   */
Looks up the globally registered PrimitiveWrapper for this primitive and wraps the given
PrimitiveSet with it.
Looks up the globally registered PrimitiveWrapper for this primitive and wraps the given PrimitiveSet with it .
public static <B, P> P wrap(PrimitiveSet<B> primitiveSet, Class<P> clazz)
      throws GeneralSecurityException {
    @SuppressWarnings("unchecked") 
    PrimitiveWrapper<?, P> wrapper = (PrimitiveWrapper<?, P>) primitiveWrapperMap.get(clazz);
    if (wrapper == null) {
      throw new GeneralSecurityException(
          "No wrapper found for " + primitiveSet.getPrimitiveClass().getName());
    }
    if (!wrapper.getInputPrimitiveClass().equals(primitiveSet.getPrimitiveClass())) {
      throw new GeneralSecurityException(
          "Wrong input primitive class, expected "
              + wrapper.getInputPrimitiveClass()
              + ", got "
              + primitiveSet.getPrimitiveClass());
    }
    @SuppressWarnings("unchecked") 
    P result = ((PrimitiveWrapper<B, P>) wrapper).wrap(primitiveSet);
    return result;
  }
public static < B , P > P wrap ( PrimitiveSet < B > primitiveSet , Class < P > clazz ) throws GeneralSecurityException { @ SuppressWarnings ( "unchecked" ) PrimitiveWrapper < ? , P > wrapper = ( PrimitiveWrapper < ? , P > ) primitiveWrapperMap . get ( clazz ) ; if ( wrapper == null ) { throw new GeneralSecurityException ( "No wrapper found for " + primitiveSet . getPrimitiveClass ( ) . getName ( ) ) ; } if ( ! wrapper . getInputPrimitiveClass ( ) . equals ( primitiveSet . getPrimitiveClass ( ) ) ) { throw new GeneralSecurityException ( "Wrong input primitive class, expected " + wrapper . getInputPrimitiveClass ( ) + ", got " + primitiveSet . getPrimitiveClass ( ) ) ; } @ SuppressWarnings ( "unchecked" ) P result = ( ( PrimitiveWrapper < B , P > ) wrapper ) . wrap ( primitiveSet ) ; return result ; }
Looks up the globally registered PrimitiveWrapper for this primitive and wraps the given
 PrimitiveSet with it.
Looks up the globally registered PrimitiveWrapper for this primitive and wraps the given PrimitiveSet with it .
// We know that we inserted Class<P> -> PrimitiveWrapper<?, P> // We just checked correctness