@Test void fromShouldReturnConfiguredRetentionTime() { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty("retentionPeriod", "15d"); assertThat(RetentionConfiguration.from(configuration)).isEqualTo(new RetentionConfiguration(Duration.ofDays(15))); }
public static RetentionConfiguration from(Configuration propertiesConfiguration) { return Optional.ofNullable(propertiesConfiguration.getString("retentionPeriod")) .map(string -> DurationParser.parse(string, ChronoUnit.DAYS)) .map(RetentionConfiguration::new) .orElse(DEFAULT); }
RetentionConfiguration { public static RetentionConfiguration from(Configuration propertiesConfiguration) { return Optional.ofNullable(propertiesConfiguration.getString("retentionPeriod")) .map(string -> DurationParser.parse(string, ChronoUnit.DAYS)) .map(RetentionConfiguration::new) .orElse(DEFAULT); } }
RetentionConfiguration { public static RetentionConfiguration from(Configuration propertiesConfiguration) { return Optional.ofNullable(propertiesConfiguration.getString("retentionPeriod")) .map(string -> DurationParser.parse(string, ChronoUnit.DAYS)) .map(RetentionConfiguration::new) .orElse(DEFAULT); } RetentionConfiguration(Duration retentionPeriod); }
RetentionConfiguration { public static RetentionConfiguration from(Configuration propertiesConfiguration) { return Optional.ofNullable(propertiesConfiguration.getString("retentionPeriod")) .map(string -> DurationParser.parse(string, ChronoUnit.DAYS)) .map(RetentionConfiguration::new) .orElse(DEFAULT); } RetentionConfiguration(Duration retentionPeriod); static RetentionConfiguration from(Configuration propertiesConfiguration); Duration getRetentionPeriod(); @Override final boolean equals(Object o); @Override final int hashCode(); }
RetentionConfiguration { public static RetentionConfiguration from(Configuration propertiesConfiguration) { return Optional.ofNullable(propertiesConfiguration.getString("retentionPeriod")) .map(string -> DurationParser.parse(string, ChronoUnit.DAYS)) .map(RetentionConfiguration::new) .orElse(DEFAULT); } RetentionConfiguration(Duration retentionPeriod); static RetentionConfiguration from(Configuration propertiesConfiguration); Duration getRetentionPeriod(); @Override final boolean equals(Object o); @Override final int hashCode(); static final RetentionConfiguration DEFAULT; }