Checks that args() of two expressions match.
@param e1 first expression
@param e2 second expression
@return whether their getArgs()'s results match
179757
private static boolean argsMatch(AbstractExpression e1, AbstractExpression e2) {
        final List<AbstractExpression> args1 = e1.getArgs(), args2 = e2.getArgs();
        if (args1 == null || args2 == null) {
            return args1 == args2;
        } else {
            return args1.size() == args2.size() &&
                    IntStream.range(0, args1.size())
                    .mapToObj(index -> (new FilterMatcher(args1.get(index), args2.get(index))).match())
                    .reduce(Boolean::logicalAnd).get();
        }
    }
894041
static boolean hasMatchingToStringPair(Iterable<?> items1, Iterable<?> items2) {
    if (isEmpty(items1) || isEmpty(items2)) {
      return false; // Bail early to avoid calling hashCode() on the elements unnecessarily.
    }
    return !retainMatchingToString(items1, items2).isEmpty();
  }
47412
public static boolean areStringEquals(String string1, String string2) {
		/* string1	string2	outcome
		 * null		null	true
		 * null		x		false
		 * x		null	false
		 * x		y		false
		 * x		x		true
		 */
		// XXX both null must be unequal? If yes, boolean must be too?
		if (string1 == null && string2 == null) {
			return false;
		} else if (string1 != null && !string1.equals(string2)) {
			return false;
		} else if (string2 != null && !string2.equals(string1)) {
			return false;
		}
		return true;
	}
842792
private static boolean expressionsEqual(ExpressionTree expr1, ExpressionTree expr2) {
    if (!expr1.getKind().equals(expr2.getKind())) {
      return false;
    }

    if (!expr1.getKind().equals(Kind.ARRAY_ACCESS)
        && !expr1.getKind().equals(Kind.IDENTIFIER)
        && !(expr1 instanceof LiteralTree)) {
      return false;
    }

    if (expr1.getKind() == Kind.ARRAY_ACCESS) {
      ArrayAccessTree arrayAccessTree1 = (ArrayAccessTree) expr1;
      ArrayAccessTree arrayAccessTree2 = (ArrayAccessTree) expr2;
      return expressionsEqual(arrayAccessTree1.getExpression(), arrayAccessTree2.getExpression())
          && expressionsEqual(arrayAccessTree1.getIndex(), arrayAccessTree2.getIndex());
    }

    if (expr1 instanceof LiteralTree) {
      LiteralTree literalTree1 = (LiteralTree) expr1;
      LiteralTree literalTree2 = (LiteralTree) expr2;
      return literalTree1.getValue().equals(literalTree2.getValue());
    }

    return Objects.equal(ASTHelpers.getSymbol(expr1), ASTHelpers.getSymbol(expr2));
  }
1318439
public List<String> getArgs() {
        List<String> args = new ArrayList<String>();
        getArgs(this.expression, args);

        return args;
    }
971463
public static boolean compareAnnotatedParameters(AnnotatedParameter<?> p1, AnnotatedParameter<?> p2) {
        return compareAnnotatedCallable(p1.getDeclaringCallable(), p2.getDeclaringCallable()) && p1.getPosition() == p2.getPosition() && compareAnnotated(p1, p2);
    }
195587
public static boolean equal(final Throwable ex1, final Throwable ex2) {
        if (ex1 == ex2) {
            return true;
        }
        if (ex1 == null) {
            if (ex2 != null) {
                return false;
            }
        } else if (ex2 == null) {
            if (ex1 != null) {
                return false;
            }
        } else {
            if (ex1.getClass() != ex2.getClass()) {
                return false;
            }
            if (ex1.getMessage() == null) {
                if (ex2.getMessage() != null) {
                    return false;
                }
            } else if (!ex1.getMessage().equals(ex2.getMessage())) {
                return false;
            }
            if (!equal(ex1.getCause(), ex2.getCause())) {
                return false;
            }
        }
        return true;
    }
