clazz = first( iter.next().model().types() );
if( iter.hasNext() )
{
// Ambiguous exception
throw new ClassNotFoundException( name, new AmbiguousTypeException(
"More than one model matches the classname " + name + ":" + toList( moduleModels ) ) );
}
}
}
// Check layer
if( clazz == null )
{
Iterable<ModelModule<ModelDescriptor>> flatten = cast( flatten(
cast( moduleInstance.layerInstance().visibleObjects( Visibility.layer ) ),
cast( moduleInstance.layerInstance().visibleTransients( Visibility.layer ) ),
cast( moduleInstance.layerInstance().visibleEntities( Visibility.layer ) ),
cast( moduleInstance.layerInstance().visibleValues( Visibility.layer ) ),
cast( moduleInstance.layerInstance().visibleObjects( Visibility.application ) ),
cast( moduleInstance.layerInstance().visibleTransients( Visibility.application ) ),
cast( moduleInstance.layerInstance().visibleEntities( Visibility.application ) ),
cast( moduleInstance.layerInstance().visibleValues( Visibility.application ) ) ) );
Iterable<ModelModule<ModelDescriptor>> layerModels = filter( translate, flatten );
Iterator<ModelModule<ModelDescriptor>> iter = layerModels.iterator();
if( iter.hasNext() )
{
clazz = first( iter.next().model().types() );
if( iter.hasNext() )
{
// Ambiguous exception
throw new ClassNotFoundException( name, new AmbiguousTypeException(
"More than one model matches the classname " + name + ":" + toList( layerModels ) ) );
}
}
}
// Check used layers
if( clazz == null )
{
Iterable<ModelModule<ModelDescriptor>> flatten = cast( flatten(
cast( moduleInstance.layerInstance().usedLayersInstance().visibleObjects() ),
cast( moduleInstance.layerInstance().usedLayersInstance().visibleTransients() ),
cast( moduleInstance.layerInstance().usedLayersInstance().visibleEntities() ),
cast( moduleInstance.layerInstance().usedLayersInstance().visibleValues() ) ) );
Iterable<ModelModule<ModelDescriptor>> usedLayersModels = filter( translate, flatten );
Iterator<ModelModule<ModelDescriptor>> iter = usedLayersModels.iterator();
if( iter.hasNext() )
{
clazz = first( iter.next().model().types() );
if( iter.hasNext() )
{
// Ambiguous exception
throw new ClassNotFoundException( name, new AmbiguousTypeException(
"More than one model matches the classname " + name + ":" + toList( usedLayersModels ) ) );
}
}
}