@Test void afterBuildRequireToSetAgainCommand() { final CommandBuilderReusable.ReusableBuilder<String> builder = new CommandBuilderReusable.ReusableBuilder<>(new DoNothingCommand()); final CanonCommand<String> canonCommand = builder.build(); assertNotNull(canonCommand); assertThrows(IllegalStateException.class, builder::build); }
public CanonCommand<R> build() { if (canonCommand == null) throw new IllegalStateException("Canon command must be set"); try { final List<Supplier<DecoratorCommand<R>>> localDecorators = getDecorators(); if (localDecorators.isEmpty()) return canonCommand; for (final Supplier<DecoratorCommand<R>> decoratorSupplier : localDecorators) { decoratedCommand = decoratorSupplier.get(); } return decoratedCommand; } finally { canonCommand = null; decoratedCommand = null; } }
CommandBuilderReusable { public CanonCommand<R> build() { if (canonCommand == null) throw new IllegalStateException("Canon command must be set"); try { final List<Supplier<DecoratorCommand<R>>> localDecorators = getDecorators(); if (localDecorators.isEmpty()) return canonCommand; for (final Supplier<DecoratorCommand<R>> decoratorSupplier : localDecorators) { decoratedCommand = decoratorSupplier.get(); } return decoratedCommand; } finally { canonCommand = null; decoratedCommand = null; } } }
CommandBuilderReusable { public CanonCommand<R> build() { if (canonCommand == null) throw new IllegalStateException("Canon command must be set"); try { final List<Supplier<DecoratorCommand<R>>> localDecorators = getDecorators(); if (localDecorators.isEmpty()) return canonCommand; for (final Supplier<DecoratorCommand<R>> decoratorSupplier : localDecorators) { decoratedCommand = decoratorSupplier.get(); } return decoratedCommand; } finally { canonCommand = null; decoratedCommand = null; } } CommandBuilderReusable();  CommandBuilderReusable(final CanonCommand<R> canonCommand); }
CommandBuilderReusable { public CanonCommand<R> build() { if (canonCommand == null) throw new IllegalStateException("Canon command must be set"); try { final List<Supplier<DecoratorCommand<R>>> localDecorators = getDecorators(); if (localDecorators.isEmpty()) return canonCommand; for (final Supplier<DecoratorCommand<R>> decoratorSupplier : localDecorators) { decoratedCommand = decoratorSupplier.get(); } return decoratedCommand; } finally { canonCommand = null; decoratedCommand = null; } } CommandBuilderReusable();  CommandBuilderReusable(final CanonCommand<R> canonCommand); T setCanonCommand(final CanonCommand<R> canonCommand); T timeout(final Duration timeout); T withDefaultOnException(final R defaultValue); CanonCommand<R> build(); }
CommandBuilderReusable { public CanonCommand<R> build() { if (canonCommand == null) throw new IllegalStateException("Canon command must be set"); try { final List<Supplier<DecoratorCommand<R>>> localDecorators = getDecorators(); if (localDecorators.isEmpty()) return canonCommand; for (final Supplier<DecoratorCommand<R>> decoratorSupplier : localDecorators) { decoratedCommand = decoratorSupplier.get(); } return decoratedCommand; } finally { canonCommand = null; decoratedCommand = null; } } CommandBuilderReusable();  CommandBuilderReusable(final CanonCommand<R> canonCommand); T setCanonCommand(final CanonCommand<R> canonCommand); T timeout(final Duration timeout); T withDefaultOnException(final R defaultValue); CanonCommand<R> build();  }