Skip to content

Commit

Permalink
revert code
Browse files Browse the repository at this point in the history
  • Loading branch information
gdliu3 committed Aug 7, 2023
1 parent a4cc0c3 commit e4f9dbb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public <T> Optional<T> getOptional(Option<T> option) {
}
}
if (value == null) {
return Optional.ofNullable(option.defaultValue());
return Optional.empty();
}
return Optional.of(convertValue(value, option));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@SuppressWarnings("checkstyle:StaticVariableName")
public class ReadableConfigTest {
Expand Down Expand Up @@ -299,18 +298,4 @@ public void testFallbackKey() {
readonlyConfig = ReadonlyConfig.fromMap(map);
Assertions.assertEquals("ark", readonlyConfig.get(usernameOption));
}

@Test
public void testOptional() {
Optional<String> notDefaultVal =
ReadonlyConfig.fromMap(new HashMap<>())
.getOptional(Options.key("option.not-exist").stringType().noDefaultValue());
Assertions.assertFalse(notDefaultVal.isPresent());
Optional<String> defaultVal =
ReadonlyConfig.fromMap(new HashMap<>())
.getOptional(
Options.key("option.exist").stringType().defaultValue("default"));
Assertions.assertTrue(defaultVal.isPresent());
Assertions.assertEquals("default", defaultVal.get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ public static JdbcSinkConfig of(ReadonlyConfig config) {
config.getOptional(JdbcOptions.PRIMARY_KEYS).ifPresent(builder::primaryKeys);
config.getOptional(JdbcOptions.DATABASE).ifPresent(builder::database);
config.getOptional(JdbcOptions.TABLE).ifPresent(builder::table);
config.getOptional(ENABLE_UPSERT).ifPresent(builder::enableUpsert);
config.getOptional(IS_PRIMARY_KEY_UPDATED).ifPresent(builder::isPrimaryKeyUpdated);
config.getOptional(SUPPORT_UPSERT_BY_INSERT_ONLY)
.ifPresent(builder::supportUpsertByInsertOnly);
config.getOptional(JdbcOptions.QUERY).ifPresent(builder::simpleSql);
builder.enableUpsert(config.get(ENABLE_UPSERT));
builder.isPrimaryKeyUpdated(config.get(IS_PRIMARY_KEY_UPDATED));
builder.supportUpsertByInsertOnly(config.get(SUPPORT_UPSERT_BY_INSERT_ONLY));
builder.simpleSql(config.get(JdbcOptions.QUERY));
return builder.build();
}
}

0 comments on commit e4f9dbb

Please sign in to comment.