&& (annotationType.isAnnotationPresent(Scope.class) || annotationType
.isAnnotationPresent(NormalScope.class)))
{
if (scope != null)
{
throw new DefinitionException("You cannot set several scopes to the class " + clazz.getName());
}
scope = annotationType;
}
else if (annotationType.isAnnotationPresent(Stereotype.class))
{
hasStereotype = true;
Annotation[] stereotypeAnnotations = annotationType.getAnnotations();
for (int j = 0; j < stereotypeAnnotations.length; j++)
{
Annotation stereotypeAnnotation = stereotypeAnnotations[j];
Class<? extends Annotation> stereotypeAnnotationType = stereotypeAnnotation.annotationType();
if (stereotypeAnnotationType.isAnnotationPresent(Scope.class)
|| stereotypeAnnotationType.isAnnotationPresent(NormalScope.class))
{
if (defaultScope != null && !defaultScope.equals(stereotypeAnnotationType))
{
throw new DefinitionException("The class " + clazz.getName()
+ " has stereotypes with different default scope");
}
defaultScope = stereotypeAnnotationType;
}
}
}
}
if (scope != null)
return scope;
if (defaultScope != null)
return defaultScope;
if (hasStereotype)
{
throw new DefinitionException("The class " + clazz.getName()
+ " has at least one stereotype but doesn't have any scope, please set an explicit scope");
}
return null;
}