537695
public static boolean isWellFormed(Expression2 expression) {
    for (int i = 0; i < expression.size; i++) {
      Expression2 subexpression = expression.getSubexpression(i);
      if (subexpression.isConstant() && subexpression.getConstant().equals(LAMBDA)) {
        // lambdas must appear as the first argument of a nested expression.
        int parentIndex = expression.getParentExpressionIndex(i);
        if (parentIndex == -1) {
          return false;
        }

        Expression2 lambdaExpression = expression.getSubexpression(parentIndex);
        List<Expression2> children = lambdaExpression.getSubexpressions();

        // Parent expression must have 3 subexpressions: lambda, argument list, body
        if (children.size() != 3) {
          return false;
        }
        if (children.get(0) != subexpression) {
          return false;
        }

        // Argument list must be an application expression containing only constants
        Expression2 argListExpr = children.get(1);
        if (argListExpr.isConstant()) {
          return false;
        }
        List<Expression2> arguments = argListExpr.getSubexpressions(); 
        for (int j = 0; j < arguments.size(); j++) {
          if (!arguments.get(j).isConstant()) {
            return false;
          }
        }
      }
    }
    return true;
  }
302681
@Override
  public Description matchMethodInvocation(MethodInvocationTree t, VisitorState state) {
    String arg1;
    String arg2;
    if (instanceEqualsMatcher.matches(t, state)) {
      arg1 = state.getSourceForNode(((JCFieldAccess) t.getMethodSelect()).getExpression());
      arg2 = state.getSourceForNode(t.getArguments().get(0));
    } else if (staticEqualsMatcher.matches(t, state)) {
      arg1 = state.getSourceForNode(t.getArguments().get(0));
      arg2 = state.getSourceForNode(t.getArguments().get(1));
    } else {
      return NO_MATCH;
    }

    Fix fix =
        SuggestedFix.builder()
            .replace(t, "Arrays.equals(" + arg1 + ", " + arg2 + ")")
            .addImport("java.util.Arrays")
            .build();
    return describeMatch(t, fix);
  }
40790
public boolean matches(MediaExpression e)
    {
        String fs = e.getFeature();
        boolean isMin = false;
        boolean isMax = false; 
        if (fs.startsWith("min-")) { isMin = true; fs = fs.substring(4); }
        else if (fs.startsWith("max-")) { isMax = true; fs = fs.substring(4); }
        
        Feature feature = getFeatureByName(fs);
        if (feature != null &&  (!(isMin || isMax) || feature.isPrefixed())) //the name (including prefixes) is allowed
        {
            switch (feature)
            {
                case WIDTH:
                    return valueMatches(getExpressionLengthPx(e), width, isMin, isMax);
                case HEIGHT:
                    return valueMatches(getExpressionLengthPx(e), height, isMin, isMax);
                case DEVICE_WIDTH:
                    return valueMatches(getExpressionLengthPx(e), deviceWidth, isMin, isMax);
                case DEVICE_HEIGHT:
                    return valueMatches(getExpressionLengthPx(e), deviceHeight, isMin, isMax);
                case ORIENTATION:
                    String oid = getExpressionIdentifier(e);
                    if (oid == null)
                        return false;
                    else if (oid.equals("portrait"))
                        return isPortrait();
                    else if (oid.equals("landscape"))
                        return !isPortrait();
                    else
                        return false;
                case ASPECT_RATIO:
                    return valueMatches(getExpressionRatio(e), getAspectRatio(), isMin, isMax);
                case DEVICE_ASPECT_RATIO:
                    return valueMatches(getExpressionRatio(e), getDeviceAspectRation(), isMin, isMax);
                case COLOR:
                    return valueMatches(getExpressionInteger(e), color, isMin, isMax);
                case COLOR_INDEX:
                    return valueMatches(getExpressionInteger(e), colorIndex, isMin, isMax);
                case MONOCHROME:
                    return valueMatches(getExpressionInteger(e), monochrome, isMin, isMax);
                case RESOLUTION:
                    return valueMatches(getExpressionResolution(e), resolution, isMin, isMax);
                case SCAN:
                    String sid = getExpressionIdentifier(e);
                    if (sid == null)
                        return false;
                    else if (sid.equals("progressive"))
                        return !scanInterlace;
                    else if (sid.equals("interlace"))
                        return scanInterlace;
                    else
                        return false;
                case GRID:
                    Integer gval = getExpressionInteger(e);
                    if (gval == null)
                        return false;
                    else if (gval == 0 || gval == 1) //0 and 1 are the only allowed values
                        return gval == grid;
                    else
                        return false;
                default:
                    return false;
            }
        }
        else
            return false; //results in "not all" for the whole query
    }
