All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hamcrest.core.IsSame Maven / Gradle / Ivy

There is a newer version: 2.0.2-beta
Show newest version
/*  Copyright (c) 2000-2006 hamcrest.org
 */
package org.hamcrest.core;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.Factory;
import org.hamcrest.BaseMatcher;


/**
 * Is the value the same object as another value?
 */
public class IsSame extends BaseMatcher {
    private final T object;

    public IsSame(T object) {
        this.object = object;
    }

    public boolean matches(Object arg) {
        return arg == object;
    }

    public void describeTo(Description description) {
        description.appendText("same(") .appendValue(object) .appendText(")");
    }

    /**
     * Creates a new instance of IsSame
     *
     * @param object The predicate evaluates to true only when the argument is
     *               this object.
     */
    @Factory
    public static  Matcher sameInstance(T object) {
        return new IsSame(object);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy