本文整理汇总了Java中com.mongodb.WriteConcern.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java WriteConcern.valueOf方法的具体用法?Java WriteConcern.valueOf怎么用?Java WriteConcern.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.WriteConcern
的用法示例。
在下文中一共展示了WriteConcern.valueOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setReadWriteMode
import com.mongodb.WriteConcern; //导入方法依赖的package包/类
@Override
public void setReadWriteMode(String readWriteMode) {
if (readWriteMode == null || readWriteMode.equals(lastReadWriteMode)) {
return;
}
lastReadWriteMode = readWriteMode;
try {
Map<String, String> map = Splitter.on(", ").withKeyValueSeparator(":").split(readWriteMode);
String read = map.get("read");
if (read != null) {
ReadPreference readPref = ReadPreference.valueOf(read);
if (!readPref.equals(this.readPreference)) {
this.readPreference = readPref;
}
}
String write = map.get("write");
if (write != null) {
WriteConcern writeConcern = WriteConcern.valueOf(write);
if (!writeConcern.equals(this.writeConcern)) {
this.writeConcern = writeConcern;
}
}
} catch (Exception e) {
// unsupported or parse error - ignore
}
}
示例2: getWriteConcern
import com.mongodb.WriteConcern; //导入方法依赖的package包/类
public static WriteConcern getWriteConcern(ExecutionOptions options) {
if (options != null) {
String value = options.getOptions().get(OPT_WRITE_CONCERN);
if (value != null) {
value = value.trim();
if (value.length() > 0) {
return WriteConcern.valueOf(value);
}
}
}
return null;
}
示例3: setWriteConcern
import com.mongodb.WriteConcern; //导入方法依赖的package包/类
/**
* @param writeConcern
* The WriteConcern setting for Mongo.<i>(may be null). If null, set to default of dbCollection's writeConcern.</i>
*/
public void setWriteConcern(final String writeConcern) {
this.writeConcern = writeConcern;
concern = WriteConcern.valueOf(writeConcern);
}
示例4: setWriteConcern
import com.mongodb.WriteConcern; //导入方法依赖的package包/类
/**
* Set the {@link WriteConcern} for write operations on MongoDB using the standard ones.
* Resolved from the fields of the WriteConcern class by calling the {@link WriteConcern#valueOf(String)} method.
*
* @param writeConcern the standard name of the WriteConcern
* @see <a href="http://api.mongodb.org/java/current/com/mongodb/WriteConcern.html#valueOf(java.lang.String)">possible options</a>
*/
public void setWriteConcern(String writeConcern) {
this.writeConcern = WriteConcern.valueOf(writeConcern);
}