1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 6 package org.mockito.internal.matchers; 7 8 import java.io.Serializable; 9 10 import org.hamcrest.Description; 11 import org.mockito.ArgumentMatcher; 12 13 14 public class EndsWith extends ArgumentMatcher<String> implements Serializable { 15 16 private static final long serialVersionUID = 8556443228350129421L; 17 private final String suffix; 18 EndsWith(String suffix)19 public EndsWith(String suffix) { 20 this.suffix = suffix; 21 } 22 matches(Object actual)23 public boolean matches(Object actual) { 24 return actual != null && ((String) actual).endsWith(suffix); 25 } 26 describeTo(Description description)27 public void describeTo(Description description) { 28 description.appendText("endsWith(\"" + suffix + "\")"); 29 } 30 }