package ch.bbv.timemanagement.touch.matchers;

import ch.bbv.timemanagement.touch.Move;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

import static ch.bbv.timemanagement.util.validation.Validate.validateThat;
import static org.hamcrest.Matchers.notNullValue;

/**
 * Matches the {@code sinAngle} property of a {@link Move}.
 */
public class SinAngleMatcher extends TypeSafeMatcher<Move> {

  private final Matcher<? super Float> delegate;

  public SinAngleMatcher(final Matcher<? super Float> delegate) {
    validateThat(delegate, notNullValue());
    this.delegate = delegate;
  }

  @Override
  protected boolean matchesSafely(final Move move) {
    return delegate.matches(move.sinAngle());
  }

  @Override
  public void describeTo(final Description description) {
    description.appendText("sinAngle ").appendDescriptionOf(delegate);
  }
}