Matches a {@link ModifierReviewable} that is package-private.

@param <T> The type of the matched object.
@return A matcher for a package-private modifier reviewable.
517872
public static <T extends ModifierReviewable.OfByteCodeElement> ElementMatcher.Junction<T> isPackagePrivate() {
        return not(isPublic().or(isProtected()).or(isPrivate()));
    }
198274
public static Matcher<TypeCastTree> typeCast(
      final Matcher<Tree> typeMatcher, final Matcher<ExpressionTree> expressionMatcher) {
    return new Matcher<TypeCastTree>() {
      @Override
      public boolean matches(TypeCastTree t, VisitorState state) {
        return typeMatcher.matches(t.getType(), state)
            && expressionMatcher.matches(t.getExpression(), state);
      }
    };
  }
812277
public static <T extends Executable> Predicate<T> executableModifierIs(final int modifier) {
        return candidate -> (candidate.getModifiers() & modifier) != 0;
    }
1123133
private static Matcher<ExpressionTree> methodReceiverHasType(final Set<String> typeSet) {
    return new Matcher<ExpressionTree>() {
      @Override
      public boolean matches(ExpressionTree expressionTree, VisitorState state) {
        Type receiverType = ASTHelpers.getReceiverType(expressionTree);
        return typeSet.contains(receiverType.toString());
      }
    };
  }
728435
private boolean processModifiers(GroovySourceAST t, SimpleGroovyAbstractableElementDoc memberOrClass) {
        GroovySourceAST modifiers = t.childOfType(MODIFIERS);
        boolean hasNonPublicVisibility = false;
        boolean hasPublicVisibility = false;
        if (modifiers != null) {
            AST currentModifier = modifiers.getFirstChild();
            while (currentModifier != null) {
                int type = currentModifier.getType();
                switch (type) {
                    case LITERAL_public:
                        memberOrClass.setPublic(true);
                        hasPublicVisibility = true;
                        break;
                    case LITERAL_protected:
                        memberOrClass.setProtected(true);
                        hasNonPublicVisibility = true;
                        break;
                    case LITERAL_private:
                        memberOrClass.setPrivate(true);
                        hasNonPublicVisibility = true;
                        break;
                    case LITERAL_static:
                        memberOrClass.setStatic(true);
                        break;
                    case FINAL:
                        memberOrClass.setFinal(true);
                        break;
                    case ABSTRACT:
                        memberOrClass.setAbstract(true);
                        break;
                }
                currentModifier = currentModifier.getNextSibling();
            }
            if (!hasNonPublicVisibility && isGroovy && !(memberOrClass instanceof GroovyFieldDoc)) {
                // in groovy, methods and classes are assumed public, unless informed otherwise
                if (isPackageScope(modifiers)) {
                    memberOrClass.setPackagePrivate(true);
                    hasNonPublicVisibility = true;
                } else {
                    memberOrClass.setPublic(true);
                }
            } else if (!hasNonPublicVisibility && !hasPublicVisibility && !isGroovy) {
                if (insideInterface(memberOrClass) || insideAnnotationDef(memberOrClass)) {
                    memberOrClass.setPublic(true);
                } else {
                    memberOrClass.setPackagePrivate(true);
                }
            }
            if (memberOrClass instanceof GroovyFieldDoc && isGroovy && !hasNonPublicVisibility & !hasPublicVisibility) {
                if (isPackageScope(modifiers)) {
                    memberOrClass.setPackagePrivate(true);
                    hasNonPublicVisibility = true;
                }
            }
            if (memberOrClass instanceof GroovyFieldDoc && !hasNonPublicVisibility && !hasPublicVisibility && isGroovy) return true;
        } else if (isGroovy && !(memberOrClass instanceof GroovyFieldDoc)) {
            // in groovy, methods and classes are assumed public, unless informed otherwise
            memberOrClass.setPublic(true);
        } else if (!isGroovy) {
            if (insideInterface(memberOrClass) || insideAnnotationDef(memberOrClass)) {
                memberOrClass.setPublic(true);
            } else {
                memberOrClass.setPackagePrivate(true);
            }
        }
        return memberOrClass instanceof GroovyFieldDoc && isGroovy && !hasNonPublicVisibility & !hasPublicVisibility;
    }
1326041
@Deprecated
    public static <T> CombinableEitherMatcher<T> either(Matcher<? super T> matcher) {
        return CoreMatchers.either(matcher);
    }
