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