/** * Returns the {@link ExtensionRegistry} listing all known Protocol Buffers extension messages to * {@code T} registered with this {@link ProtoCoder}. */ public ExtensionRegistry getExtensionRegistry() { if (memoizedExtensionRegistry == null) { ExtensionRegistry registry = ExtensionRegistry.newInstance(); for (Class<?> extensionHost : extensionHostClasses) { try { extensionHost .getDeclaredMethod("registerAllExtensions", ExtensionRegistry.class) .invoke(null, registry); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new IllegalStateException(e); } } memoizedExtensionRegistry = registry.getUnmodifiable(); } return memoizedExtensionRegistry; }
/** * Get an unmodifiable {@link ExtensionRegistry} containing all the * extensions of {@code TestAllExtensions}. */ public static ExtensionRegistry getExtensionRegistry() { ExtensionRegistry registry = ExtensionRegistry.newInstance(); registerAllExtensions(registry); return registry.getUnmodifiable(); }