当前位置: 首页>>代码示例>>Java>>正文


Java Document.entrySet方法代码示例

本文整理汇总了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;
}
 
开发者ID:mongodb,项目名称:stitch-android-sdk,代码行数:31,代码来源:PushProviderInfo.java

示例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()));
  }
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:15,代码来源:DocumentTransformerTest.java


注:本文中的org.bson.Document.entrySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。