Match Conditions
A match condition (defined by a matchConditions
object) lets you refine the
method matching criteria by specifying a match condition based on a parameter or return value
or the value returned by an invoked object.
A match condition is optional, but there can be at most one for the information point. If you do not supply a match condition, the information point includes all invocations of the matched method.
The condition consists of a match type and the comparison operator that defines the data to be compared. The match types are:
- EQUALS
- NOT_EQUALS
- LT
- GT
- LE
- GE
- NOT
- AND
- OR
The comparison operator is an expression node that defines a left side (lhs
)
and a right side (rhs)
of the operation. It contains:
- a type:
ENTITY
,STRING
, orINTEGER
- a value, which is an
entityValue
,stringValue
, orintegerValue
If the type is ENTITY
, the entityValue
has one of the
following types: INVOKED_OBJECT
, RETURN_VALUE
, or
PARAMETER
. If the type of the entityValue
is
PARAMETER
, the parameterIndex
indicates the 0-based
numeric index of the parameter on which to match. So if the method takes two parameters, for
example, the first being a string and second an integer, a parameterIndex
of
0 matches against the string and a parameterIndex
of 1 matches the integer
value.
The information point in the following example only matches invocations of the
processPayment
method in which the second parameter (at parameter index 1)
equals VISA
.
{
"probe": {
"phpDefinition": {
"methodMatch": {
"methodNameCondition": {
"type": "EQUALS",
"matchStrings": [
"processPayment"
]
},
"matchCondition": {
"type": "EQUALS",
"comparisonOp": {
"lhs": {
"type": "ENTITY",
"entityValue": {
"type": "PARAMETER",
"parameterIndex": 1
}
},
"rhs": {
"type": "STRING",
"stringValue": "VISA"
}
}
}
}
}
}
}