public ClassDiagramAssociation(PlantUmlDiagram diagram)
        {
            var components = ImmutableHashSet.CreateBuilder <AssociatedComponent>();

            ValidateStereotypes(diagram);
            foreach (var component in diagram.AllComponents)
            {
                components.Add(new AssociatedComponent(component));
            }
            _components = components.ToImmutable();
        }
        private void ValidateStereotypes(PlantUmlDiagram plantUmlDiagram)
        {
            ISet <Stereotype> visited = new HashSet <Stereotype>();

            foreach (PlantUmlComponent component in plantUmlDiagram.AllComponents)
            {
                foreach (Stereotype stereotype in component.Stereotypes)
                {
                    if (visited.Contains(stereotype))
                    {
                        throw new IllegalDiagramException(string.Format("Stereotype '{0}' should be unique", stereotype.AsString()));
                    }
                    visited.Add(stereotype);
                }
            }
        }