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

com.objogate.wl.swing.matcher.JLabelTextMatcher Maven / Gradle / Ivy

The newest version!
package com.objogate.wl.swing.matcher;

import static org.hamcrest.Matchers.equalTo;

import javax.swing.JLabel;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

public class JLabelTextMatcher extends TypeSafeMatcher {
    private final Matcher matcher;

    public JLabelTextMatcher(Matcher matcher) {
        this.matcher = matcher;
    }

    @Override
    public boolean matchesSafely(JLabel label) {
        return matcher.matches(label.getText());
    }

    public void describeTo(Description description) {
        description.appendText("with text ")
                .appendDescriptionOf(matcher);
    }

    public static JLabelTextMatcher withLabelText(String text) {
      return withLabelText(equalTo(text));
    }

    public static JLabelTextMatcher withLabelText(Matcher text) {
        return new JLabelTextMatcher(text);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy