KeyTypeManager { public KeyFactory<?, KeyProtoT> keyFactory() { throw new UnsupportedOperationException("Creating keys is not supported."); } @SafeVarargs // Safe because we do not reference the array (see Effective Java ed. 3, Item 32). protected  KeyTypeManager(Class<KeyProtoT> clazz, PrimitiveFactory<?, KeyProtoT>... factories); final Class<KeyProtoT> getKeyClass(); abstract String getKeyType(); abstract int getVersion(); abstract KeyMaterialType keyMaterialType(); abstract KeyProtoT parseKey(ByteString byteString); abstract void validateKey(KeyProtoT keyProto); final P getPrimitive(KeyProtoT key, Class<P> primitiveClass); final Set<Class<?>> supportedPrimitives(); KeyFactory<?, KeyProtoT> keyFactory();  }
@Test public void keyFactory_throwsUnsupported() throws Exception { KeyTypeManager<AesGcmKey> keyManager = new TestKeyTypeManager(); try { keyManager.keyFactory(); fail(); } catch (UnsupportedOperationException e) { } }