org.skyscreamer.jsonassert
Class RegularExpressionValueMatcher<T>

java.lang.Object
  extended by org.skyscreamer.jsonassert.RegularExpressionValueMatcher<T>
All Implemented Interfaces:
ValueMatcher<T>

public class RegularExpressionValueMatcher<T>
extends Object
implements ValueMatcher<T>

A JSONassert value matcher that matches actual value to regular expression. If non-null regular expression passed to constructor, then all actual values will be compared against this constant pattern, ignoring any expected value passed to equal method. If null regular expression passed to constructor, then expected value passed to equals method will be used to dynamically specify regular expression pattern that actual value must match.

Author:
Duncan Mackinder

Constructor Summary
RegularExpressionValueMatcher()
          Create RegularExpressionValueMatcher in which the pattern the actual value must match with be specified dynamically from the expected string passed to this matcher in the equals method.
RegularExpressionValueMatcher(String pattern)
          Create RegularExpressionValueMatcher with specified pattern.
 
Method Summary
 boolean equal(T actual, T expected)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegularExpressionValueMatcher

public RegularExpressionValueMatcher()
Create RegularExpressionValueMatcher in which the pattern the actual value must match with be specified dynamically from the expected string passed to this matcher in the equals method.


RegularExpressionValueMatcher

public RegularExpressionValueMatcher(String pattern)
                              throws IllegalArgumentException
Create RegularExpressionValueMatcher with specified pattern. If pattern is not null, it must be a valid regular expression that defines a constant expected pattern that every actual value must match (in this case the expected value passed to equal method will be ignored). If pattern is null, the pattern the actual value must match with be specified dynamically from the expected string passed to this matcher in the equals method.

Parameters:
pattern - if non null, regular expression pattern which all actual values this matcher is applied to must match. If null, this matcher will apply pattern specified dynamically via the expected parameter to the equal method.
Throws:
IllegalArgumentException - if pattern is non-null and not a valid regular expression.
Method Detail

equal

public boolean equal(T actual,
                     T expected)
Specified by:
equal in interface ValueMatcher<T>


Copyright © 2014. All Rights Reserved.