/*
(non-Javadoc)

@see
edu.umd.cs.findbugs.plan.DetectorFactorySelector#selectFactory(edu.umd
.cs.findbugs.DetectorFactory)
345118
@Override
    public boolean selectFactory(DetectorFactory factory) {
        return (plugin == null || plugin == factory.getPlugin()) && factory.isReportingDetector();
    }
620385
public static Type[] getEnvironmentRepositoryFactoryTypeParams(
			ConfigurableListableBeanFactory beanFactory, String factoryName) {
		MethodMetadata methodMetadata = (MethodMetadata) beanFactory
				.getBeanDefinition(factoryName).getSource();
		Class<?> factoryClass = null;
		try {
			factoryClass = Class.forName(methodMetadata.getReturnTypeName());
		}
		catch (ClassNotFoundException e) {
			throw new IllegalStateException(e);
		}
		Optional<AnnotatedType> annotatedFactoryType = Arrays
				.stream(factoryClass.getAnnotatedInterfaces()).filter(i -> {
					ParameterizedType parameterizedType = (ParameterizedType) i.getType();
					return parameterizedType.getRawType()
							.equals(EnvironmentRepositoryFactory.class);
				}).findFirst();
		ParameterizedType factoryParameterizedType = (ParameterizedType) annotatedFactoryType
				.orElse(factoryClass.getAnnotatedSuperclass()).getType();
		return factoryParameterizedType.getActualTypeArguments();
	}
845521
public void addSelections(Class<?> selectionType) {
		List<Field> fields = JpaHelper.listFields(selectionType);
		for (Field field : fields) {
			if (field.getName().equals("serialVersionUID"))
				continue;
			if (type != null && JpaHelper.findField(type, field.getName()) != null) {
				if (JpaHelper.findField(type, field.getName()).getType().equals(field.getType())) {
					this.selections.add(field.getName());
				}
			}
		}
	}
1233328
public DetectorFactory getFactoryByShortName(final String shortName) {
        return findFirstMatchingFactory(factory -> factory.getShortName().equals(shortName));
    }
1287202
static Optional<AnnotatedBeanFactory<?>> find(@Nullable BeanFactoryId beanFactoryId) {
        if (beanFactoryId == null) {
            return Optional.empty();
        }
        final AnnotatedBeanFactory<?> factory = factories.get(beanFactoryId);
        return factory != null && factory != unsupportedBeanFactory ? Optional.of(factory)
                                                                    : Optional.empty();
    }
530556
private static LogFactory detectLogFactory() {
        LogFactory logFactory;
        try {
            logFactory = new Slf4jLogFactory(true);
            logFactory.getLog(LogFactory.class).debug("Use [{}] Logger As Default.", logFactory.logFramworkName);
        } catch (Throwable e) {
            try {
                logFactory = new Log4jLogFactory();
                logFactory.getLog(LogFactory.class).debug("Use [{}] Logger As Default.", logFactory.logFramworkName);
            } catch (Throwable e2) {
                try {
                    logFactory = new Log4j2LogFactory();
                    logFactory.getLog(LogFactory.class).debug("Use [{}] Logger As Default.", logFactory.logFramworkName);
                } catch (Throwable e3) {
                    try {
                        logFactory = new JdkLogFactory();
                        logFactory.getLog(LogFactory.class).debug("Use [{}] Logger As Default.", logFactory.logFramworkName);
                    } catch (Throwable e5) {
                        logFactory = new ConsoleLogFactory();
                        logFactory.getLog(LogFactory.class).debug("Use [{}] Logger As Default.", logFactory.logFramworkName);
                    }
                }
            }
        }

        return logFactory;
    }
428011
private static <T> ServiceBindingBuilder<T> newFactoryBinder(final Factory<T> factory) {
        return BindingBuilderFactory.newFactoryBinder(factory);
    }
1149786
@Nullable
  CompiledTemplate.Factory selectDelTemplate(
      String delTemplateName, String variant, Predicate<String> activeDelPackageSelector) {
    TemplateData selectedTemplate =
        selector.selectTemplate(delTemplateName, variant, activeDelPackageSelector);
    if (selectedTemplate == null) {
      return null;
    }
    if (selectedTemplate.factory == null) {
      throw new IllegalArgumentException(
          "cannot get a factory for the private template: " + selectedTemplate.soyTemplateName());
    }
    return selectedTemplate.factory;
  }
1294601
public void setConnectionFactory(XAConnectionFactory connectionFactory) {
		this.connectionFactory = connectionFactory;
		setClassName(DirectXAConnectionFactory.class.getName());
		setDriverProperties(new Properties());
	}
603545
public void removeFactory(FileSetProvider factory) {
		if (logger.isLoggable(Level.FINER)) {
			logger.finer("Removing factory: " + factory);
		}
		filters.remove(factory);
	}
1018753
public static void applyXXEProtection(DocumentBuilderFactory factory) {
		Map<String, Boolean> features = new HashMap<String, Boolean>();
		features.put("http://apache.org/xml/features/disallow-doctype-decl", true);
		features.put("http://xml.org/sax/features/external-general-entities", false);
		features.put("http://xml.org/sax/features/external-parameter-entities", false);
		features.put("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

		for (Map.Entry<String, Boolean> entry : features.entrySet()) {
			String feature = entry.getKey();
			Boolean value = entry.getValue();
			try {
				factory.setFeature(feature, value);
			} catch (ParserConfigurationException e) {
				//feature is not supported by the local XML engine, skip it
			}
		}

		factory.setXIncludeAware(false);
		factory.setExpandEntityReferences(false);
	}
74881
@SuppressWarnings("static-method")
	public IJavaElement getSelectedResource(IStructuredSelection selection) {
		IJavaElement elem = null;
		if (selection != null && !selection.isEmpty()) {
			final Object object = selection.getFirstElement();
			if (object instanceof IAdaptable) {
				final IAdaptable adaptable = (IAdaptable) object;
				elem = adaptable.getAdapter(IJavaElement.class);
				if (elem == null) {
					elem = getPackage(adaptable);
				}
			}
		}
		if (elem == null) {
			final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
			IWorkbenchPart part = activePage.getActivePart();
			if (part instanceof ContentOutline) {
				part = activePage.getActiveEditor();
			}
			if (part instanceof XtextEditor) {
				final IXtextDocument doc = ((XtextEditor) part).getDocument();
				final IFile file = doc.getAdapter(IFile.class);
				elem = getPackage(file);
			}
		}
		if (elem == null || elem.getElementType() == IJavaElement.JAVA_MODEL) {
			try {
				final IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
				if (projects.length == 1) {
					elem = projects[0];
				}
			} catch (JavaModelException e) {
				throw new RuntimeException(e.getMessage());
			}
		}
		return elem;
	}
1248466
@Override
    public void setConstraintValidatorFactory(Configuration<?> apiConfig) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "setConstraintValidatorFactory", apiConfig);
        }
        Class<? extends ConstraintValidatorFactory> clazz = null;
        ConstraintValidatorFactory cvf = null;
        if (constraintValidatorFactory != null) {

            try {
                clazz = loadClass(constraintValidatorFactory).asSubclass(ConstraintValidatorFactory.class);
                cvf = instantiateClass(clazz);
            } catch (Throwable t) {
                FFDCFilter.processException(t, CLASS_NAME + ".setConstraintValidatorFactory", "313");
                // message and exception printed out in previous method called.
                // however since we can not create a validation factory throw validationException
                ValidationException e = new ValidationException(t);
                throw e;
            }
        }

        if (cvf != null) {
            apiConfig.constraintValidatorFactory(cvf);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "setConstraintValidatorFactory", cvf);
        }
    }
528565
@Reference(cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC)
	public void addFactory(FileSetProvider factory) {
		if (logger.isLoggable(Level.FINER)) {
			logger.finer("Adding factory: " + factory);
		}
		filters.add(factory);
	}
988964
public static <T> T find(Class<T> factoryClass, Descriptor descriptor) {
		Preconditions.checkNotNull(descriptor);
		return findInternal(factoryClass, descriptor.toProperties(), Optional.empty());
	}
1024804
public SheetMapperFactory getterFactory(GetterFactory<Row, CsvColumnKey> getterFactory) {
        return super.addGetterFactory(new ContextualGetterFactoryAdapter<Row, CsvColumnKey>(getterFactory));
    }
84758
@Deprecated
    public static ValidatorFactory getValidatorFactory()
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "getValidatorFactory");

        ValidatorFactory validatorFactory = AbstractBeanValidation.getValidatorFactory();

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "getValidatorFactory: " + Util.identity(validatorFactory));

        return validatorFactory;
    }