2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.voice.voicerss.internal;
15 import org.hamcrest.Description;
16 import org.hamcrest.Matcher;
17 import org.hamcrest.TypeSafeMatcher;
18 import org.openhab.core.audio.AudioFormat;
21 * Hamcrest {@link Matcher} to assert a compatible {@link AudioFormat}.
23 * @author Andreas Brenk - Initial contribution
25 public class CompatibleAudioFormatMatcher extends TypeSafeMatcher<AudioFormat> {
27 private final AudioFormat audioFormat;
29 public CompatibleAudioFormatMatcher(AudioFormat audioFormat) {
30 this.audioFormat = audioFormat;
34 protected boolean matchesSafely(AudioFormat actual) {
35 return audioFormat.isCompatible(actual);
39 public void describeTo(Description description) {
40 description.appendText("an audio format compatible to ").appendValue(audioFormat);
44 * Creates a matcher that matches when the examined object is
45 * compatible to the specified <code>audioFormat</code>.
47 * @param audioFormat the audio format which must be compatible
49 public static Matcher<AudioFormat> compatibleAudioFormat(AudioFormat audioFormat) {
50 return new CompatibleAudioFormatMatcher(audioFormat);