@Test public void when_creating_validator_registration_state_with_null__then_exception_is_thrown() { Assertions.assertThatThrownBy(() -> ValidatorRegistrationState.from(null)) .isInstanceOf(NullPointerException.class); Assertions.assertThatThrownBy(() -> ValidatorRegistrationState.from(null, mock(RadixAddress.class))) .isInstanceOf(NullPointerException.class); Assertions.assertThatThrownBy(() -> ValidatorRegistrationState.from(Stream.empty(), null)) .isInstanceOf(NullPointerException.class); }
static ValidatorRegistrationState from(Stream<Particle> store, RadixAddress address) { Objects.requireNonNull(store, "store"); Objects.requireNonNull(address, "address"); return store .map(ValidatorRegistrationState::from) .filter(state -> state.getAddress().equals(address)) .max(Comparator.comparing(ValidatorRegistrationState::getNonce)) .orElseGet(() -> ValidatorRegistrationState.initial(address)); }
ValidatorRegistrationState { static ValidatorRegistrationState from(Stream<Particle> store, RadixAddress address) { Objects.requireNonNull(store, "store"); Objects.requireNonNull(address, "address"); return store .map(ValidatorRegistrationState::from) .filter(state -> state.getAddress().equals(address)) .max(Comparator.comparing(ValidatorRegistrationState::getNonce)) .orElseGet(() -> ValidatorRegistrationState.initial(address)); } }
ValidatorRegistrationState { static ValidatorRegistrationState from(Stream<Particle> store, RadixAddress address) { Objects.requireNonNull(store, "store"); Objects.requireNonNull(address, "address"); return store .map(ValidatorRegistrationState::from) .filter(state -> state.getAddress().equals(address)) .max(Comparator.comparing(ValidatorRegistrationState::getNonce)) .orElseGet(() -> ValidatorRegistrationState.initial(address)); } private  ValidatorRegistrationState(Particle particle, RadixAddress address, boolean registered, long nonce); }
ValidatorRegistrationState { static ValidatorRegistrationState from(Stream<Particle> store, RadixAddress address) { Objects.requireNonNull(store, "store"); Objects.requireNonNull(address, "address"); return store .map(ValidatorRegistrationState::from) .filter(state -> state.getAddress().equals(address)) .max(Comparator.comparing(ValidatorRegistrationState::getNonce)) .orElseGet(() -> ValidatorRegistrationState.initial(address)); } private  ValidatorRegistrationState(Particle particle, RadixAddress address, boolean registered, long nonce); @Override boolean equals(Object o); @Override int hashCode(); }
ValidatorRegistrationState { static ValidatorRegistrationState from(Stream<Particle> store, RadixAddress address) { Objects.requireNonNull(store, "store"); Objects.requireNonNull(address, "address"); return store .map(ValidatorRegistrationState::from) .filter(state -> state.getAddress().equals(address)) .max(Comparator.comparing(ValidatorRegistrationState::getNonce)) .orElseGet(() -> ValidatorRegistrationState.initial(address)); } private  ValidatorRegistrationState(Particle particle, RadixAddress address, boolean registered, long nonce); @Override boolean equals(Object o); @Override int hashCode();  }