final TypeContainer typeContainer = policy.getTypeContainer();
String typeName = typeContainer.getName();
Type type = typeContainer.getType();
if (typeName != null && type == null) {
// this is a reference to a declared type.
TypeDeclaration declaration = definitions.getType(typeName);
if (declaration == null) {
throw new RepositoryException(EXCEPTION_LOCALIZER.format(
"repository-unable-to-find-type-information",
typeName));
}
type = declaration.getType();
} else if (typeName == null && type != null) {
// this is an anonymous type
} else if (typeName == null && type == null) {
// nothing specified, error.