本文整理了Java中java.util.Hashtable.getOrDefault()
方法的一些代码示例,展示了Hashtable.getOrDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hashtable.getOrDefault()
方法的具体详情如下:
包路径:java.util.Hashtable
类名称:Hashtable
方法名:getOrDefault
暂无
代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core
@Override
public synchronized V getOrDefault(Object key, V defaultValue) {
return getDelegate().getOrDefault(key, defaultValue);
}
代码示例来源:origin: com.haulmont.thirdparty/eclipselink
@Override
public synchronized V getOrDefault(Object key, V defaultValue) {
return getDelegate().getOrDefault(key, defaultValue);
}
代码示例来源:origin: stackoverflow.com
public class ApplicationSettings {
private final Properties properties = new Properties();
public ApplicationSettings() {
properties.load(...);
}
public String emailFrom() {
// simple methods are concise, and encode the default right inline
return properties.getOrDefault("emailFrom", "hello@abc.com");
}
public int getMaxTestSeconds() {
// You can do more complex validation if you want, too
String value = properties.get("maxTestInSec");
if (value == null) {
return 30;
}
int maxTestSeconds = Integer.parseInt(value);
if (maxTestSeconds <= 0) {
// could instead log a warning and return the default if you want
throw new IllegalStateException(
"maxTestInSec must be positive - was " + maxTestSeconds);
}
return maxTestSeconds;
}
}
代码示例来源:origin: dita-ot/dita-ot
/**
* Get result.
*/
@Override
public void getResult(final ContentHandler buf) throws SAXException {
final String separator = paramTable.getOrDefault("separator", "|");
final List<String> v = valueSet.stream()
.map(fileValue -> fileValue.value)
.collect(Collectors.toList());
Collections.sort(v);
final StringBuilder retBuf = new StringBuilder();
for (final Iterator<String> i = v.iterator(); i.hasNext();) {
retBuf.append(i.next());
if (i.hasNext()) {
retBuf.append(separator);
}
}
final char[] ret = retBuf.toString().toCharArray();
buf.characters(ret, 0, ret.length);
}
代码示例来源:origin: ml.alternet/alternet-tools
Optional<Object> cast(Class<?> c, String s) {
try {
// try scalar types
return Optional.of(Type.of(c).parse(s));
} catch (UnsupportedOperationException uoe) {
return Optional.ofNullable(classMappers.getOrDefault(c, k -> {
try {
return c.getConstructor(String.class).newInstance(s);
} catch (InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e)
{
return doThrow(e);
} catch (NoSuchMethodException | SecurityException e) {
return null;
}
}).apply(s));
}
}
代码示例来源:origin: dita-ot/dita-ot
/**
* Get result.
*/
@Override
public void getResult(final ContentHandler buf) throws SAXException {
final String property = paramTable.getOrDefault("property", "transtype");
for (final Value value: valueSet) {
buf.startElement(NULL_NS_URI, "not", "not", new AttributesBuilder().build());
buf.startElement(NULL_NS_URI, "equals", "equals", new AttributesBuilder()
.add("arg1", "${" + property + "}")
.add("arg2", value.value)
.add("casesensitive", "false")
.build());
buf.endElement(NULL_NS_URI, "equals", "equals");
buf.endElement(NULL_NS_URI, "not", "not");
}
}
代码示例来源:origin: octo-online/reactive-audit
@Test(expected = ReactiveAuditException.class)
public void getOrDefault()
{
ReactiveAudit.off.commit();
Hashtable hash=new Hashtable();
TestTools.strict.commit();
hash.getOrDefault(null,null);
}
@Test(expected = ReactiveAuditException.class)
内容来源于网络,如有侵权,请联系作者删除!