Skip to content
Snippets Groups Projects
Commit f1b30d59 authored by Sören Henning's avatar Sören Henning
Browse files

replaced lists with maps

parent 7777ae8a
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
Pipeline #
package kieker.analysis.domain.systemdependency; package kieker.analysis.domain.systemdependency;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class Component extends SystemEntity { public class Component extends SystemEntity {
private final Container container; private final Container container;
private final Collection<Operation> operations = new ArrayList<>(); private final Map<String, Operation> operations = new HashMap<>();
public Component(final String name, final Container container) { public Component(final String name, final Container container) {
super(name, container.getIdentifier() + ',' + name); super(name, container.getIdentifier() + ',' + name);
...@@ -19,11 +20,11 @@ public class Component extends SystemEntity { ...@@ -19,11 +20,11 @@ public class Component extends SystemEntity {
} }
public Collection<Operation> getOperations() { public Collection<Operation> getOperations() {
return operations; return operations.values();
} }
protected void addOperation(final Operation operation) { protected void addOperation(final Operation operation) {
this.operations.add(operation); this.operations.put(operation.getName(), operation);
} }
} }
package kieker.analysis.domain.systemdependency; package kieker.analysis.domain.systemdependency;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class Container extends SystemEntity { public class Container extends SystemEntity {
private final Collection<Component> components = new ArrayList<>(); private final Map<String, Component> components = new HashMap<>();
public Container(final String name) { public Container(final String name) {
super(name, name); super(name, name);
} }
public Collection<Component> getComponents() { public Collection<Component> getComponents() {
return components; return components.values();
} }
protected void addComponent(final Component component) { protected void addComponent(final Component component) {
this.components.add(component); this.components.put(component.getName(), component);
} }
} }
...@@ -2,10 +2,12 @@ package kieker.analysis.domain.systemdependency; ...@@ -2,10 +2,12 @@ package kieker.analysis.domain.systemdependency;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class SoftwareSystem { public class SoftwareSystem {
private Collection<Container> containers = new ArrayList<>(); private final Map<String, Container> containers = new HashMap<>();
private Collection<Dependency<Container>> containerDependencies = new ArrayList<>(); private Collection<Dependency<Container>> containerDependencies = new ArrayList<>();
private Collection<Dependency<Component>> componentDependencies = new ArrayList<>(); private Collection<Dependency<Component>> componentDependencies = new ArrayList<>();
...@@ -14,11 +16,11 @@ public class SoftwareSystem { ...@@ -14,11 +16,11 @@ public class SoftwareSystem {
public SoftwareSystem() {} public SoftwareSystem() {}
public Collection<Container> getContainers() { public Collection<Container> getContainers() {
return containers; return containers.values();
} }
public void setContainers(final Collection<Container> containers) { public void addContainer(final Container container) {
this.containers = containers; containers.put(container.getName(), container);
} }
public Collection<Dependency<Container>> getContainerDependencies() { public Collection<Dependency<Container>> getContainerDependencies() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment