Condition { public void registerObserver(@NonNull Observer observer) { checkNotNull(observer, "observer"); if (mObservers.contains(observer)) { throw new IllegalStateException("Observer is already registered."); } mObservers.add(observer); if (mObservers.size() == 1) { onFirstObserverRegistered(); } }  abstract boolean eval(); void registerObserver(@NonNull Observer observer); void unregisterObserver(@NonNull Observer observer); @NonNull Condition and(@NonNull Condition condition); @NonNull Condition or(@NonNull Condition condition); @NonNull Condition xor(@NonNull Condition condition); @NonNull Condition not(); @NonNull static Condition isTrue(boolean value); @NonNull static Condition isFalse(boolean value); @NonNull static Condition always(); @NonNull static Condition never(); @NonNull static Condition and(@NonNull final Condition a, @NonNull final Condition b); @NonNull static Condition or(@NonNull final Condition a, @NonNull final Condition b); @NonNull static Condition xor(@NonNull final Condition a, @NonNull final Condition b); @NonNull static Condition not(@NonNull final Condition condition); @NonNull static Condition adapter(@NonNull PowerAdapter adapter,
                                    @NonNull Predicate<PowerAdapter> predicate);  }
@Test(expected = IllegalStateException.class) public void doubleRegistrationThrows() { Observer observer = mock(Observer.class); mCondition.registerObserver(observer); mCondition.registerObserver(observer); }