@Test public void components_are_identified_by_name() { Level level = new Level("dummy"); Component a = level.component("a"); Component b = level.component("b"); assertThat(a).isNotSameAs(b); Component secondReferenceToA = level.component("a"); assertThat(a).isSameAs(secondReferenceToA); }
Component component(String name) { for (Component component : components) { if (component.name.equals(name)) { return component; } } Component component = new Component(name); components.add(component); return component; }
Level { Component component(String name) { for (Component component : components) { if (component.name.equals(name)) { return component; } } Component component = new Component(name); components.add(component); return component; } }
Level { Component component(String name) { for (Component component : components) { if (component.name.equals(name)) { return component; } } Component component = new Component(name); components.add(component); return component; } Level(String name); }
Level { Component component(String name) { for (Component component : components) { if (component.name.equals(name)) { return component; } } Component component = new Component(name); components.add(component); return component; } Level(String name); int maxComponentSize(); int sumComponentSize(); int maxDependencyStrength(); String formatted(); }
Level { Component component(String name) { for (Component component : components) { if (component.name.equals(name)) { return component; } } Component component = new Component(name); components.add(component); return component; } Level(String name); int maxComponentSize(); int sumComponentSize(); int maxDependencyStrength(); String formatted(); final String name; public Collection<Component> components; public Collection<ComponentDep> dependencies; }