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

Java Property类代码示例

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

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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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