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


Java Property类代码示例

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


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

示例1: writeMappedField

import org.mongodb.morphia.annotations.Property; //导入依赖的package包/类
private void writeMappedField(final DBObject dbObject, final MappedField mf, final Object entity,
                              final Map<Object, DBObject> involvedObjects) {

    //skip not saved fields.
    if (mf.hasAnnotation(NotSaved.class)) {
        return;
    }

    // get the annotation from the field.
    Class<? extends Annotation> annType = getFieldAnnotation(mf);

    if (Property.class.equals(annType) || Serialized.class.equals(annType) || mf.isTypeMongoCompatible()
        || (getConverters().hasSimpleValueConverter(mf) || (getConverters().hasSimpleValueConverter(mf.getFieldValue(entity))))) {
        opts.getValueMapper().toDBObject(entity, mf, dbObject, involvedObjects, this);
    } else if (Reference.class.equals(annType)) {
        opts.getReferenceMapper().toDBObject(entity, mf, dbObject, involvedObjects, this);
    } else if (Embedded.class.equals(annType)) {
        opts.getEmbeddedMapper().toDBObject(entity, mf, dbObject, involvedObjects, this);
    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("No annotation was found, using default mapper " + opts.getDefaultMapper() + " for " + mf);
        }
        opts.getDefaultMapper().toDBObject(entity, mf, dbObject, involvedObjects, this);
    }

}
 
开发者ID:mongodb,项目名称:morphia,代码行数:27,代码来源:Mapper.java

示例2: getConstraints

import org.mongodb.morphia.annotations.Property; //导入依赖的package包/类
private List<ClassConstraint> getConstraints() {
    final List<ClassConstraint> constraints = new ArrayList<ClassConstraint>(32);

    // normally, i do this with scanning the classpath, but that´d bring
    // another dependency ;)

    // class-level
    constraints.add(new MultipleId());
    constraints.add(new MultipleVersions());
    constraints.add(new NoId());
    constraints.add(new EmbeddedAndId());
    constraints.add(new EntityAndEmbed());
    constraints.add(new EmbeddedAndValue());
    constraints.add(new EntityCannotBeMapOrIterable());
    constraints.add(new DuplicatedAttributeNames());
    // constraints.add(new ContainsEmbeddedWithId());
    // field-level
    constraints.add(new MisplacedProperty());
    constraints.add(new ReferenceToUnidentifiable());
    constraints.add(new LazyReferenceMissingDependencies());
    constraints.add(new LazyReferenceOnArray());
    constraints.add(new MapKeyDifferentFromString());
    constraints.add(new MapNotSerializable());
    constraints.add(new VersionMisuse(creator));
    //
    constraints.add(new ContradictingFieldAnnotation(Reference.class, Serialized.class));
    constraints.add(new ContradictingFieldAnnotation(Reference.class, Property.class));
    constraints.add(new ContradictingFieldAnnotation(Reference.class, Embedded.class));
    //
    constraints.add(new ContradictingFieldAnnotation(Embedded.class, Serialized.class));
    constraints.add(new ContradictingFieldAnnotation(Embedded.class, Property.class));
    //
    constraints.add(new ContradictingFieldAnnotation(Property.class, Serialized.class));

    return constraints;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:37,代码来源:MappingValidator.java

示例3: check

import org.mongodb.morphia.annotations.Property; //导入依赖的package包/类
@Override
protected void check(final Mapper mapper, final MappedClass mc, final MappedField mf, final Set<ConstraintViolation> ve) {
    // an @Id field can not be a Value, Reference, or Embedded
    if (mf.hasAnnotation(Id.class)) {
        if (mf.hasAnnotation(Reference.class) || mf.hasAnnotation(Embedded.class) || mf.hasAnnotation(Property.class)) {
            ve.add(new ConstraintViolation(Level.FATAL, mc, mf, getClass(),
                                           mf.getFullName() + " is annotated as @" + Id.class.getSimpleName()
                                           + " and cannot be mixed with other annotations (like @Reference)"));
        }
    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:12,代码来源:IdDoesNotMix.java

示例4: check

import org.mongodb.morphia.annotations.Property; //导入依赖的package包/类
@Override
protected void check(final Mapper mapper, final MappedClass mc, final MappedField mf, final Set<ConstraintViolation> ve) {
    // a field can be a Value, Reference, or Embedded
    if (mf.hasAnnotation(Property.class)) {
        // make sure that the property type is supported
        if (mf.isSingleValue() && !mf.isTypeMongoCompatible() && !mapper.getConverters().hasSimpleValueConverter(mf)) {
            ve.add(new ConstraintViolation(Level.WARNING, mc, mf, getClass(),
                                           mf.getFullName() + " is annotated as @" + Property.class.getSimpleName()
                                           + " but is a type that cannot be mapped simply (type is "
                                           + mf.getType().getName() + ")."));
        }
    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:14,代码来源:MisplacedProperty.java

示例5: getFieldAnnotation

import org.mongodb.morphia.annotations.Property; //导入依赖的package包/类
private Class<? extends Annotation> getFieldAnnotation(final MappedField mf) {
    Class<? extends Annotation> annType = null;
    for (final Class<? extends Annotation> testType : new Class[]{Property.class, Embedded.class, Serialized.class, Reference.class}) {
        if (mf.hasAnnotation(testType)) {
            annType = testType;
            break;
        }
    }
    return annType;
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:11,代码来源:Mapper.java

示例6: readMappedField

import org.mongodb.morphia.annotations.Property; //导入依赖的package包/类
private void readMappedField(final Datastore datastore, final MappedField mf, final Object entity, final EntityCache cache,
                             final DBObject dbObject) {
    if (mf.hasAnnotation(Property.class) || mf.hasAnnotation(Serialized.class)
        || mf.isTypeMongoCompatible() || getConverters().hasSimpleValueConverter(mf)) {
        opts.getValueMapper().fromDBObject(datastore, dbObject, mf, entity, cache, this);
    } else if (mf.hasAnnotation(Embedded.class)) {
        opts.getEmbeddedMapper().fromDBObject(datastore, dbObject, mf, entity, cache, this);
    } else if (mf.hasAnnotation(Reference.class)) {
        opts.getReferenceMapper().fromDBObject(datastore, dbObject, mf, entity, cache, this);
    } else {
        opts.getDefaultMapper().fromDBObject(datastore, dbObject, mf, entity, cache, this);
    }
}
 
开发者ID:mongodb,项目名称:morphia,代码行数:14,代码来源:Mapper.java


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