@Test public void testCreateInstallHookProcessor() { InternalImportOptions options = new InternalImportOptions(pid, pcl); assertTrue("should be instance of wrapper", options.createInstallHookProcessor() instanceof InternalImportOptions.InstallHookProcessorWrapper); options.setInstallHookPolicy(InstallHookPolicy.SKIP); assertSame("should be noop with skip policy", InternalImportOptions.NOOP_INSTALL_HOOK_PROCESSOR, options.createInstallHookProcessor()); options.setInstallHookPolicy(InstallHookPolicy.DEFAULT); options.setInstallHookProcessorFactoryDelegate(TestInstallHookProcessor::new); assertTrue("should be test processor intance", ((InternalImportOptions.InstallHookProcessorWrapper) options.createInstallHookProcessor()) .wrapped instanceof TestInstallHookProcessor); options.setInstallHookProcessorFactoryDelegate(null); InternalImportOptions optsNoClass = new InternalImportOptions(pid, null, InstallHookProcessor.class); assertSame("should be noop with just processor interface", InternalImportOptions.NOOP_INSTALL_HOOK_PROCESSOR, optsNoClass.createInstallHookProcessor()); }
@Override public InstallHookProcessor createInstallHookProcessor() { if (!isSkip()) { if (installHookProcessorFactoryDelegate != null) { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, installHookProcessorFactoryDelegate.createInstallHookProcessor()); } else if (internalInstallHookProcessorClazz != null) { try { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, internalInstallHookProcessorClazz.newInstance()); } catch (InstantiationException | IllegalAccessException e) { LOGGER.error("failed to create instance of wrapped processor class", e); } } } return NOOP_INSTALL_HOOK_PROCESSOR; }
InternalImportOptions extends ImportOptions implements InstallHookProcessorFactory { @Override public InstallHookProcessor createInstallHookProcessor() { if (!isSkip()) { if (installHookProcessorFactoryDelegate != null) { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, installHookProcessorFactoryDelegate.createInstallHookProcessor()); } else if (internalInstallHookProcessorClazz != null) { try { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, internalInstallHookProcessorClazz.newInstance()); } catch (InstantiationException | IllegalAccessException e) { LOGGER.error("failed to create instance of wrapped processor class", e); } } } return NOOP_INSTALL_HOOK_PROCESSOR; } }
InternalImportOptions extends ImportOptions implements InstallHookProcessorFactory { @Override public InstallHookProcessor createInstallHookProcessor() { if (!isSkip()) { if (installHookProcessorFactoryDelegate != null) { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, installHookProcessorFactoryDelegate.createInstallHookProcessor()); } else if (internalInstallHookProcessorClazz != null) { try { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, internalInstallHookProcessorClazz.newInstance()); } catch (InstantiationException | IllegalAccessException e) { LOGGER.error("failed to create instance of wrapped processor class", e); } } } return NOOP_INSTALL_HOOK_PROCESSOR; } InternalImportOptions(final @NotNull PackageId packageId, final @NotNull ClassLoader implClassLoader);   InternalImportOptions(final @NotNull PackageId packageId,
                          final @Nullable ImportOptions optionsDelegate,
                          final @Nullable Class<? extends InstallHookProcessor> internalInstallHookProcessorClazz); }
