|
18 | 18 |
|
19 | 19 | import static com.google.common.base.MoreObjects.firstNonNull; |
20 | 20 | import static com.google.common.collect.ImmutableList.toImmutableList; |
21 | | -import static com.google.edwmigration.dumper.application.dumper.utils.OptionalUtils.optionallyWhen; |
22 | 21 | import static java.time.temporal.ChronoUnit.DAYS; |
23 | 22 | import static java.time.temporal.ChronoUnit.HOURS; |
24 | 23 | import static java.util.Arrays.stream; |
|
27 | 26 | import com.google.common.base.MoreObjects; |
28 | 27 | import com.google.common.base.MoreObjects.ToStringHelper; |
29 | 28 | import com.google.common.base.Predicates; |
30 | | -import com.google.common.base.Strings; |
31 | 29 | import com.google.common.collect.ImmutableList; |
32 | 30 | import com.google.edwmigration.dumper.application.dumper.ZonedParser.DayOffset; |
33 | 31 | import com.google.edwmigration.dumper.application.dumper.connector.Connector; |
@@ -759,10 +757,6 @@ public boolean isAssessment() { |
759 | 757 | return getOptions().has(optionAssessment); |
760 | 758 | } |
761 | 759 |
|
762 | | - private <T> Optional<T> optionAsOptional(OptionSpec<T> spec) { |
763 | | - return optionallyWhen(getOptions().has(spec), () -> getOptions().valueOf(spec)); |
764 | | - } |
765 | | - |
766 | 760 | @Nonnull |
767 | 761 | public Predicate<String> getSchemaPredicate() { |
768 | 762 | return toPredicate(getSchemata()); |
@@ -793,7 +787,11 @@ public String getUserOrFail() { |
793 | 787 | */ |
794 | 788 | @Nonnull |
795 | 789 | public Optional<String> getPasswordIfFlagProvided() { |
796 | | - return optionallyWhen(getOptions().has(optionPass), this::getPasswordOrPrompt); |
| 790 | + if (getOptions().has(optionPass)) { |
| 791 | + return Optional.of(getPasswordOrPrompt()); |
| 792 | + } else { |
| 793 | + return Optional.empty(); |
| 794 | + } |
797 | 795 | } |
798 | 796 |
|
799 | 797 | @Nonnull |
@@ -840,7 +838,15 @@ public List<String> getConfiguration() { |
840 | 838 | } |
841 | 839 |
|
842 | 840 | public Optional<String> getOutputFile() { |
843 | | - return optionAsOptional(optionOutput).filter(file -> !Strings.isNullOrEmpty(file)); |
| 841 | + if (!getOptions().has(optionOutput)) { |
| 842 | + return Optional.empty(); |
| 843 | + } |
| 844 | + String file = getOptions().valueOf(optionOutput); |
| 845 | + if (file == null || file.isEmpty()) { |
| 846 | + return Optional.empty(); |
| 847 | + } else { |
| 848 | + return Optional.of(file); |
| 849 | + } |
844 | 850 | } |
845 | 851 |
|
846 | 852 | public boolean isOutputContinue() { |
|
0 commit comments