• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Field类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseFieldsString

import org.mongodb.morphia.annotations.Field; //导入依赖的package包/类
private List<Field> parseFieldsString(final String str) {
    List<Field> fields = new ArrayList<Field>();
    final String[] parts = str.split(",");
    for (String s : parts) {
        s = s.trim();
        IndexType dir = IndexType.ASC;

        if (s.startsWith("-")) {
            dir = IndexType.DESC;
            s = s.substring(1).trim();
        }

        fields.add(new FieldBuilder()
                       .value(s)
                       .type(dir));
    }
    return fields;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:19,代码来源:IndexBuilder.java


示例2: convert

import org.mongodb.morphia.annotations.Field; //导入依赖的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


示例3: calculateKeys

import org.mongodb.morphia.annotations.Field; //导入依赖的package包/类
BsonDocument calculateKeys(final MappedClass mc, final Index index) {
    BsonDocument keys = new BsonDocument();
    for (Field field : index.fields()) {
        String path;
        try {
            path = findField(mc, index.options(), new ArrayList<String>(asList(field.value().split("\\."))));
        } catch (Exception e) {
            path = field.value();
            String message = format("The path '%s' can not be validated against '%s' and may represent an invalid index",
                                    path, mc.getClazz().getName());
            if (!index.options().disableValidation()) {
                throw new MappingException(message);
            }
            LOG.warning(message);
        }
        keys.putAll(toBsonDocument(path, field.type().toIndexValue()));
    }
    return keys;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:20,代码来源:IndexHelper.java


示例4: calculateWeights

import org.mongodb.morphia.annotations.Field; //导入依赖的package包/类
private void calculateWeights(final Index index, final com.mongodb.client.model.IndexOptions indexOptions) {
    Document weights = new Document();
    for (Field field : index.fields()) {
        if (field.weight() != -1) {
            if (field.type() != IndexType.TEXT) {
                throw new MappingException("Weight values only apply to text indexes: " + Arrays.toString(index.fields()));
            }
            weights.put(field.value(), field.weight());
        }
    }
    if (!weights.isEmpty()) {
        indexOptions.weights(weights);
    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:15,代码来源:IndexHelper.java


示例5: collectNestedIndexes

import org.mongodb.morphia.annotations.Field; //导入依赖的package包/类
private List<Index> collectNestedIndexes(final MappedClass mc, final List<MappedClass> parentMCs) {
    List<Index> list = new ArrayList<Index>();
    for (final MappedField mf : mc.getPersistenceFields()) {
        if (!mf.isTypeMongoCompatible() && !mf.hasAnnotation(Reference.class) && !mf.hasAnnotation(Serialized.class)
            && !mf.hasAnnotation(NotSaved.class) && !mf.isTransient()) {

            final List<MappedClass> parents = new ArrayList<MappedClass>(parentMCs);
            parents.add(mc);

            List<MappedClass> classes = new ArrayList<MappedClass>();
            MappedClass mappedClass = mapper.getMappedClass(mf.isSingleValue() ? mf.getType() : mf.getSubClass());
            classes.add(mappedClass);
            classes.addAll(mapper.getSubTypes(mappedClass));
            for (MappedClass aClass : classes) {
                for (Index index : collectIndexes(aClass, parents)) {
                    List<Field> fields = new ArrayList<Field>();
                    for (Field field : index.fields()) {
                        fields.add(new FieldBuilder()
                                       .value(field.value().equals("$**")
                                              ? field.value()
                                              : mf.getNameToStore() + "." + field.value())
                                       .type(field.type())
                                       .weight(field.weight()));
                    }
                    list.add(new IndexBuilder(index)
                                 .fields(fields));
                }
            }
        }
    }

    return list;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:34,代码来源:IndexHelper.java


示例6: builders

import org.mongodb.morphia.annotations.Field; //导入依赖的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: getIdField

import org.mongodb.morphia.annotations.Field; //导入依赖的package包/类
/**
 * @return the idField
 */
public java.lang.reflect.Field getIdField() {
    return idField;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:7,代码来源:MappedClass.java


示例8: isIgnorable

import org.mongodb.morphia.annotations.Field; //导入依赖的package包/类
private boolean isIgnorable(final java.lang.reflect.Field field, final int fieldMods, final Mapper mapper) {
    return field.isAnnotationPresent(Transient.class)
           || Modifier.isTransient(fieldMods)
           || field.isSynthetic() && Modifier.isTransient(fieldMods)
           || mapper.getOptions().isIgnoreFinals() && Modifier.isFinal(fieldMods);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:7,代码来源:MappedClass.java


示例9: annotationType

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


示例10: fields

import org.mongodb.morphia.annotations.Field; //导入依赖的package包/类
@Override
public Field[] fields() {
    return get("fields");
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:5,代码来源:IndexBuilder.java


示例11: replaceFields

import org.mongodb.morphia.annotations.Field; //导入依赖的package包/类
private Index replaceFields(final Index original, final List<Field> list) {
    return new IndexBuilder(original)
        .fields(list);
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:5,代码来源:IndexHelper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SnapshotVersion类代码示例发布时间:2022-05-23
下一篇:
Java ClientBuilder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap