@SuppressWarnings("unchecked")
    public static <T> NFAFactory<T> compileFactory(
            final Pattern<T, ?> pattern, boolean timeoutHandling) {
        if (pattern == null) {
            // return a factory for empty NFAs
            return new NFAFactoryImpl<>(
                    0,
                    Collections.<String, Long>emptyMap(),
                    Collections.<State<T>>emptyList(),
                    timeoutHandling);
        } else {
            final NFAFactoryCompiler<T> nfaFactoryCompiler = new NFAFactoryCompiler<>(pattern);
            nfaFactoryCompiler.compileFactory();
            return new NFAFactoryImpl<>(
                    nfaFactoryCompiler.getWindowTime(),
                    nfaFactoryCompiler.getWindowTimes(),
                    nfaFactoryCompiler.getStates(),
                    timeoutHandling);
        }
    }
@Test
    public void testWindowTimeCorrectlySet() {
        Pattern<Event, ?> pattern =
                Pattern.<Event>begin("start")
                        .followedBy("middle")
                        .within(Time.seconds(10))
                        .followedBy("then")
                        .within(Time.seconds(20))
                        .followedBy("end");

        NFACompiler.NFAFactoryCompiler<Event> factory =
                new NFACompiler.NFAFactoryCompiler<>(pattern);
        factory.compileFactory();
        assertEquals(10000, factory.getWindowTime());
    }