本文整理汇总了Java中org.bson.Document.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java Document.entrySet方法的具体用法?Java Document.entrySet怎么用?Java Document.entrySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.Document
的用法示例。
在下文中一共展示了Document.entrySet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromPreferences
import org.bson.Document; //导入方法依赖的package包/类
/**
* @param context The Context that has access to the app's preferences.
* @param clientAppId The app ID that the preferences are for.
* @return All persisted push provider information.
*/
synchronized static List<PushProviderInfo> fromPreferences(final Context context, final String clientAppId) {
final String globPrefPath = String.format(SHARED_PREFERENCES_NAME, clientAppId);
final SharedPreferences preferences = context.getSharedPreferences(globPrefPath, Context.MODE_PRIVATE);
final Document configs = Document.parse(preferences.getString(PREF_CONFIGS, "{}"));
final List<PushProviderInfo> providers = new ArrayList<>();
for (final Map.Entry<String, Object> configEntry : configs.entrySet()) {
final Document info = (Document) configEntry.getValue();
final PushProviderName providerName =
PushProviderName.fromTypeName(info.getString(PushProviderInfo.Fields.TYPE));
final Document config = (Document) info.get(PushProviderInfo.Fields.CONFIG);
final PushProviderInfo provider;
switch (providerName) {
case GCM:
provider = GCMPushProviderInfo.fromConfig(configEntry.getKey(), config);
break;
default:
throw new IllegalStateException("Unknown provider name");
}
providers.add(provider);
}
return providers;
}
示例2: canTransformDocumentToMap
import org.bson.Document; //导入方法依赖的package包/类
@Test
public void canTransformDocumentToMap() {
Document document = new Document().append("a", "b").append("c", 1);
//noinspection unchecked
Map<String, Object> transformed = documentTransformer.transform(Map.class, document);
assertThat(transformed.size(), is(document.size()));
for (Map.Entry<String, Object> entry : document.entrySet()) {
assertThat(transformed, hasKey(entry.getKey()));
assertThat(transformed.get(entry.getKey()), is(entry.getValue()));
}
}