655872
@Requires("modifier != null")
  @Ensures("getModifiers().contains(modifier)")
  public void addModifier(ElementModifier modifier) {
    switch (modifier) {
      case PRIVATE:
      case PACKAGE_PRIVATE:
      case PROTECTED:
      case PUBLIC:
        modifiers.remove(ElementModifier.PRIVATE);
        modifiers.remove(ElementModifier.PACKAGE_PRIVATE);
        modifiers.remove(ElementModifier.PROTECTED);
        modifiers.remove(ElementModifier.PUBLIC);
    }
    modifiers.add(modifier);
  }
129891
public static Set<Class<?>> scanPackageByAnnotation(String packageName, final Class<? extends Annotation> annotationClass) {
		return scanPackage(packageName, new Filter<Class<?>>() {
			@Override
			public boolean accept(Class<?> clazz) {
				return clazz.isAnnotationPresent(annotationClass);
			}
		});
	}
1333215
public static <T extends Tree, V extends Tree> Matcher<T> contains(
      Class<V> clazz, Matcher<V> treeMatcher) {
    final Matcher<Tree> contains = new Contains(toType(clazz, treeMatcher));
    return contains::matches;
  }
576572
Optional<ExecutableElement> findSetterMethodFor(Element field) {
        String name = field.getSimpleName().toString();
        if (field.asType().getKind() == TypeKind.BOOLEAN) {
            if (name.length() > 2 && Character.isUpperCase(name.charAt(2))) {
                name = name.replaceFirst("^(is)(.+)", "$2");
            }
        }
        String setterName = setterNameFor(name);
        // FIXME refine this to discover one of possible overloaded methods with correct signature (i.e. single arg of field type)
        TypeElement typeElement = classElementFor(field);
        if (typeElement == null) {
            return Optional.empty();
        }

        List<? extends Element> elements = typeElement.getEnclosedElements();
        List<ExecutableElement> methods = ElementFilter.methodsIn(elements);
        return methods.stream()
            .filter(method -> {
                String methodName = method.getSimpleName().toString();
                if (setterName.equals(methodName)) {
                    Set<Modifier> modifiers = method.getModifiers();
                    return
                        // it's not static
                        !modifiers.contains(STATIC)
                            // it's either public or package visibility
                            && modifiers.contains(PUBLIC)
                            || !(modifiers.contains(PRIVATE) || modifiers.contains(PROTECTED));
                }
                return false;
            })
            .findFirst();
    }
45620
public static <S> Matcher<S> is(Matcher<S> matcher) {
        return Matchers.is(matcher);
    }
1028591
public static <T extends Tree> Matcher<T> isPrimitiveType() {
    return new Matcher<T>() {
      @Override
      public boolean matches(Tree t, VisitorState state) {
        Type type = getType(t);
        return type != null && type.isPrimitive();
      }
    };
  }
219780
public static <T extends ModifierReviewable.OfByteCodeElement> ElementMatcher.Junction<T> isStatic() {
        return new ModifierMatcher<T>(ModifierMatcher.Mode.STATIC);
    }
638282
public static <T extends Tree> Matcher<T> packageStartsWith(String prefix) {
    return (tree, state) -> getPackageFullName(state).startsWith(prefix);
  }
665188
public static <T extends Tree> Matcher<T> isVoidType() {
    return new Matcher<T>() {
      @Override
      public boolean matches(T t, VisitorState state) {
        Type type = getType(t);
        return type != null && state.getTypes().isSameType(type, state.getSymtab().voidType);
      }
    };
  }
842885
public static <T extends Tree> Matcher<T> isArrayType() {
    return new Matcher<T>() {
      @Override
      public boolean matches(Tree t, VisitorState state) {
        Type type = getType(t);
        return type != null && state.getTypes().isArray(type);
      }
    };
  }
680565
function getPackageConfigMatch(loader, normalized) {
    var pkgName, exactMatch = false, configPath;
    for (var i = 0; i < loader.packageConfigPaths.length; i++) {
      var packageConfigPath = loader.packageConfigPaths[i];
      var p = packageConfigPaths[packageConfigPath] || (packageConfigPaths[packageConfigPath] = createPkgConfigPathObj(packageConfigPath));
      if (normalized.length < p.length)
        continue;
      var match = normalized.match(p.regEx);
      if (match && (!pkgName || (!(exactMatch && p.wildcard) && pkgName.length < match[1].length))) {
        pkgName = match[1];
        exactMatch = !p.wildcard;
        configPath = pkgName + packageConfigPath.substr(p.length);
      }
    }

    if (!pkgName)
      return;

    return {
      packageName: pkgName,
      configPath: configPath
    };
  }