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


Java Tag类代码示例

本文整理汇总了Java中com.mongodb.Tag的典型用法代码示例。如果您正苦于以下问题:Java Tag类的具体用法?Java Tag怎么用?Java Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Tag类属于com.mongodb包,在下文中一共展示了Tag类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseArg

import com.mongodb.Tag; //导入依赖的package包/类
private static TagSet parseArg(ObjectNode arg) {
    List<Tag> tags = new ArrayList<>();
    for (Iterator<Map.Entry<String, JsonNode>> itr = arg.fields(); itr.hasNext();) {
        Map.Entry<String, JsonNode> entry = itr.next();
        tags.add(new Tag(entry.getKey(), entry.getValue().asText()));
    }
    return new TagSet(tags);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:9,代码来源:MongoReadPreference.java

示例2: ReadPreferenceParser

import com.mongodb.Tag; //导入依赖的package包/类
ReadPreferenceParser(ConnectionString connectionString, JsonObject config) {
  ReadPreference connStringReadPreference = connectionString != null ? connectionString.getReadPreference() : null;
  if (connStringReadPreference != null) {
    // Prefer connection string's read preference
    readPreference = connStringReadPreference;
  } else {
    ReadPreference rp;
    String rps = config.getString("readPreference");
    if (rps != null) {
      JsonArray readPreferenceTags = config.getJsonArray("readPreferenceTags");
      if (readPreferenceTags == null) {
        rp = ReadPreference.valueOf(rps);
        if (rp == null) throw new IllegalArgumentException("Invalid ReadPreference " + rps);
      } else {
        // Support advanced ReadPreference Tags
        List<TagSet> tagSet = new ArrayList<>();
        readPreferenceTags.forEach(o -> {
          String tagString = (String) o;
          List<Tag> tags = Stream.of(tagString.trim().split(","))
              .map(s -> s.split(":"))
              .filter(array -> {
                if (array.length != 2) {
                  throw new IllegalArgumentException("Invalid readPreferenceTags value '" + tagString + "'");
                }
                return true;
              }).map(array -> new Tag(array[0], array[1])).collect(Collectors.toList());

          tagSet.add(new TagSet(tags));
        });
        rp = ReadPreference.valueOf(rps, tagSet);
      }
    } else {
      rp = null;
    }

    readPreference = rp;
  }
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:39,代码来源:ReadPreferenceParser.java

示例3: toTags

import com.mongodb.Tag; //导入依赖的package包/类
private static TagSet toTags( DBObject tagsDocument )
{
	List<Tag> tagList = new ArrayList<Tag>( );
	for ( String key : tagsDocument.keySet( ) )
	{
		tagList.add( new Tag( key, tagsDocument.get( key ).toString( ) ) );
	}
	return new TagSet( tagList );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:10,代码来源:QueryProperties.java

示例4: testNearestArgs

import com.mongodb.Tag; //导入依赖的package包/类
@Test
public void testNearestArgs() {
    TaggableReadPreference pref = (TaggableReadPreference) MongoReadPreference.parse("nearest ( {\"x\":1} )");
    Assert.assertTrue(pref.equals(ReadPreference.nearest(new TagSet(Arrays.asList(new Tag("x", "1"))))));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:6,代码来源:MongoReadPreferenceTest.java

示例5: testNearestArgs2

import com.mongodb.Tag; //导入依赖的package包/类
@Test
public void testNearestArgs2() {
    TaggableReadPreference pref = (TaggableReadPreference) MongoReadPreference.parse("nearest ( [ {\"x\":1}, {\"y\":\"a\"}] )");
    Assert.assertTrue(pref.equals(ReadPreference.nearest(Arrays.asList(new TagSet(Arrays.asList(new Tag("x", "1"))),
            new TagSet(Arrays.asList(new Tag("y", "a")))))));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:7,代码来源:MongoReadPreferenceTest.java

示例6: testNearestArgs3

import com.mongodb.Tag; //导入依赖的package包/类
@Test
public void testNearestArgs3() {
    TaggableReadPreference pref = (TaggableReadPreference) MongoReadPreference.parse("nearest([ {\"x\":1}, {\"y\":\"a\"}])");
    Assert.assertTrue(pref.equals(ReadPreference.nearest(Arrays.asList(new TagSet(Arrays.asList(new Tag("x", "1"))),
            new TagSet(Arrays.asList(new Tag("y", "a")))))));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:7,代码来源:MongoReadPreferenceTest.java


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