本文整理汇总了Java中org.mongodb.morphia.annotations.Embedded类的典型用法代码示例。如果您正苦于以下问题:Java Embedded类的具体用法?Java Embedded怎么用?Java Embedded使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Embedded类属于org.mongodb.morphia.annotations包,在下文中一共展示了Embedded类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConfiguration
import org.mongodb.morphia.annotations.Embedded; //导入依赖的package包/类
protected Configuration createConfiguration(RoundEnvironment roundEnv) {
Class entities = QueryEntities.class;
Class entity = Entity.class;
Class superType = QuerySupertype.class;
Class embedded = Embedded.class;
Class skip = Transient.class;
DefaultConfiguration conf = new DefaultConfiguration(roundEnv, this.processingEnv.getOptions(), Collections.emptySet(), entities, entity, superType, (Class)null, embedded, skip);
try {
Class e = Class.forName("com.egopulse.querydsl.mongodb.Point");
conf.addCustomType(Double[].class, e);
return conf;
} catch (ClassNotFoundException var9) {
throw new IllegalStateException(var9);
}
}
示例2: writeMappedField
import org.mongodb.morphia.annotations.Embedded; //导入依赖的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);
}
}
示例3: check
import org.mongodb.morphia.annotations.Embedded; //导入依赖的package包/类
@Override
public void check(final Mapper mapper, final MappedClass mc, final Set<ConstraintViolation> ve) {
if (mc.getEntityAnnotation() != null && mc.getEmbeddedAnnotation() != null) {
ve.add(new ConstraintViolation(Level.FATAL, mc, getClass(), format("Cannot have both @%s and @%s annotation at class level.",
Entity.class.getSimpleName(), Embedded.class.getSimpleName())));
}
}
示例4: check
import org.mongodb.morphia.annotations.Embedded; //导入依赖的package包/类
@Override
public void check(final Mapper mapper, final MappedClass mc, final Set<ConstraintViolation> ve) {
if (mc.getEmbeddedAnnotation() != null && mc.getIdField() != null) {
ve.add(new ConstraintViolation(Level.FATAL, mc, getClass(),
"@" + Embedded.class.getSimpleName() + " classes cannot specify a @Id field"));
}
}
示例5: check
import org.mongodb.morphia.annotations.Embedded; //导入依赖的package包/类
@Override
public void check(final Mapper mapper, final MappedClass mc, final Set<ConstraintViolation> ve) {
if (mc.getEmbeddedAnnotation() != null && !mc.getEmbeddedAnnotation().value().equals(Mapper.IGNORED_FIELDNAME)) {
ve.add(new ConstraintViolation(Level.FATAL, mc, getClass(),
"@" + Embedded.class.getSimpleName()
+ " classes cannot specify a fieldName value(); this is on applicable on fields"));
}
}
示例6: getConstraints
import org.mongodb.morphia.annotations.Embedded; //导入依赖的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;
}
示例7: check
import org.mongodb.morphia.annotations.Embedded; //导入依赖的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)"));
}
}
}
示例8: update
import org.mongodb.morphia.annotations.Embedded; //导入依赖的package包/类
/**
* Update mappings based on fields/annotations.
*/
// TODO: Remove this and make these fields dynamic or auto-set some other way
public void update() {
embeddedAn = (Embedded) getAnnotation(Embedded.class);
entityAn = (Entity) getFirstAnnotation(Entity.class);
// polymorphicAn = (Polymorphic) getAnnotation(Polymorphic.class);
final List<MappedField> fields = getFieldsAnnotatedWith(Id.class);
if (fields != null && !fields.isEmpty()) {
idField = fields.get(0).getField();
}
}
示例9: getFieldAnnotation
import org.mongodb.morphia.annotations.Embedded; //导入依赖的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;
}
示例10: readMappedField
import org.mongodb.morphia.annotations.Embedded; //导入依赖的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);
}
}
示例11: hasAnnotation
import org.mongodb.morphia.annotations.Embedded; //导入依赖的package包/类
@Override
public boolean hasAnnotation(final Class ann) {
return Embedded.class.equals(ann);
}
示例12: getEmbeddedAnnotation
import org.mongodb.morphia.annotations.Embedded; //导入依赖的package包/类
/**
* @return the embeddedAn
*/
public Embedded getEmbeddedAnnotation() {
return embeddedAn;
}
示例13: getClassEmbeddedAnnotation
import org.mongodb.morphia.annotations.Embedded; //导入依赖的package包/类
/**
* Returns the @Embedded annotation on a Class if present
*
* @param c the class to examine
* @return the annotation. may be null.
*/
public static Embedded getClassEmbeddedAnnotation(final Class c) {
return getAnnotation(c, Embedded.class);
}