Class Capture
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
Using an instance of this class within a Matcher will capture the matching value.
The as*()
APIs on the instance can be used to get the captured value.
Example:
// Given a template - // { // "Resources": { // "MyBar": { // "Type": "Foo::Bar", // "Properties": { // "Fred": "Flob", // } // }, // "MyBaz": { // "Type": "Foo::Bar", // "Properties": { // "Fred": "Quib", // } // } // } // } Capture fredCapture = new Capture(); template.hasResourceProperties("Foo::Bar", Map.of( "Fred", fredCapture)); fredCapture.asString(); // returns "Flob" fredCapture.next(); // returns true fredCapture.asString();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionasArray()
Retrieve the captured value as an array.Retrieve the captured value as a boolean.asNumber()
Retrieve the captured value as a number.asObject()
Retrieve the captured value as a JSON object.asString()
Retrieve the captured value as a string.getName()
A name for the matcher.next()
When multiple results are captured, move the iterator to the next result.Test whether a target matches the provided pattern.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Capture
protected Capture(software.amazon.jsii.JsiiObjectRef objRef) -
Capture
protected Capture(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Capture
Initialize a new capture.- Parameters:
pattern
- a nested pattern or Matcher.
-
Capture
@Stability(Stable) public Capture()Initialize a new capture.
-
-
Method Details
-
asArray
Retrieve the captured value as an array.An error is generated if no value is captured or if the value is not an array.
-
asBoolean
Retrieve the captured value as a boolean.An error is generated if no value is captured or if the value is not a boolean.
-
asNumber
Retrieve the captured value as a number.An error is generated if no value is captured or if the value is not a number.
-
asObject
Retrieve the captured value as a JSON object.An error is generated if no value is captured or if the value is not an object.
-
asString
Retrieve the captured value as a string.An error is generated if no value is captured or if the value is not a string.
-
next
When multiple results are captured, move the iterator to the next result.- Returns:
- true if another capture is present, false otherwise
-
test
Test whether a target matches the provided pattern.Every Matcher must implement this method. This method will be invoked by the assertions framework. Do not call this method directly.
-
getName
A name for the matcher.This is collected as part of the result and may be presented to the user.
-