@Test public void filterConsumersShouldReturnOnlyConsumer() { Dependency dependencyB = Dependency.on(dependencyComponent); Consumer consumerC = Consumer.by(consumerComponent); Set<Consumer> expected = new HashSet<>(); expected.add(consumerC); Set<Consumer> actual = ComponentRelationships.filterConsumers(Arrays.asList(dependencyB, consumerC)); Assert.assertEquals(expected, actual); }
public static Set<Consumer> filterConsumers(Collection<Relationship> relationships) { Objects.requireNonNull(relationships, "relationship collection required"); return relationships.stream() .filter(rel -> rel instanceof Consumer) .map(rel -> (Consumer) rel) .collect(Collectors.toSet()); }
ComponentRelationships { public static Set<Consumer> filterConsumers(Collection<Relationship> relationships) { Objects.requireNonNull(relationships, "relationship collection required"); return relationships.stream() .filter(rel -> rel instanceof Consumer) .map(rel -> (Consumer) rel) .collect(Collectors.toSet()); } }
ComponentRelationships { public static Set<Consumer> filterConsumers(Collection<Relationship> relationships) { Objects.requireNonNull(relationships, "relationship collection required"); return relationships.stream() .filter(rel -> rel instanceof Consumer) .map(rel -> (Consumer) rel) .collect(Collectors.toSet()); } @JsonCreator  ComponentRelationships(@JsonProperty("component") Component component,
            @JsonProperty("dependencies") Set<Dependency> dependencies,
            @JsonProperty("consumers") Set<Consumer> consumers); }
ComponentRelationships { public static Set<Consumer> filterConsumers(Collection<Relationship> relationships) { Objects.requireNonNull(relationships, "relationship collection required"); return relationships.stream() .filter(rel -> rel instanceof Consumer) .map(rel -> (Consumer) rel) .collect(Collectors.toSet()); } @JsonCreator  ComponentRelationships(@JsonProperty("component") Component component,
            @JsonProperty("dependencies") Set<Dependency> dependencies,
            @JsonProperty("consumers") Set<Consumer> consumers); static ComponentRelationships of(Component component, Set<Dependency> dependencies,
            Set<Consumer> consumers); static ComponentRelationships of(Component component, Collection<Relationship> relationships); static ComponentRelationships of(Component component, Relationship... relationships); static Set<Consumer> filterConsumers(Collection<Relationship> relationships); static Set<Dependency> filterDependencies(Collection<Relationship> relationships); boolean hasRelationships(); @Override int hashCode(); @Override boolean equals(Object o); Component getComponent(); Set<Dependency> getDependencies(); Set<Consumer> getConsumers(); @JsonIgnore Set<Relationship> getRelationships(); static ComponentRelationshipsBuilder builder(); }
ComponentRelationships { public static Set<Consumer> filterConsumers(Collection<Relationship> relationships) { Objects.requireNonNull(relationships, "relationship collection required"); return relationships.stream() .filter(rel -> rel instanceof Consumer) .map(rel -> (Consumer) rel) .collect(Collectors.toSet()); } @JsonCreator  ComponentRelationships(@JsonProperty("component") Component component,
            @JsonProperty("dependencies") Set<Dependency> dependencies,
            @JsonProperty("consumers") Set<Consumer> consumers); static ComponentRelationships of(Component component, Set<Dependency> dependencies,
            Set<Consumer> consumers); static ComponentRelationships of(Component component, Collection<Relationship> relationships); static ComponentRelationships of(Component component, Relationship... relationships); static Set<Consumer> filterConsumers(Collection<Relationship> relationships); static Set<Dependency> filterDependencies(Collection<Relationship> relationships); boolean hasRelationships(); @Override int hashCode(); @Override boolean equals(Object o); Component getComponent(); Set<Dependency> getDependencies(); Set<Consumer> getConsumers(); @JsonIgnore Set<Relationship> getRelationships(); static ComponentRelationshipsBuilder builder();  }