class AnnotatedObjectFactory {

    public <T> Map<RepositoryObjectKey, T> createObjects(Class<T> objectClass, Annotation annotation) {
        Map<String, T> rawObjectInstances;

        ObjectInstance[] instanceDescriptors = extractInstanceDescriptors(annotation);
        if (instanceDescriptors.length > 0) {
            rawObjectInstances = createObjectsFromInstanceDescriptors(objectClass, instanceDescriptors);
        } else {
            rawObjectInstances = createObject(objectClass, annotation);
        }


        int objectOrder = extractOrder(annotation);
        Map<RepositoryObjectKey, T> createdObjects = new HashMap<RepositoryObjectKey, T>();
        for (Entry<String, T> objectEntry : rawObjectInstances.entrySet()) {
            createdObjects.put(new RepositoryObjectKey(objectEntry.getKey(), objectOrder), objectEntry.getValue());
        }

        return createdObjects;
    }

}