本文整理汇总了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;未经允许,请勿转载。 |
请发表评论