InternalImportOptions extends ImportOptions implements InstallHookProcessorFactory { @Override public InstallHookProcessor createInstallHookProcessor() { if (!isSkip()) { if (installHookProcessorFactoryDelegate != null) { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, installHookProcessorFactoryDelegate.createInstallHookProcessor()); } else if (internalInstallHookProcessorClazz != null) { try { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, internalInstallHookProcessorClazz.newInstance()); } catch (InstantiationException | IllegalAccessException e) { LOGGER.error("failed to create instance of wrapped processor class", e); } } } return NOOP_INSTALL_HOOK_PROCESSOR; } InternalImportOptions(final @NotNull PackageId packageId, final @NotNull ClassLoader implClassLoader);   InternalImportOptions(final @NotNull PackageId packageId,
                          final @Nullable ImportOptions optionsDelegate,
                          final @Nullable Class<? extends InstallHookProcessor> internalInstallHookProcessorClazz); @Override InstallHookProcessor createInstallHookProcessor(); @Override ImportOptions copy(); InstallHookProcessorFactory getInstallHookProcessorFactoryDelegate(); void setInstallHookProcessorFactoryDelegate(final InstallHookProcessorFactory installHookProcessorFactoryDelegate); InstallHookPolicy getInstallHookPolicy(); void setInstallHookPolicy(final InstallHookPolicy installHookPolicy); ErrorListener getViolationReporter(); void setViolationReporter(final ErrorListener violationReporter); @Override boolean isStrict(); @Override void setStrict(final boolean strict); @Override ProgressTrackerListener getListener(); @Override void setListener(final ProgressTrackerListener listener); @Override String getPatchParentPath(); @Override void setPatchParentPath(final String patchParentPath); @Override File getPatchDirectory(); @Override void setPatchDirectory(final File patchDirectory); @Override boolean isPatchKeepInRepo(); @Override void setPatchKeepInRepo(final boolean patchKeepInRepo); @Override AccessControlHandling getAccessControlHandling(); @Override void setAccessControlHandling(final AccessControlHandling acHandling); @Override boolean isNonRecursive(); @Override void setNonRecursive(final boolean nonRecursive); @Override Pattern getCndPattern(); @Override void setCndPattern(final String cndPattern); @Override boolean isDryRun(); @Override void setDryRun(final boolean dryRun); @Override void setAutoSaveThreshold(final int threshold); @Override int getAutoSaveThreshold(); @Override ImportMode getImportMode(); @Override void setImportMode(final ImportMode importMode); @Override WorkspaceFilter getFilter(); @Override void setFilter(final WorkspaceFilter filter); @Override ClassLoader getHookClassLoader(); @Override void setHookClassLoader(final ClassLoader hookClassLoader); @Override PathMapping getPathMapping(); @Override void setPathMapping(final PathMapping pathMapping); @Override DependencyHandling getDependencyHandling(); @Override void setDependencyHandling(final DependencyHandling dependencyHandling); }
InternalImportOptions extends ImportOptions implements InstallHookProcessorFactory { @Override public InstallHookProcessor createInstallHookProcessor() { if (!isSkip()) { if (installHookProcessorFactoryDelegate != null) { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, installHookProcessorFactoryDelegate.createInstallHookProcessor()); } else if (internalInstallHookProcessorClazz != null) { try { return new InstallHookProcessorWrapper(packageId, installHookPolicy, violationReporter, internalInstallHookProcessorClazz.newInstance()); } catch (InstantiationException | IllegalAccessException e) { LOGGER.error("failed to create instance of wrapped processor class", e); } } } return NOOP_INSTALL_HOOK_PROCESSOR; } InternalImportOptions(final @NotNull PackageId packageId, final @NotNull ClassLoader implClassLoader);   InternalImportOptions(final @NotNull PackageId packageId,
                          final @Nullable ImportOptions optionsDelegate,
                          final @Nullable Class<? extends InstallHookProcessor> internalInstallHookProcessorClazz); @Override InstallHookProcessor createInstallHookProcessor(); @Override ImportOptions copy(); InstallHookProcessorFactory getInstallHookProcessorFactoryDelegate(); void setInstallHookProcessorFactoryDelegate(final InstallHookProcessorFactory installHookProcessorFactoryDelegate); InstallHookPolicy getInstallHookPolicy(); void setInstallHookPolicy(final InstallHookPolicy installHookPolicy); ErrorListener getViolationReporter(); void setViolationReporter(final ErrorListener violationReporter); @Override boolean isStrict(); @Override void setStrict(final boolean strict); @Override ProgressTrackerListener getListener(); @Override void setListener(final ProgressTrackerListener listener); @Override String getPatchParentPath(); @Override void setPatchParentPath(final String patchParentPath); @Override File getPatchDirectory(); @Override void setPatchDirectory(final File patchDirectory); @Override boolean isPatchKeepInRepo(); @Override void setPatchKeepInRepo(final boolean patchKeepInRepo); @Override AccessControlHandling getAccessControlHandling(); @Override void setAccessControlHandling(final AccessControlHandling acHandling); @Override boolean isNonRecursive(); @Override void setNonRecursive(final boolean nonRecursive); @Override Pattern getCndPattern(); @Override void setCndPattern(final String cndPattern); @Override boolean isDryRun(); @Override void setDryRun(final boolean dryRun); @Override void setAutoSaveThreshold(final int threshold); @Override int getAutoSaveThreshold(); @Override ImportMode getImportMode(); @Override void setImportMode(final ImportMode importMode); @Override WorkspaceFilter getFilter(); @Override void setFilter(final WorkspaceFilter filter); @Override ClassLoader getHookClassLoader(); @Override void setHookClassLoader(final ClassLoader hookClassLoader); @Override PathMapping getPathMapping(); @Override void setPathMapping(final PathMapping pathMapping); @Override DependencyHandling getDependencyHandling(); @Override void setDependencyHandling(final DependencyHandling dependencyHandling);  }