use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.NotMatcherOperator in project pinpoint by naver.
the class TransformerMatcherExecutionPlanner method traversal.
// find indexed operands.
private boolean traversal(final MatcherOperand operand, final List<MatcherOperand> index) {
if (!operand.isOperator()) {
if (operand.isIndex()) {
index.add(operand);
return true;
}
return false;
}
if (operand instanceof NotMatcherOperator) {
// skip NOT operator.
return false;
}
MatcherOperator operator = (MatcherOperator) operand;
final MatcherOperand leftOperand = operator.getLeftOperand();
if (leftOperand == null) {
throw new IllegalArgumentException("invalid left operand - left operand must not be null. operator=" + operator);
}
final MatcherOperand rightOperand = operator.getRightOperand();
if (rightOperand == null) {
throw new IllegalArgumentException("invalid right operand - right operand must not be null. operator=" + operator);
}
if (operand instanceof AndMatcherOperator) {
// if find any.
final boolean indexed = traversal(leftOperand, index);
if (indexed) {
return true;
}
return traversal(rightOperand, index);
} else if (operand instanceof OrMatcherOperator) {
// find all.
final boolean indexed = traversal(leftOperand, index);
return traversal(rightOperand, index) || indexed;
} else {
throw new IllegalArgumentException("unknown operator. operator=" + operand);
}
}
use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.NotMatcherOperator in project pinpoint by naver.
the class DefaultTransformerMatcher method traversal.
boolean traversal(ClassLoader classLoader, MatcherOperand operand, InternalClassMetadata classMetadata) {
if (operand instanceof NotMatcherOperator) {
NotMatcherOperator operator = (NotMatcherOperator) operand;
if (operator.getRightOperand() == null) {
throw new IllegalArgumentException("invalid operator - not found right operand. operator=" + operator);
}
final MatcherOperand rightOperand = operator.getRightOperand();
// NOT
return match(classLoader, rightOperand, classMetadata) == false;
}
MatcherOperator operator = (MatcherOperator) operand;
// for binary operator.
if (operator.getLeftOperand() == null) {
throw new IllegalArgumentException("invalid operator - not found left operand. operator=" + operator);
}
final MatcherOperand leftOperand = operator.getLeftOperand();
if (operator.getRightOperand() == null) {
throw new IllegalArgumentException("invalid operator - not found right operand. operator=" + operator);
}
final MatcherOperand rightOperand = operator.getRightOperand();
MatcherOperand firstOperand = leftOperand;
MatcherOperand secondOperand = rightOperand;
if (leftOperand.getExecutionCost() > rightOperand.getExecutionCost()) {
// cost-based execution plan.
firstOperand = rightOperand;
secondOperand = leftOperand;
}
if (operand instanceof OrMatcherOperator) {
// OR
if (match(classLoader, firstOperand, classMetadata)) {
return true;
}
return match(classLoader, secondOperand, classMetadata);
} else if (operand instanceof AndMatcherOperator) {
// AND
if (match(classLoader, firstOperand, classMetadata)) {
return match(classLoader, secondOperand, classMetadata);
}
return false;
} else {
throw new IllegalArgumentException("unknown operator. operator=" + operator);
}
}
use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.NotMatcherOperator in project pinpoint by naver.
the class AbstractMatcherOperandTest method not.
@Test
public void not() {
MatcherOperand operand = new ClassInternalNameMatcherOperand("java/lang/String");
operand = operand.not();
assertTrue(operand instanceof NotMatcherOperator);
NotMatcherOperator operator = (NotMatcherOperator) operand;
assertTrue(operator.getRightOperand() instanceof ClassInternalNameMatcherOperand);
}
Aggregations