Example #1
0
  public Collection<String> getArguments() {
    Collection<String> args = new ArrayList<>();
    Optional.ofNullable(username).ifPresent(s -> args.addAll(Arrays.asList("-u", s)));
    Optional.ofNullable(password).ifPresent(s -> args.addAll(Arrays.asList("-p", s)));
    Optional.ofNullable(from)
        .ifPresent(d -> args.addAll(Arrays.asList("-f", d.format(DateTimeFormatter.ISO_DATE))));

    return args;
  }
Example #2
0
  public void save() {
    final Properties properties = new Properties();
    Optional.ofNullable(username).ifPresent(s -> properties.setProperty("username", s));
    Optional.ofNullable(password).ifPresent(s -> properties.setProperty("password", s));
    Optional.ofNullable(from)
        .ifPresent(d -> properties.setProperty("from", d.format(DateTimeFormatter.ISO_DATE)));

    try {
      properties.store(getConfigurationWriter(), null);
    } catch (IOException e) {
      e.printStackTrace(); // TODO logging
    }
  }