Class StringSubject


  • public class StringSubject
    extends ComparableSubject<String>
    Propositions for string subjects.
    Author:
    David Saff, Christian Gruber (cgruber@israfil.net)
    • Constructor Detail

      • StringSubject

        protected StringSubject​(FailureMetadata metadata,
                                @Nullable String string)
        Constructor for use by subclasses. If you want to create an instance of this class itself, call check(...).that(actual).
    • Method Detail

      • hasLength

        public void hasLength​(int expectedLength)
        Fails if the string does not have the given length.
      • isEmpty

        public void isEmpty()
        Fails if the string is not equal to the zero-length "empty string."
      • isNotEmpty

        public void isNotEmpty()
        Fails if the string is equal to the zero-length "empty string."
      • contains

        public void contains​(@Nullable CharSequence string)
        Fails if the string does not contain the given sequence.
      • doesNotContain

        public void doesNotContain​(@Nullable CharSequence string)
        Fails if the string contains the given sequence.
      • startsWith

        public void startsWith​(@Nullable String string)
        Fails if the string does not start with the given string.
      • endsWith

        public void endsWith​(@Nullable String string)
        Fails if the string does not end with the given string.
      • matches

        public void matches​(@Nullable String regex)
        Fails if the string does not match the given regex.
      • matches

        @GwtIncompatible("java.util.regex.Pattern")
        public void matches​(@Nullable Pattern regex)
        Fails if the string does not match the given regex.
      • doesNotMatch

        public void doesNotMatch​(@Nullable String regex)
        Fails if the string matches the given regex.
      • doesNotMatch

        @GwtIncompatible("java.util.regex.Pattern")
        public void doesNotMatch​(@Nullable Pattern regex)
        Fails if the string matches the given regex.
      • containsMatch

        @GwtIncompatible("java.util.regex.Pattern")
        public void containsMatch​(@Nullable Pattern regex)
        Fails if the string does not contain a match on the given regex.
      • containsMatch

        public void containsMatch​(@Nullable String regex)
        Fails if the string does not contain a match on the given regex.
      • doesNotContainMatch

        @GwtIncompatible("java.util.regex.Pattern")
        public void doesNotContainMatch​(@Nullable Pattern regex)
        Fails if the string contains a match on the given regex.
      • doesNotContainMatch

        public void doesNotContainMatch​(@Nullable String regex)
        Fails if the string contains a match on the given regex.