TriggerStateMachine implements Serializable { public boolean isCompatible(TriggerStateMachine other) { if (!getClass().equals(other.getClass())) { return false; } if (subTriggers == null) { return other.subTriggers == null; } else if (other.subTriggers == null) { return false; } else if (subTriggers.size() != other.subTriggers.size()) { return false; } for (int i = 0; i < subTriggers.size(); i++) { if (!subTriggers.get(i).isCompatible(other.subTriggers.get(i))) { return false; } } return true; } protected  TriggerStateMachine(@Nullable List<TriggerStateMachine> subTriggers); abstract void onElement(OnElementContext c); abstract void onMerge(OnMergeContext c); abstract boolean shouldFire(TriggerContext context); abstract void onFire(TriggerContext context); void prefetchOnElement(StateAccessor<?> state); void prefetchOnMerge(MergingStateAccessor<?, ?> state); void prefetchShouldFire(StateAccessor<?> state); void prefetchOnFire(StateAccessor<?> state); void clear(TriggerContext c); Iterable<TriggerStateMachine> subTriggers(); boolean isCompatible(TriggerStateMachine other); @Override String toString(); @Override boolean equals(@Nullable Object obj); @Override int hashCode(); TriggerStateMachine orFinally(TriggerStateMachine until);  }
@Test public void testIsCompatible() throws Exception { assertTrue(new Trigger1(null).isCompatible(new Trigger1(null))); assertTrue( new Trigger1(Arrays.asList(new Trigger2(null))) .isCompatible(new Trigger1(Arrays.asList(new Trigger2(null))))); assertFalse(new Trigger1(null).isCompatible(new Trigger2(null))); assertFalse( new Trigger1(Arrays.asList(new Trigger1(null))) .isCompatible(new Trigger1(Arrays.asList(new Trigger2(null))))); }