Top Constructors Methods
org.hamcrest.text

public Class CharSequenceLength

extends FeatureMatcher<CharSequence, Integer>
Class Inheritance
Imports
org.hamcrest.FeatureMatcher, .Matcher

Authors
Marco Leichsenring, Steve Freeman

Constructor Summary

AccessConstructor and Description
public
CharSequenceLength(Matcher<? super Integer>
The matcher to apply to the feature
lengthMatcher
)

Method Summary

Modifier and TypeMethod and Description
protected Integer
featureValueOf(CharSequence
the target object
actual
)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.
public static Matcher<CharSequence>
hasLength(int
the expected length of the string
length
)

Creates a matcher of CharSequence that matches when a char sequence has the given length For example:

assertThat("text", hasLength(4))
public static Matcher<CharSequence>
hasLength(Matcher<? super Integer>
the expected length of the string
lengthMatcher
)

Creates a matcher of CharSequence that matches when a char sequence has the given length For example:

assertThat("text", hasLength(lessThan(4)))
Inherited from org.hamcrest.FeatureMatcher:
describeTomatchesSafely

Constructor Detail

CharSequenceLengthback to summary
public CharSequenceLength(Matcher<? super Integer> lengthMatcher)
Parameters
lengthMatcher:Matcher<? super Integer>

The matcher to apply to the feature

Annotations
@SuppressWarnings:WeakerAccess

Method Detail

featureValueOfback to summary
protected Integer featureValueOf(CharSequence actual)

Implements abstract org.hamcrest.FeatureMatcher.featureValueOf.

Doc from org.hamcrest.FeatureMatcher.featureValueOf.

Implement this to extract the interesting feature.

Parameters
actual:CharSequence

the target object

Returns:Integer

the feature to be matched

Annotations
@Override
hasLengthback to summary
public static Matcher<CharSequence> hasLength(int length)

Creates a matcher of CharSequence that matches when a char sequence has the given length For example:

assertThat("text", hasLength(4))
Parameters
length:int

the expected length of the string

hasLengthback to summary
public static Matcher<CharSequence> hasLength(Matcher<? super Integer> lengthMatcher)

Creates a matcher of CharSequence that matches when a char sequence has the given length For example:

assertThat("text", hasLength(lessThan(4)))
Parameters
lengthMatcher:Matcher<? super Integer>

the expected length of the string

Annotations
@SuppressWarnings:WeakerAccess