Inspect the given {@link Class} for any {@link FacetConstraintType#OPTIONAL} dependency {@link Facet} types.
961651
public static <FACETTYPE extends Facet<?>> Set<Class<FACETTYPE>> getOptionalFacets(final Class<?> inspectedType)
   {
      return getRelatedFacets(inspectedType, FacetConstraintType.OPTIONAL);
   }
245110
public static <T extends Annotation> Optional<T> getAnnotation( Class<T> annotation, List<? extends HasAnnotations>
            hasAnnotationsList ) {
        for ( HasAnnotations accessor : hasAnnotationsList ) {
            if ( accessor.isAnnotationPresent( annotation ) ) {
                return Optional.of( accessor.getAnnotation( annotation ) );
            }
        }
        return Optional.absent();
    }
680187
static <FACETEDTYPE extends Faceted<?>, FACETTYPE extends Facet<FACETEDTYPE>> boolean hasCircularConstraints(
            Class<?> inspectedType)
   {
      Set<Class<FACETTYPE>> allRelatedFacets = getAllRelatedFacets(inspectedType);
      for (Class<? extends Facet<?>> requirement : allRelatedFacets)
      {
         for (Class<? extends Facet<?>> subrequirement : getAllRelatedFacets(requirement))
         {
            if (subrequirement.isAssignableFrom(requirement))
               return true;
         }
      }
      return false;
   }
1186123
public static <T extends AnnotationDescription> ElementMatcher.Junction<T> annotationType(Class<? extends Annotation> type) {
        return annotationType(TypeDescription.ForLoadedType.of(type));
    }
768878
@SuppressWarnings("unchecked")
	 Class<?>[] getAllInterfacesAndClasses ( Class<?>[] classes ) 
    {
        if(0 == classes.length ) 
        {
            return classes;
        }
        else 
        {
            List<Class<?>> extendedClasses = new ArrayList<Class<?>>();
            // all interfaces hierarchy
            for (Class<?> clazz: classes) {
            	if (clazz != null) 
            	{
            		Class<?>[] interfaces = clazz.getInterfaces();
	                if (interfaces != null)
	                {
	                	extendedClasses.addAll(Arrays.asList(interfaces));
	                }
	                Class<?> superclass = clazz.getSuperclass();
	                if (superclass != null && superclass != Object.class)
	                {
	                	extendedClasses.addAll(Arrays.asList(superclass));
	                }
            	}
            }
            
            //Class::getInterfaces() gets only interfaces/classes implemented/extended directly by a given class.
            //We need to walk the whole way up the tree.
            return (Class[]) ArrayUtils.addAll( classes, getAllInterfacesAndClasses( extendedClasses.toArray(new Class[extendedClasses.size()])));
        }
    }
255680
@Override
    public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {

        if (!checked) {
            checked = true;
            Collection<TypeQualifierValue<?>> allKnownTypeQualifiers = TypeQualifierValue.getAllKnownTypeQualifiers();
            int size = allKnownTypeQualifiers.size();
            if (size == 1) {
                TypeQualifierValue<?> value = Util.first(allKnownTypeQualifiers);
                if (!value.typeQualifier.getClassName().equals(NONNULL_ANNOTATION)) {
                    shouldRunAnalysis = true;
                }

            } else if (size > 1) {
                shouldRunAnalysis = true;
            }
        }

        if (shouldRunAnalysis) {
            super.visitClass(classDescriptor);
        }
    }
17007
static Class<?> getSetterType(Method setter) {
		Class<?>[] parameterTypes = setter.getParameterTypes();
		if (parameterTypes.length != 1) {
			throw new BeanUtilsException(
					String.format("Method %s has %d parameters and cannot be a setter", setter.getName(), parameterTypes.length));
		}

		return parameterTypes[0];
	}
495799
public static <T extends JUnitWatcher> Optional<T> getAttachedWatcher(Class<T> watcherType) {
        Optional<T> watcher = CreateTest.getAttachedWatcher(watcherType);
        if (watcher.isPresent()) return watcher;
        
        watcher = Run.getAttachedWatcher(watcherType);
        if (watcher.isPresent()) return watcher;
        
        watcher = RunAnnouncer.getAttachedWatcher(watcherType);
        if (watcher.isPresent()) return watcher;
        
        return RunReflectiveCall.getAttachedWatcher(watcherType);
    }
416903
@CheckForNull
    private <T extends BugAnnotation> T findPrimaryAnnotationOfType(Class<T> cls) {
        T firstMatch = null;
        for (Iterator<BugAnnotation> i = annotationIterator(); i.hasNext();) {
            BugAnnotation annotation = i.next();
            if (cls.isAssignableFrom(annotation.getClass())) {
                if (annotation.getDescription().endsWith("DEFAULT")) {
                    return cls.cast(annotation);
                } else if (firstMatch == null) {
                    firstMatch = cls.cast(annotation);
                }
            }
        }
        return firstMatch;
    }
980447
public static Optional<Class<?>> getClassWithAnnotation(final Class<?> source,
        final Class<? extends Annotation> annotationClass) {

        Class<?> nextSource = source;
        while (nextSource != Object.class) {
            if (nextSource.isAnnotationPresent(annotationClass)) {
                return Optional.of(nextSource);
            } else {
                nextSource = nextSource.getSuperclass();
            }
        }

        return Optional.empty();
    }
286562
@SuppressWarnings("unchecked")
	public <T> T getInstance(Class<T> beanClass) {
		String[] beanNames = applicationContext.getBeanNamesForType(beanClass);
		if (beanNames.length == 0) {
			return null;
		}
		return (T) applicationContext.getBean(beanNames[0]);
	}
391164
public static Class<?> classFromAsmType(Type type) {
    Optional<Class<?>> maybeClass = objectTypeToClassCache.getUnchecked(type);
    if (!maybeClass.isPresent()) {
      throw new IllegalArgumentException("Could not load: " + type);
    }
    return maybeClass.get();
  }
242373
public FacesBackingBean getFacesBackingBeanInstance( Class beanClass )
        throws InstantiationException, IllegalAccessException
    {
        assert FacesBackingBean.class.isAssignableFrom( beanClass )
                : "Class " + beanClass.getName() + " does not extend " + FacesBackingBean.class.getName();
        return ( FacesBackingBean ) beanClass.newInstance();
    }
1103259
private static Type[] getGenericInterfaces(Class<?> cls, Class<?> expectedClass,
                                               Class<?> commonBaseCls) {
        if (Object.class == cls) {
            return emptyType;
        }
        Type[] cachedTypes = getTypes(cls, expectedClass, commonBaseCls);
        if (cachedTypes != null)
            return cachedTypes;
        if (expectedClass != null) {
            Type genericSuperType = cls.getGenericSuperclass();
            if (genericSuperType instanceof ParameterizedType) {
                Class<?> actualType = InjectionUtils.getActualType(genericSuperType);
                if (actualType != null && actualType.isAssignableFrom(expectedClass)) {
                    Type[] tempTypes = new Type[] { genericSuperType };
                    putTypes(cls, expectedClass, commonBaseCls, tempTypes);
                    return tempTypes;
                } else if (commonBaseCls != null && commonBaseCls != Object.class 
                           && commonBaseCls.isAssignableFrom(expectedClass)
                           && commonBaseCls.isAssignableFrom(actualType)
                           || expectedClass.isAssignableFrom(actualType)) {
                    putTypes(cls, expectedClass, commonBaseCls, emptyType);
                    return emptyType;
                }
            }
        }
        Type[] types = cls.getGenericInterfaces();
        if (types.length > 0) {
            putTypes(cls, expectedClass, commonBaseCls, types);
            return types;
        }
        Type[] superGenericTypes = getGenericInterfaces(cls.getSuperclass(), expectedClass, commonBaseCls);
        putTypes(cls, expectedClass, commonBaseCls, superGenericTypes);
        return superGenericTypes;
    }
946391
public static <T extends MethodDescription> ElementMatcher.Junction<T> isGetter(Class<?> type) {
        return isGetter(TypeDescription.ForLoadedType.of(type));
    }
451053
@Override
    public <T> T asFacet(Class<T> facetType)
    {
        if (facetType == SpanProvider.class)
        {
            return facetType.cast(new SpanProviderFacet());
        }

        if (facetType == SeekableReader.class && _scanner.isBufferedInput())
        {
            return facetType.cast(new SeekableReaderFacet());
        }

        return super.asFacet(facetType);
    }
1358756
@Override
	protected Set<Class<? extends Annotation>> getSupportedAnnotationClasses() {
		Set<Class<? extends Annotation>> annotations = new LinkedHashSet<Class<? extends Annotation>>();

		annotations.add(BindType.class);
		annotations.add(BindDataSource.class);
		annotations.add(BindDataSourceOptions.class);
		annotations.add(BindSqlType.class);
		annotations.add(BindDao.class);
		annotations.add(BindDaoMany2Many.class);
		annotations.add(BindGeneratedDao.class);

		return annotations;
	}