/*
 * #%L
 * wcm.io
 * %%
 * Copyright (C) 2020 wcm.io
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package io.wcm.qa.glnm.hamcrest;

import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;


/**
 * <p>Abstract TypeSafeWrappingMatcher class.</p>
 *
 * @since 5.0.0
 */
public abstract class TypeSafeWrappingMatcher<T, I> extends TypeSafeMatcher<T> {

  private Matcher<I> internalMatcher;

  protected TypeSafeWrappingMatcher(Matcher<I> matcher) {
    setInternalMatcher(matcher);
  }

  /** {@inheritDoc} */
  @Override
  public void describeTo(Description description) {
    getInternalMatcher().describeTo(description);
  }

  @Override
  protected void describeMismatchSafely(T item, Description mismatchDescription) {
    getInternalMatcher().describeMismatch(map(item), mismatchDescription);
  }

  protected Matcher<I> getInternalMatcher() {
    return internalMatcher;
  }

  protected abstract I map(T item);

  @Override
  protected boolean matchesSafely(T item) {
    return getInternalMatcher().matches(map(item));
  }

  protected void setInternalMatcher(Matcher<I> internalMatcher) {
    this.internalMatcher = internalMatcher;
  }

}

@@ -882,17 +882,17 @@
 cher%3CT, 
-I
+M
 %3E extend
@@ -925,33 +925,33 @@
 private Matcher%3C
-I
+M
 %3E internalMatche
@@ -998,17 +998,17 @@
 Matcher%3C
-I
+M
 %3E matche
@@ -1387,17 +1387,17 @@
 Matcher%3C
-I
+M
 %3E getInt
@@ -1467,17 +1467,17 @@
 bstract 
-I
+M
  map(T i
@@ -1640,17 +1640,17 @@
 Matcher%3C
-I
+M
 %3E intern

use M for matcher