public ChainSpecification(ComponentId componentId, Inheritance inheritance, Collection<Phase> phases, Set<ComponentSpecification> componentReferences) { assertNotNull(componentId, inheritance, phases, componentReferences); if (componentsByName(componentReferences).size() != componentReferences.size()) throw new RuntimeException("Two components with the same name are specified in '" + componentId + "', but name must be unique inside a given chain."); this.componentId = componentId; this.inheritance = inheritance; this.phases = copyPhasesImmutable(phases); this.componentReferences = ImmutableSet.copyOf( filterByComponentSpecification(componentReferences, inheritance.excludedComponents)); }