org.apache.flink.cep.pattern.conditions.SubtypeCondition Java Examples

The following examples show how to use org.apache.flink.cep.pattern.conditions.SubtypeCondition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PatternTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testPatternWithSubtyping() {
	Pattern<Event, ?> pattern = Pattern.<Event>begin("start").next("subevent").subtype(SubEvent.class).followedBy("end");

	Pattern<Event, ?> previous;
	Pattern<Event, ?> previous2;

	assertNotNull(previous = pattern.getPrevious());
	assertNotNull(previous2 = previous.getPrevious());
	assertNull(previous2.getPrevious());

	assertNotNull(previous.getCondition());
	assertTrue(previous.getCondition() instanceof SubtypeCondition);

	assertEquals(pattern.getName(), "end");
	assertEquals(previous.getName(), "subevent");
	assertEquals(previous2.getName(), "start");
}
 
Example #2
Source File: PatternTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPatternWithSubtyping() {
	Pattern<Event, ?> pattern = Pattern.<Event>begin("start").next("subevent").subtype(SubEvent.class).followedBy("end");

	Pattern<Event, ?> previous;
	Pattern<Event, ?> previous2;

	assertNotNull(previous = pattern.getPrevious());
	assertNotNull(previous2 = previous.getPrevious());
	assertNull(previous2.getPrevious());

	assertNotNull(previous.getCondition());
	assertTrue(previous.getCondition() instanceof SubtypeCondition);

	assertEquals(pattern.getName(), "end");
	assertEquals(previous.getName(), "subevent");
	assertEquals(previous2.getName(), "start");
}
 
Example #3
Source File: PatternTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testPatternWithSubtyping() {
	Pattern<Event, ?> pattern = Pattern.<Event>begin("start").next("subevent").subtype(SubEvent.class).followedBy("end");

	Pattern<Event, ?> previous;
	Pattern<Event, ?> previous2;

	assertNotNull(previous = pattern.getPrevious());
	assertNotNull(previous2 = previous.getPrevious());
	assertNull(previous2.getPrevious());

	assertNotNull(previous.getCondition());
	assertTrue(previous.getCondition() instanceof SubtypeCondition);

	assertEquals(pattern.getName(), "end");
	assertEquals(previous.getName(), "subevent");
	assertEquals(previous2.getName(), "start");
}
 
Example #4
Source File: Pattern.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Applies a subtype constraint on the current pattern. This means that an event has
 * to be of the given subtype in order to be matched.
 *
 * @param subtypeClass Class of the subtype
 * @param <S> Type of the subtype
 * @return The same pattern with the new subtype constraint
 */
public <S extends F> Pattern<T, S> subtype(final Class<S> subtypeClass) {
	Preconditions.checkNotNull(subtypeClass, "The class cannot be null.");

	if (condition == null) {
		this.condition = new SubtypeCondition<F>(subtypeClass);
	} else {
		this.condition = new RichAndCondition<>(condition, new SubtypeCondition<F>(subtypeClass));
	}

	@SuppressWarnings("unchecked")
	Pattern<T, S> result = (Pattern<T, S>) this;

	return result;
}
 
Example #5
Source File: Pattern.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Applies a subtype constraint on the current pattern. This means that an event has
 * to be of the given subtype in order to be matched.
 *
 * @param subtypeClass Class of the subtype
 * @param <S> Type of the subtype
 * @return The same pattern with the new subtype constraint
 */
public <S extends F> Pattern<T, S> subtype(final Class<S> subtypeClass) {
	Preconditions.checkNotNull(subtypeClass, "The class cannot be null.");

	if (condition == null) {
		this.condition = new SubtypeCondition<F>(subtypeClass);
	} else {
		this.condition = new RichAndCondition<>(condition, new SubtypeCondition<F>(subtypeClass));
	}

	@SuppressWarnings("unchecked")
	Pattern<T, S> result = (Pattern<T, S>) this;

	return result;
}
 
Example #6
Source File: Pattern.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Applies a subtype constraint on the current pattern. This means that an event has
 * to be of the given subtype in order to be matched.
 *
 * @param subtypeClass Class of the subtype
 * @param <S> Type of the subtype
 * @return The same pattern with the new subtype constraint
 */
public <S extends F> Pattern<T, S> subtype(final Class<S> subtypeClass) {
	Preconditions.checkNotNull(subtypeClass, "The class cannot be null.");

	if (condition == null) {
		this.condition = new SubtypeCondition<F>(subtypeClass);
	} else {
		this.condition = new RichAndCondition<>(condition, new SubtypeCondition<F>(subtypeClass));
	}

	@SuppressWarnings("unchecked")
	Pattern<T, S> result = (Pattern<T, S>) this;

	return result;
}