/** Create a Next that updates the model and dispatches the supplied set of effects. */ @Nonnull public static <M, F> Next<M, F> next(M model, Set<? extends F> effects) { return new AutoValue_Next<>(model, ImmutableUtil.immutableSet(effects)); }
/** Create a Next that updates the model but dispatches no effects. */ @Nonnull public static <M, F> Next<M, F> next(M model) { return new AutoValue_Next<>(model, ImmutableUtil.<F>emptySet()); }
/** Create a Next that doesn't update the model but dispatches the supplied effects. */ @Nonnull public static <M, F> Next<M, F> dispatch(Set<? extends F> effects) { return new AutoValue_Next<>(null, ImmutableUtil.immutableSet(effects)); }
/** Create an empty Next that doesn't update the model or dispatch effects. */ @Nonnull public static <M, F> Next<M, F> noChange() { return new AutoValue_Next<>(null, ImmutableUtil.<F>emptySet()); } }
/** Create a Next that doesn't update the model but dispatches the supplied effects. */ @Nonnull public static <M, F> Next<M, F> dispatch(Set<? extends F> effects) { return new AutoValue_Next<>(null, ImmutableUtil.immutableSet(effects)); }
/** Create an empty Next that doesn't update the model or dispatch effects. */ @Nonnull public static <M, F> Next<M, F> noChange() { return new AutoValue_Next<>(null, ImmutableUtil.<F>emptySet()); } }
/** Create a Next that updates the model but dispatches no effects. */ @Nonnull public static <M, F> Next<M, F> next(M model) { return new AutoValue_Next<>(model, ImmutableUtil.<F>emptySet()); }
/** Create a Next that updates the model and dispatches the supplied set of effects. */ @Nonnull public static <M, F> Next<M, F> next(M model, Set<? extends F> effects) { return new AutoValue_Next<>(model, ImmutableUtil.immutableSet(effects)); }
@Test public void testEquals() throws Exception { Next<String, String> m1 = new AutoValue_Next<>("hi", ImmutableUtil.<String>emptySet()); Next<String, String> m2 = Next.next("hi"); Next<String, String> m3 = Next.next("hi", ImmutableUtil.<String>emptySet()); Next<String, String> n1 = new AutoValue_Next<>("hi", ImmutableUtil.setOf("a", "b")); Next<String, String> n2 = Next.next("hi", effects("a", "b")); Next<String, String> n3 = Next.next("hi", effects("b", "a")); Next<String, String> n4 = Next.next("hi", ImmutableUtil.setOf("b", "a")); Next<String, String> o1 = new AutoValue_Next<>("hi", ImmutableUtil.setOf("a", "b", "c")); Next<String, String> o2 = Next.next("hi", effects("a", "c", "b")); Next<String, String> o3 = Next.next("hi", effects("b", "a", "c")); Next<String, String> o4 = Next.next("hi", ImmutableUtil.setOf("c", "b", "a")); Next<String, String> p1 = new AutoValue_Next<>(null, ImmutableUtil.setOf("a", "b", "c")); Next<String, String> p2 = Next.dispatch(effects("a", "c", "b")); Next<String, String> p3 = Next.dispatch(effects("b", "a", "c")); Next<String, String> p4 = Next.dispatch(ImmutableUtil.setOf("c", "b", "a")); Next<String, String> q1 = new AutoValue_Next<>("hey", ImmutableUtil.<String>setOf()); Next<String, String> q2 = Next.next("hey"); Next<String, String> q3 = Next.next("hey", Collections.<String>emptySet()); Next<String, String> r1 = new AutoValue_Next<>("hey", ImmutableUtil.setOf("a", "b")); Next<String, String> r2 = Next.next("hey", effects("a", "b")); Next<String, String> s1 = new AutoValue_Next<>("hey", ImmutableUtil.setOf("a", "b", "c")); Next<String, String> s2 = Next.next("hey", effects("a", "b", "c"));