S
- the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation"
for more details.A
- the type of the "actual" value.public abstract class AbstractCharSequenceAssert<S extends AbstractCharSequenceAssert<S,A>,A extends CharSequence> extends AbstractAssert<S,A> implements EnumerableAssert<S,Character>
CharSequence
s.actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
AbstractCharSequenceAssert(A actual,
Class<?> selfType) |
Modifier and Type | Method and Description |
---|---|
S |
contains(CharSequence... values)
Verifies that the actual
CharSequence contains all the given strings. |
S |
containsIgnoringCase(CharSequence sequence)
Verifies that the actual
CharSequence contains the given sequence, ignoring case considerations. |
S |
containsOnlyOnce(CharSequence sequence)
Verifies that the actual
CharSequence contains only once the given sequence. |
S |
containsSequence(CharSequence... values)
Verifies that the actual
CharSequence contains all the given strings in the given order. |
S |
doesNotContain(CharSequence sequence)
Verifies that the actual
CharSequence does not contain the given sequence. |
S |
doesNotMatch(CharSequence regex)
Verifies that the actual
CharSequence does not match the given regular expression. |
S |
doesNotMatch(Pattern pattern)
Verifies that the actual
CharSequence does not match the given regular expression. |
S |
endsWith(CharSequence suffix)
Verifies that the actual
CharSequence ends with the given suffix. |
S |
hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as given
Iterable . |
S |
hasSameSizeAs(Object[] other)
Verifies that the actual group has the same size as given array.
|
S |
hasSize(int expected)
Verifies that the number of values in the actual group is equal to the given one.
|
void |
isEmpty()
Verifies that the actual group of values is empty.
|
S |
isEqualToIgnoringCase(CharSequence expected)
Verifies that the actual
CharSequence is equal to the given one, ignoring case considerations. |
S |
isNotEmpty()
Verifies that the actual group of values is not empty.
|
void |
isNullOrEmpty()
Verifies that the actual group of values is
null or empty. |
S |
matches(CharSequence regex)
Verifies that the actual
CharSequence matches the given regular expression. |
S |
matches(Pattern pattern)
Verifies that the actual
CharSequence matches the given regular expression. |
S |
startsWith(CharSequence prefix)
Verifies that the actual
CharSequence starts with the given prefix. |
S |
usingComparator(Comparator<? super A> customComparator)
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks.
|
S |
usingDefaultComparator()
Revert to standard comparison for incoming assertion checks.
|
S |
usingDefaultElementComparator()
Deprecated.
Custom element Comparator is not supported for CharSequence comparison.
|
S |
usingElementComparator(Comparator<? super Character> customComparator)
Deprecated.
Custom element Comparator is not supported for CharSequence comparison.
|
as, as, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage
public void isNullOrEmpty()
null
or empty.isNullOrEmpty
in interface EnumerableAssert<S extends AbstractCharSequenceAssert<S,A>,Character>
public void isEmpty()
isEmpty
in interface EnumerableAssert<S extends AbstractCharSequenceAssert<S,A>,Character>
public S isNotEmpty()
isNotEmpty
in interface EnumerableAssert<S extends AbstractCharSequenceAssert<S,A>,Character>
this
assertion object.public S hasSize(int expected)
hasSize
in interface EnumerableAssert<S extends AbstractCharSequenceAssert<S,A>,Character>
expected
- the expected number of values in the actual group.this
assertion object.public S hasSameSizeAs(Object[] other)
hasSameSizeAs
in interface EnumerableAssert<S extends AbstractCharSequenceAssert<S,A>,Character>
other
- the array to compare size with actual group.this
assertion object.public S hasSameSizeAs(Iterable<?> other)
Iterable
.hasSameSizeAs
in interface EnumerableAssert<S extends AbstractCharSequenceAssert<S,A>,Character>
other
- the Iterable
to compare size with actual group.this
assertion object.public S isEqualToIgnoringCase(CharSequence expected)
CharSequence
is equal to the given one, ignoring case considerations.expected
- the given CharSequence
to compare the actual CharSequence
to.this
assertion object.AssertionError
- if the actual CharSequence
is not equal to the given one.public S containsOnlyOnce(CharSequence sequence)
CharSequence
contains only once the given sequence.sequence
- the sequence to search for.this
assertion object.AssertionError
- if the actual CharSequence
does not contain the given one, or contain it multiple times.public S contains(CharSequence... values)
CharSequence
contains all the given strings.
You can use one or several strings as in the example below
assertThat("Gandalf the grey").contains("alf"); assertThat("Gandalf the grey").contains("alf", "grey");
values
- the Strings to look for.this
assertion object.NullPointerException
- if the given values is null
.IllegalArgumentException
- if the given values is empty.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
does not contain all the given strings.public S containsSequence(CharSequence... values)
CharSequence
contains all the given strings in the given order.
Example :
String book = "{ 'title':'A Game of Thrones', 'author':'George Martin'}"; // this assertion succeeds ... assertThat(book).containsSequence("{", "title", "A Game of Thrones", "}"); // ... but this one fails as "author" must come after "A Game of Thrones" assertThat(book).containsSequence("{", "author", "A Game of Thrones", "}");
values
- the Strings to look for in order.this
assertion object.NullPointerException
- if the given values is null
.IllegalArgumentException
- if the given values is empty.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
does not contain all the given strings in the given order.public S containsIgnoringCase(CharSequence sequence)
CharSequence
contains the given sequence, ignoring case considerations.sequence
- the sequence to search for.this
assertion object.NullPointerException
- if the given sequence is null
.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
does not contain the given one.public S doesNotContain(CharSequence sequence)
CharSequence
does not contain the given sequence.sequence
- the sequence to search for.this
assertion object.NullPointerException
- if the given sequence is null
.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
contains the given one.public S startsWith(CharSequence prefix)
CharSequence
starts with the given prefix.prefix
- the given prefix.this
assertion object.NullPointerException
- if the given prefix is null
.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
does not start with the given prefix.public S endsWith(CharSequence suffix)
CharSequence
ends with the given suffix.suffix
- the given suffix.this
assertion object.NullPointerException
- if the given suffix is null
.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
does not end with the given suffix.public S matches(CharSequence regex)
CharSequence
matches the given regular expression.regex
- the regular expression to which the actual CharSequence
is to be matched.this
assertion object.NullPointerException
- if the given pattern is null
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
does not match the given regular expression.public S doesNotMatch(CharSequence regex)
CharSequence
does not match the given regular expression.regex
- the regular expression to which the actual CharSequence
is to be matched.this
assertion object.NullPointerException
- if the given pattern is null
.PatternSyntaxException
- if the regular expression's syntax is invalid.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
matches the given regular expression.public S matches(Pattern pattern)
CharSequence
matches the given regular expression.pattern
- the regular expression to which the actual CharSequence
is to be matched.this
assertion object.NullPointerException
- if the given pattern is null
.AssertionError
- if the actual CharSequence
is null
.AssertionError
- if the actual CharSequence
does not match the given regular expression.public S doesNotMatch(Pattern pattern)
CharSequence
does not match the given regular expression.pattern
- the regular expression to which the actual CharSequence
is to be matched.this
assertion object.NullPointerException
- if the given pattern is null
.AssertionError
- if the actual CharSequence
does not match the given regular expression.@Deprecated public final S usingElementComparator(Comparator<? super Character> customComparator)
usingElementComparator
in interface EnumerableAssert<S extends AbstractCharSequenceAssert<S,A>,Character>
customComparator
- the comparator to use for incoming assertion checks.this
assertion object.UnsupportedOperationException
- if this method is called.@Deprecated public final S usingDefaultElementComparator()
usingDefaultElementComparator
in interface EnumerableAssert<S extends AbstractCharSequenceAssert<S,A>,Character>
this
assertion object.UnsupportedOperationException
- if this method is called.public S usingComparator(Comparator<? super A> customComparator)
AbstractAssert
Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.
Examples :
// frodo and sam are instances of Character with Hobbit race (obviously :). // raceComparator implements Comparator<Character> assertThat(frodo).usingComparator(raceComparator).isEqualTo(sam);
usingComparator
in interface Assert<S extends AbstractCharSequenceAssert<S,A>,A extends CharSequence>
usingComparator
in class AbstractAssert<S extends AbstractCharSequenceAssert<S,A>,A extends CharSequence>
customComparator
- the comparator to use for incoming assertion checks.this
assertion object.public S usingDefaultComparator()
AbstractAssert
This method should be used to disable a custom comparison strategy set by calling Assert.usingComparator(Comparator)
.
usingDefaultComparator
in interface Assert<S extends AbstractCharSequenceAssert<S,A>,A extends CharSequence>
usingDefaultComparator
in class AbstractAssert<S extends AbstractCharSequenceAssert<S,A>,A extends CharSequence>
this
assertion object.Copyright © 2013 AssertJ. All Rights Reserved.