Top Description Fields Constructors Methods
org.hamcrest.object

public Class IsEventFrom

extends TypeSafeDiagnosingMatcher<EventObject>
Class Inheritance
Imports
org.hamcrest.Description, .Matcher, .TypeSafeDiagnosingMatcher, java.util.EventObject

Tests if the value is an event announced by a specific object.

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final Object

Constructor Summary

AccessConstructor and Description
public
IsEventFrom(Class<?> eventClass, Object source)

Method Summary

Modifier and TypeMethod and Description
public void
describeTo(Description
The description to be built or appended to.
description
)

Implements org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object.
public static Matcher<EventObject>
eventFrom(Class<? extends EventObject>
the class of the event to match on
eventClass
,
Object
the source of the event
source
)

Creates a matcher of java.util.EventObject that matches any object derived from eventClass announced by source.

public static Matcher<EventObject>
eventFrom(Object
the source of the event
source
)

Creates a matcher of java.util.EventObject that matches any EventObject announced by source.

private boolean
public boolean
matchesSafely(EventObject item, Description mismatchDescription)

Implements abstract org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Subclasses should implement this.
Inherited from org.hamcrest.TypeSafeDiagnosingMatcher:
describeMismatchmatches

Field Detail

eventClassback to summary
private final Class<?> eventClass
sourceback to summary
private final Object source

Constructor Detail

IsEventFromback to summary
public IsEventFrom(Class<?> eventClass, Object source)

Method Detail

describeToback to summary
public void describeTo(Description description)

Implements org.hamcrest.SelfDescribing.describeTo.

Doc from org.hamcrest.SelfDescribing.describeTo.

Generates a description of the object. The description may be part of a a description of a larger object of which this is just a component, so it should be worded appropriately.

Parameters
description:Description

The description to be built or appended to.

Annotations
@Override
eventFromback to summary
public static Matcher<EventObject> eventFrom(Class<? extends EventObject> eventClass, Object source)

Creates a matcher of java.util.EventObject that matches any object derived from eventClass announced by source. For example:

assertThat(myEvent, is(eventFrom(PropertyChangeEvent.class, myBean)))
Parameters
eventClass:Class<? extends EventObject>

the class of the event to match on

source:Object

the source of the event

eventFromback to summary
public static Matcher<EventObject> eventFrom(Object source)

Creates a matcher of java.util.EventObject that matches any EventObject announced by source. For example:

assertThat(myEvent, is(eventFrom(myBean)))
Parameters
source:Object

the source of the event

eventHasSameSourceback to summary
private boolean eventHasSameSource(EventObject ev)
matchesSafelyback to summary
public boolean matchesSafely(EventObject item, Description mismatchDescription)

Implements abstract org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Doc from org.hamcrest.TypeSafeDiagnosingMatcher.matchesSafely.

Subclasses should implement this. The item will already have been checked for the specific type and will never be null.

Annotations
@Override