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


Java Indexed类代码示例

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


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

示例1: convert

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
@SuppressWarnings("deprecation")
Index convert(final Indexed indexed, final String nameToStore) {
    if (indexed.dropDups() || indexed.options().dropDups()) {
        LOG.warning("Support for dropDups has been removed from the server.  Please remove this setting.");
    }
    final Map<String, Object> newOptions = extractOptions(indexed.options());
    if (!extractOptions(indexed).isEmpty() && !newOptions.isEmpty()) {
        throw new MappingException("Mixed usage of deprecated @Indexed values with the new @IndexOption values is not "
                                       + "allowed.  Please migrate all settings to @IndexOptions");
    }

    List<Field> fields = Collections.<Field>singletonList(new FieldBuilder()
                                                              .value(nameToStore)
                                                              .type(fromValue(indexed.value().toIndexValue())));
    return newOptions.isEmpty()
           ? new IndexBuilder()
               .options(new IndexOptionsBuilder()
                            .migrate(indexed))
               .fields(fields)
           : new IndexBuilder()
               .options(indexed.options())
               .fields(fields);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:24,代码来源:IndexHelper.java

示例2: oldIndexedForm

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
@Test
@SuppressWarnings("deprecation")
public void oldIndexedForm() {
    Indexed indexed = new IndexedBuilder()
        .name("index_name")
        .background(true)
        .dropDups(true)
        .expireAfterSeconds(42)
        .sparse(true)
        .unique(true)
        .value(IndexDirection.DESC);
    assertEquals(indexed.options().name(), "");

    Index converted = indexHelper.convert(indexed, "oldstyle");
    assertEquals(converted.options().name(), "index_name");
    assertTrue(converted.options().background());
    assertTrue(converted.options().dropDups());
    assertTrue(converted.options().sparse());
    assertTrue(converted.options().unique());
    assertEquals(new FieldBuilder().value("oldstyle").type(IndexType.DESC), converted.fields()[0]);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:22,代码来源:IndexHelperTest.java

示例3: normalizeIndexed

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
@Test
@SuppressWarnings("deprecation")
public void normalizeIndexed() {
    Indexed indexed = new IndexedBuilder()
        .value(IndexDirection.DESC)
        .options(new IndexOptionsBuilder().name("index_name")
                                          .background(true)
                                          .dropDups(true)
                                          .expireAfterSeconds(42)
                                          .sparse(true)
                                          .unique(true));

    Index converted = indexHelper.convert(indexed, "oldstyle");
    assertEquals(converted.options().name(), "index_name");
    assertTrue(converted.options().background());
    assertTrue(converted.options().dropDups());
    assertTrue(converted.options().sparse());
    assertTrue(converted.options().unique());
    assertEquals(new FieldBuilder().value("oldstyle").type(IndexType.DESC), converted.fields()[0]);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:21,代码来源:IndexHelperTest.java

示例4: collectFieldIndexes

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private List<Index> collectFieldIndexes(final MappedClass mc) {
    List<Index> list = new ArrayList<Index>();
    for (final MappedField mf : mc.getPersistenceFields()) {
        if (mf.hasAnnotation(Indexed.class)) {
            final Indexed indexed = mf.getAnnotation(Indexed.class);
            list.add(convert(indexed, mf.getNameToStore()));
        } else if (mf.hasAnnotation(Text.class)) {
            final Text text = mf.getAnnotation(Text.class);
            list.add(convert(text, mf.getNameToStore()));
        }
    }
    return list;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:15,代码来源:IndexHelper.java

示例5: extractOptions

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
private Map<String, Object> extractOptions(final Indexed indexed) {
    Map<String, Object> map = toMap(indexed);
    if (indexed.options().collation().locale().equals("")) {
        map.remove("options");
    }
    map.remove("value");
    return map;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:9,代码来源:IndexHelper.java

示例6: builders

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
@Test
public void builders() throws NoSuchMethodException {
    compareFields(Index.class, IndexBuilder.class);
    compareFields(IndexOptions.class, IndexOptionsBuilder.class);
    compareFields(Indexed.class, IndexedBuilder.class);
    compareFields(Field.class, FieldBuilder.class);
    compareFields(Collation.class, CollationBuilder.class);
    compareFields(Text.class, TextBuilder.class);
    compareFields(Validation.class, ValidationBuilder.class);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:11,代码来源:AnnotationBuilderTest.java

示例7: indexedPartialFilters

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
@Test
public void indexedPartialFilters() {
    MongoCollection<Document> collection = getDatabase().getCollection("indexes");
    MappedClass mappedClass = getMorphia().getMapper().getMappedClass(IndexedClass.class);

    Indexed indexed = new IndexedBuilder()
        .options(new IndexOptionsBuilder()
                     .partialFilter("{ name : { $gt : 13 } }"));

    indexHelper.createIndex(collection, mappedClass, indexHelper.convert(indexed, "text"), false);
    findPartialIndex(BasicDBObject.parse(indexed.options().partialFilter()));
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:13,代码来源:IndexHelperTest.java

示例8: annotationType

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
@Override
public Class<Indexed> annotationType() {
    return Indexed.class;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:5,代码来源:IndexedBuilder.java

示例9: migrate

import org.mongodb.morphia.annotations.Indexed; //导入依赖的package包/类
IndexOptionsBuilder migrate(final Indexed index) {
    putAll(toMap(index));
    return this;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:5,代码来源:IndexOptionsBuilder.java


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