本文整理了Java中io.debezium.config.Field.defaultValue()
方法的一些代码示例,展示了Field.defaultValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field.defaultValue()
方法的具体详情如下:
包路径:io.debezium.config.Field
类名称:Field
方法名:defaultValue
[英]Get the default value of the field.
[中]获取字段的默认值。
代码示例来源:origin: debezium/debezium
/**
* Get the string representation of the default value of the field.
*
* @return the default value, or {@code null} if there is no default value
*/
public String defaultValueAsString() {
Object defaultValue = defaultValue();
return defaultValue != null ? defaultValue.toString() : null;
}
代码示例来源:origin: debezium/debezium
@Before
public void beforeEach() {
hostname = System.getProperty("database.hostname");
if (hostname == null) hostname = "localhost";
String portStr = System.getProperty("database.port");
if (portStr != null) {
port = Integer.parseInt(portStr);
} else {
port = (Integer) MySqlConnectorConfig.PORT.defaultValue();
}
username = "snapper";
password = "snapperpass";
serverId = 18965;
serverName = "logical_server_name";
databaseName = "connector_test_ro";
Testing.Files.delete(DB_HISTORY_PATH);
}
代码示例来源:origin: debezium/debezium
/**
* Add this field to the given configuration definition.
*
* @param configDef the definition of the configuration; may be null if none of the fields are to be added
* @param groupName the name of the group; may be null
* @param fields the fields to be added as a group to the definition of the configuration
* @return the updated configuration; never null
*/
public static ConfigDef group(ConfigDef configDef, String groupName, Field... fields) {
if (configDef != null) {
if (groupName != null) {
for (int i = 0; i != fields.length; ++i) {
Field f = fields[i];
configDef.define(f.name(), f.type(), f.defaultValue(), null, f.importance(), f.description(),
groupName, i + 1, f.width(), f.displayName(), f.dependents(), null);
}
} else {
for (int i = 0; i != fields.length; ++i) {
Field f = fields[i];
configDef.define(f.name(), f.type(), f.defaultValue(), null, f.importance(), f.description(),
null, 1, f.width(), f.displayName(), f.dependents(), null);
}
}
}
return configDef;
}
代码示例来源:origin: debezium/debezium
private <T> void validateField(Config config, Field field, T expectedValue) {
assertNoConfigurationErrors(config, field);
Object actualValue = configValue(config, field.name()).value();
if (actualValue == null) {
actualValue = field.defaultValue();
}
if (expectedValue == null) {
assertThat(actualValue).isNull();
} else {
if (expectedValue instanceof EnumeratedValue) {
assertThat(((EnumeratedValue) expectedValue).getValue()).isEqualTo(actualValue.toString());
}
else {
assertThat(expectedValue).isEqualTo(actualValue);
}
}
}
代码示例来源:origin: debezium/debezium
protected static void assertConfigDefIsValid(Connector connector, io.debezium.config.Field.Set fields) {
ConfigDef configDef = connector.config();
assertThat(configDef).isNotNull();
fields.forEach(expected -> {
assertThat(configDef.names()).contains(expected.name());
ConfigKey key = configDef.configKeys().get(expected.name());
assertThat(key).isNotNull();
assertThat(key.name).isEqualTo(expected.name());
assertThat(key.displayName).isEqualTo(expected.displayName());
assertThat(key.importance).isEqualTo(expected.importance());
assertThat(key.documentation).isEqualTo(expected.description());
assertThat(key.type).isEqualTo(expected.type());
if (expected.equals(MySqlConnectorConfig.DATABASE_HISTORY) || expected.equals(MySqlConnectorConfig.JDBC_DRIVER)) {
assertThat(((Class<?>) key.defaultValue).getName()).isEqualTo((String) expected.defaultValue());
} else if (!expected.equals(MySqlConnectorConfig.SERVER_ID)) {
assertThat(key.defaultValue).isEqualTo(expected.defaultValue());
}
assertThat(key.dependents).isEqualTo(expected.dependents());
assertThat(key.width).isNotNull();
assertThat(key.group).isNotNull();
assertThat(key.orderInGroup).isGreaterThan(0);
assertThat(key.validator).isNull();
assertThat(key.recommender).isNull();
});
}
}
代码示例来源:origin: debezium/debezium
private void validateFieldDef(Field expected) {
ConfigDef configDef = connector.config();
assertThat(configDef.names()).contains(expected.name());
ConfigDef.ConfigKey key = configDef.configKeys().get(expected.name());
assertThat(key).isNotNull();
assertThat(key.name).isEqualTo(expected.name());
assertThat(key.displayName).isEqualTo(expected.displayName());
assertThat(key.importance).isEqualTo(expected.importance());
assertThat(key.documentation).isEqualTo(expected.description());
assertThat(key.type).isEqualTo(expected.type());
assertThat(key.defaultValue).isEqualTo(expected.defaultValue());
assertThat(key.dependents).isEqualTo(expected.dependents());
assertThat(key.width).isNotNull();
assertThat(key.group).isNotNull();
assertThat(key.orderInGroup).isGreaterThan(0);
assertThat(key.validator).isNull();
assertThat(key.recommender).isNull();
}
}
代码示例来源:origin: debezium/debezium
protected static void assertConfigDefIsValid(Connector connector, io.debezium.config.Field.Set fields) {
ConfigDef configDef = connector.config();
assertThat(configDef).isNotNull();
fields.forEach(expected -> {
assertThat(configDef.names()).contains(expected.name());
ConfigKey key = configDef.configKeys().get(expected.name());
assertThat(key).isNotNull();
assertThat(key.name).isEqualTo(expected.name());
assertThat(key.displayName).isEqualTo(expected.displayName());
assertThat(key.importance).isEqualTo(expected.importance());
assertThat(key.documentation).isEqualTo(expected.description());
assertThat(key.type).isEqualTo(expected.type());
assertThat(key.defaultValue).isEqualTo(expected.defaultValue());
assertThat(key.dependents).isEqualTo(expected.dependents());
assertThat(key.width).isNotNull();
assertThat(key.group).isNotNull();
assertThat(key.orderInGroup).isGreaterThan(0);
assertThat(key.validator).isNull();
assertThat(key.recommender).isNull();
});
}
代码示例来源:origin: io.debezium/debezium-core
/**
* Get the string representation of the default value of the field.
*
* @return the default value, or {@code null} if there is no default value
*/
public String defaultValueAsString() {
Object defaultValue = defaultValue();
return defaultValue != null ? defaultValue.toString() : null;
}
代码示例来源:origin: io.debezium/debezium-connector-mysql
@Before
public void beforeEach() {
hostname = System.getProperty("database.hostname");
if (hostname == null) hostname = "localhost";
String portStr = System.getProperty("database.port");
if (portStr != null) {
port = Integer.parseInt(portStr);
} else {
port = (Integer) MySqlConnectorConfig.PORT.defaultValue();
}
username = "snapper";
password = "snapperpass";
serverId = 18965;
serverName = "logical_server_name";
databaseName = "connector_test_ro";
Testing.Files.delete(DB_HISTORY_PATH);
}
代码示例来源:origin: io.debezium/debezium-core
/**
* Add this field to the given configuration definition.
*
* @param configDef the definition of the configuration; may be null if none of the fields are to be added
* @param groupName the name of the group; may be null
* @param fields the fields to be added as a group to the definition of the configuration
* @return the updated configuration; never null
*/
public static ConfigDef group(ConfigDef configDef, String groupName, Field... fields) {
if (configDef != null) {
if (groupName != null) {
for (int i = 0; i != fields.length; ++i) {
Field f = fields[i];
configDef.define(f.name(), f.type(), f.defaultValue(), null, f.importance(), f.description(),
groupName, i + 1, f.width(), f.displayName(), f.dependents(), null);
}
} else {
for (int i = 0; i != fields.length; ++i) {
Field f = fields[i];
configDef.define(f.name(), f.type(), f.defaultValue(), null, f.importance(), f.description(),
null, 1, f.width(), f.displayName(), f.dependents(), null);
}
}
}
return configDef;
}
代码示例来源:origin: io.debezium/debezium-connector-postgres
private <T> void validateField(Config config, Field field, T expectedValue) {
assertNoConfigurationErrors(config, field);
Object actualValue = configValue(config, field.name()).value();
if (actualValue == null) {
actualValue = field.defaultValue();
}
if (expectedValue == null) {
assertThat(actualValue).isNull();
} else {
if (expectedValue instanceof EnumeratedValue) {
assertThat(((EnumeratedValue) expectedValue).getValue()).isEqualTo(actualValue.toString());
}
else {
assertThat(expectedValue).isEqualTo(actualValue);
}
}
}
代码示例来源:origin: io.debezium/debezium-connector-mysql
protected static void assertConfigDefIsValid(Connector connector, io.debezium.config.Field.Set fields) {
ConfigDef configDef = connector.config();
assertThat(configDef).isNotNull();
fields.forEach(expected -> {
assertThat(configDef.names()).contains(expected.name());
ConfigKey key = configDef.configKeys().get(expected.name());
assertThat(key).isNotNull();
assertThat(key.name).isEqualTo(expected.name());
assertThat(key.displayName).isEqualTo(expected.displayName());
assertThat(key.importance).isEqualTo(expected.importance());
assertThat(key.documentation).isEqualTo(expected.description());
assertThat(key.type).isEqualTo(expected.type());
if (expected.equals(MySqlConnectorConfig.DATABASE_HISTORY) || expected.equals(MySqlConnectorConfig.JDBC_DRIVER)) {
assertThat(((Class<?>) key.defaultValue).getName()).isEqualTo((String) expected.defaultValue());
} else if (!expected.equals(MySqlConnectorConfig.SERVER_ID)) {
assertThat(key.defaultValue).isEqualTo(expected.defaultValue());
}
assertThat(key.dependents).isEqualTo(expected.dependents());
assertThat(key.width).isNotNull();
assertThat(key.group).isNotNull();
assertThat(key.orderInGroup).isGreaterThan(0);
assertThat(key.validator).isNull();
assertThat(key.recommender).isNull();
});
}
}
代码示例来源:origin: io.debezium/debezium-connector-postgres
private void validateFieldDef(Field expected) {
ConfigDef configDef = connector.config();
assertThat(configDef.names()).contains(expected.name());
ConfigDef.ConfigKey key = configDef.configKeys().get(expected.name());
assertThat(key).isNotNull();
assertThat(key.name).isEqualTo(expected.name());
assertThat(key.displayName).isEqualTo(expected.displayName());
assertThat(key.importance).isEqualTo(expected.importance());
assertThat(key.documentation).isEqualTo(expected.description());
assertThat(key.type).isEqualTo(expected.type());
assertThat(key.defaultValue).isEqualTo(expected.defaultValue());
assertThat(key.dependents).isEqualTo(expected.dependents());
assertThat(key.width).isNotNull();
assertThat(key.group).isNotNull();
assertThat(key.orderInGroup).isGreaterThan(0);
assertThat(key.validator).isNull();
assertThat(key.recommender).isNull();
}
}
内容来源于网络,如有侵权,请联系作者删除!