package org.hamcrest.core;

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

import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsInstanceOf.instanceOf;

/**
 * Decorates another Matcher, retaining the behavior but allowing tests
 * to be slightly more expressive.
 *
 * For example:  assertThat(cheese, equalTo(smelly))
 *          vs.  assertThat(cheese, is(equalTo(smelly)))
 */
public class Is<T> extends BaseMatcher<T> {
    private final Matcher<T> matcher;

    public Is(Matcher<T> matcher) {
        this.matcher = matcher;
    }

    @Override
    public boolean matches(Object arg) {
        return matcher.matches(arg);
    }

    @Override
    public void describeTo(Description description) {
        description.appendText("is ").appendDescriptionOf(matcher);
    }

    @Override
    public void describeMismatch(Object item, Description mismatchDescription) {
        matcher.describeMismatch(item, mismatchDescription);
    }

    /**
     * Decorates another Matcher, retaining the behavior but allowing tests
     * to be slightly more expressive.
     *
     * For example:  assertThat(cheese, equalTo(smelly))
     *          vs.  assertThat(cheese, is(equalTo(smelly)))
     */
    @Factory
    public static <T> Matcher<T> is(Matcher<T> matcher) {
        return new Is<T>(matcher);
    }

    /**
     * This is a shortcut to the frequently used is(equalTo(x)).
     *
     * For example:  assertThat(cheese, is(equalTo(smelly)))
     *          vs.  assertThat(cheese, is(smelly))
     */
    @Factory
    public static <T> Matcher<T> is(T value) {
        return is(equalTo(value));
    }

    /**
     * This is a shortcut to the frequently used is(instanceOf(SomeClass.class)).
     *
     * For example:  assertThat(cheese, is(instanceOf(Cheddar.class)))
     *          vs.  assertThat(cheese, is(Cheddar.class))
     *
     * @deprecated use isA(Class<T> type) instead.
     */
    @Factory
    @Deprecated
    public static <T> Matcher<T> is(Class<T> type) {
        final Matcher<T> typeMatcher = instanceOf(type);
        return is(typeMatcher);
    }

    /**
     * A shortcut for the frequently used is(instanceOf(SomeClass.class)).
     *
     * For example:  assertThat(cheese, is(instanceOf(Cheddar.class)))
     *          vs.  assertThat(cheese, isA(Cheddar.class))
     */
    @Factory
    public static <T> Matcher<T> isA(Class<T> type) {
        final Matcher<T> typeMatcher = instanceOf(type);
        return is(typeMatcher);
    }
}

@@ -300,32 +300,33 @@
 ning the behavio
+u
 r but allowing t
@@ -1097,27 +1097,27 @@
 taining 
-the
+its
  behavio
 r but al
@@ -1108,17 +1108,19 @@
  behavio
-r
+ur,
  but all
@@ -1427,33 +1427,25 @@
  /**%0A     * 
-This is a
+A
  shortcut to
@@ -1730,17 +1730,9 @@
   * 
-This is a
+A
  sho

correct spelling error in Javadoc.