本文整理匯總了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);
}