use of org.mongodb.morphia.annotations.Embedded in project morphia by mongodb.
the class Morphia method mapPackage.
/**
* Tries to map all classes in the package specified.
*
* @param packageName the name of the package to process
* @param ignoreInvalidClasses specifies whether to ignore classes in the package that cannot be mapped
* @return the Morphia instance
*/
public synchronized Morphia mapPackage(final String packageName, final boolean ignoreInvalidClasses) {
try {
for (final Class clazz : ReflectionUtils.getClasses(packageName, mapper.getOptions().isMapSubPackages())) {
try {
final Embedded embeddedAnn = ReflectionUtils.getClassEmbeddedAnnotation(clazz);
final Entity entityAnn = ReflectionUtils.getClassEntityAnnotation(clazz);
final boolean isAbstract = Modifier.isAbstract(clazz.getModifiers());
if ((entityAnn != null || embeddedAnn != null) && !isAbstract) {
map(clazz);
}
} catch (final MappingException ex) {
if (!ignoreInvalidClasses) {
throw ex;
}
}
}
return this;
} catch (IOException e) {
throw new MappingException("Could not get map classes from package " + packageName, e);
} catch (ClassNotFoundException e) {
throw new MappingException("Could not get map classes from package " + packageName, e);
}
}
use of org.mongodb.morphia.annotations.Embedded in project morphia by mongodb.
the class MappedField method getConcreteType.
/**
* @return the concrete type of the MappedField
*/
public Class getConcreteType() {
final Embedded e = getAnnotation(Embedded.class);
if (e != null) {
final Class concrete = e.concreteClass();
if (concrete != Object.class) {
return concrete;
}
}
final Property p = getAnnotation(Property.class);
if (p != null) {
final Class concrete = p.concreteClass();
if (concrete != Object.class) {
return concrete;
}
}
return getType();
}
use of org.mongodb.morphia.annotations.Embedded in project querydsl by querydsl.
the class MorphiaAnnotationProcessor method createConfiguration.
@Override
protected Configuration createConfiguration(RoundEnvironment roundEnv) {
Class<? extends Annotation> entities = QueryEntities.class;
Class<? extends Annotation> entity = Entity.class;
Class<? extends Annotation> superType = QuerySupertype.class;
Class<? extends Annotation> embedded = Embedded.class;
Class<? extends Annotation> skip = Transient.class;
DefaultConfiguration conf = new DefaultConfiguration(processingEnv, roundEnv, Collections.<String>emptySet(), entities, entity, superType, null, embedded, skip);
try {
// Point is an Expression<Double[]>
@SuppressWarnings("unchecked") Class<? extends Expression<Double[]>> cl = (Class<? extends Expression<Double[]>>) Class.forName("com.querydsl.mongodb.Point");
conf.addCustomType(Double[].class, cl);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(e);
}
return conf;
}
Aggregations