978445
private static boolean revComparisonsMatch(AbstractExpression e1, AbstractExpression e2) {
        return e1 instanceof ComparisonExpression &&
                e1.getExpressionType() == ComparisonExpression.reverses.get(e2.getExpressionType()) &&
                new FilterMatcher(((ComparisonExpression) e1).reverseOperator(), e2).match();
    }
1182635
@Override
    public Predicate like(Expression<String> arg0, String arg1, Expression<Character> arg2)
    {
        // TODO Auto-generated method stub
        return null;
    }
979102
private final static boolean valuesMatch(Object value1, Object value2) {
        if (value1 == null) {
            return value2 == null;
        } else {
            return value1.equals(value2);
        }
    }
421387
protected boolean verifyCondition1(IContextMapping<INode> mapping, IMappingElement<INode> e) {
        return findRelation(IMappingElement.LESS_GENERAL, e.getSource().getAncestors(), e.getTarget(), mapping) ||
                findRelation(IMappingElement.EQUIVALENCE, e.getSource().getAncestors(), e.getTarget(), mapping) ||

                findRelation(IMappingElement.LESS_GENERAL, e.getSource(), e.getTarget().getDescendants(), mapping) ||
                findRelation(IMappingElement.EQUIVALENCE, e.getSource(), e.getTarget().getDescendants(), mapping) ||

                findRelation(IMappingElement.LESS_GENERAL, e.getSource().getAncestors(), e.getTarget().getDescendants(), mapping) ||
                findRelation(IMappingElement.EQUIVALENCE, e.getSource().getAncestors(), e.getTarget().getDescendants(), mapping);
    }
1247374
private static boolean isMatching(Method base, Method compare) {

		// if names and argument types match ... then this are the same method
		if (base.getName().equals(compare.getName()) &&
		    base.getParameterCount() == compare.getParameterCount()) {

			Class<?>[] typeBase = base.getParameterTypes();
			Class<?>[] typeCompare = compare.getParameterTypes();

			for (int index = 0; index < typeBase.length; index++) {
				Class clazzBase = typeBase[index];
				Class clazzCompare = typeCompare[index];
				if (!clazzBase.equals(clazzCompare)) {
					return false;
				}
			}

			return true;
		}

		return false;
	}
44058
private static boolean determineVerbosity(String[] args) {
		if (args != null && args.length > 0) {
            for (String arg : args) {
                if ("-c".equals(arg)) {
                    return false;
                }
            }
		}
		return true;
	}
342491
def args_match(m_args, m_kwargs, default, *args, **kwargs):
    
    if len(m_args) > len(args):
        return False
    for m_arg, arg in zip(m_args, args):
        matches = arg_match(m_arg, arg, eq)
        if not matches or matches is InvalidArg:
            return False  # bail out

    if m_kwargs:
        for name, m_arg in m_kwargs.items():
            name, comparator = arg_comparitor(name)
            arg = kwargs.get(name)
            if not arg_match(m_arg, arg, comparator, default):
                return False  # bail out
    return True