public class StringsCompare extends Object
Useful for testing when you have an expected file as a resource, say, and need to compare it to output of some execution.
| Modifier and Type | Field and Description |
|---|---|
static Function<String,String> |
DEFAULT_OPERATION
Default operation is to remove trailing whitespace before compare.
|
static Function<String,String> |
IDENT
Ident transform, use when you want no mapping done on strings.
|
static Function<String,String> |
LOWER_CASE
Mapping transform to lowercase a string, allowing for case insensitive
compares.
|
static Predicate<String> |
SKIP_BLANK
Predicate to skip whitespace only lines.
|
static Predicate<String> |
SKIP_EMPTY
Predicate to skip empty lines.
|
static Predicate<String> |
SKIP_NONE
Predicate to skip no lines.
|
static Function<String,String> |
TRIM_LEADING_AND_TRAILING_WHITESPACE
Mapping transform to trim leading and trailing whitespace.
|
static Function<String,String> |
TRIM_LEADING_WHITESPACE
Mapping transform to remove leading whitespace.
|
static Function<String,String> |
TRIM_TRAILING_WHITESPACE
Mapping transform to remove trailing whitespace.
|
| Modifier and Type | Method and Description |
|---|---|
static org.sfj.StringsCompare.LineSource |
source(Class<?> clz,
String name)
Source from a resource stream, UTF-8 charset.
|
static org.sfj.StringsCompare.LineSource |
source(Class<?> clz,
String name,
Charset cset)
Source from a resource stream, specified charset
|
static org.sfj.StringsCompare.LineSource |
source(File f)
Source from a file using UTF8 charset encoding.
|
static org.sfj.StringsCompare.LineSource |
source(File f,
Charset cSet)
Source from a file using specified encoding.
|
static org.sfj.StringsCompare.LineSource |
source(InputStream is)
Source from an input stream, using UTF-8 encoding.
|
static org.sfj.StringsCompare.LineSource |
source(InputStream is,
Charset cset)
Source from an input stream using a specific char set.
|
static org.sfj.StringsCompare.LineSource |
source(Iterable<String> iter)
Source from an iterable.
|
static org.sfj.StringsCompare.LineSource |
source(Iterator<String> iter)
Source from an arbitrary iterator.
|
static org.sfj.StringsCompare.LineSource |
source(Reader r)
Source for a reader.
|
static org.sfj.StringsCompare.LineSource |
source(String s)
Source from a string.
|
static org.sfj.StringsCompare.LineSource |
source(String[] arr)
Source from an array of strings.
|
static org.sfj.StringsCompare.LineSource |
source(String[] arr,
int pos,
int len)
Source from an array of strings.
|
static boolean |
stringsCompare(org.sfj.StringsCompare.LineSource left,
org.sfj.StringsCompare.LineSource right)
Compare two
LineSource objects using the default operation. |
static boolean |
stringsCompare(org.sfj.StringsCompare.LineSource left,
org.sfj.StringsCompare.LineSource right,
Function<String,String> mapper)
Compare with no skipping filter but the specified mapper.
|
static boolean |
stringsCompare(org.sfj.StringsCompare.LineSource left,
org.sfj.StringsCompare.LineSource right,
Predicate<String> filter)
Compare with a specified skipping predicate and the default mapping.
|
static boolean |
stringsCompare(org.sfj.StringsCompare.LineSource left,
org.sfj.StringsCompare.LineSource right,
Predicate<String> filter,
Function<String,String> mapper)
Compare two
LineSource objects using a specified operation. |
public static final Function<String,String> IDENT
public static final Function<String,String> TRIM_LEADING_WHITESPACE
public static final Function<String,String> TRIM_TRAILING_WHITESPACE
public static final Function<String,String> LOWER_CASE
public static final Function<String,String> TRIM_LEADING_AND_TRAILING_WHITESPACE
public static boolean stringsCompare(org.sfj.StringsCompare.LineSource left,
org.sfj.StringsCompare.LineSource right)
throws IOException
LineSource objects using the default operation.left - one side.right - the other.IOException - on exceptionpublic static boolean stringsCompare(org.sfj.StringsCompare.LineSource left,
org.sfj.StringsCompare.LineSource right,
Predicate<String> filter)
throws IOException
left - left sourceright - right source.filter - filter to use to skip linesIOException - on exceptionpublic static boolean stringsCompare(org.sfj.StringsCompare.LineSource left,
org.sfj.StringsCompare.LineSource right,
Function<String,String> mapper)
throws IOException
left - left sourceright - right sourcemapper - mapper per line.IOException - on exceptionpublic static boolean stringsCompare(org.sfj.StringsCompare.LineSource left,
org.sfj.StringsCompare.LineSource right,
Predicate<String> filter,
Function<String,String> mapper)
throws IOException
LineSource objects using a specified operation. Note that any
Function operation can be changed to make compound operations.left - left sourceright - right sourcefilter - predicate to designate lines to skipmapper - mapper per line.IOException - on exceptionpublic static org.sfj.StringsCompare.LineSource source(Reader r) throws IOException
r - reader to draw fromIOException - on underlying exceptionpublic static org.sfj.StringsCompare.LineSource source(String s) throws IOException
s - String to useIOException - on exceptionpublic static org.sfj.StringsCompare.LineSource source(InputStream is) throws IOException
is - input streamIOException - on exceptionpublic static org.sfj.StringsCompare.LineSource source(InputStream is, Charset cset) throws IOException
is - input streamcset - charset encodingIOException - on exceptionpublic static org.sfj.StringsCompare.LineSource source(Class<?> clz, String name) throws IOException
clz - class to use for getResourceAsStream()name - name to openIOException - on exceptionpublic static org.sfj.StringsCompare.LineSource source(Class<?> clz, String name, Charset cset) throws IOException
clz - class to usename - name to use for resourcecset - charset encoding to use.IOException - on exceptionpublic static org.sfj.StringsCompare.LineSource source(String[] arr)
arr - array of stringspublic static org.sfj.StringsCompare.LineSource source(String[] arr, int pos, int len)
arr - array of stringspos - position of first entry to uselen - number of entries to usepublic static org.sfj.StringsCompare.LineSource source(Iterator<String> iter)
iter - base iteratorpublic static org.sfj.StringsCompare.LineSource source(Iterable<String> iter)
iter - iterablepublic static org.sfj.StringsCompare.LineSource source(File f) throws IOException
f - file to openIOException - on exceptionpublic static org.sfj.StringsCompare.LineSource source(File f, Charset cSet) throws IOException
f - filecSet - charsetIOException - on exceptionCopyright © 2020. All rights reserved.