1 /* Copyright (c) 2000-2006 hamcrest.org 2 */ 3 package org.hamcrest.text; 4 5 import org.hamcrest.Factory; 6 import org.hamcrest.Matcher; 7 8 /** 9 * Tests if the argument is a string that contains a substring. 10 */ 11 public class StringContains extends SubstringMatcher { StringContains(String substring)12 public StringContains(String substring) { 13 super(substring); 14 } 15 evalSubstringOf(String s)16 protected boolean evalSubstringOf(String s) { 17 return s.indexOf(substring) >= 0; 18 } 19 relationship()20 protected String relationship() { 21 return "containing"; 22 } 23 24 @Factory containsString(String substring)25 public static Matcher<String> containsString(String substring) { 26 return new StringContains(substring); 27 } 28 29 }