@Test public void copy() { Application<Task, Dependency> app = new Application<Task, Dependency>(); Task task = new Task("t"); app.addVertex(task); Architecture<Resource, Link> arch = new Architecture<Resource, Link>(); Resource resource = new Resource("r"); arch.addVertex(resource); Mappings<Task, Resource> mappings = new Mappings<Task, Resource>(); Mapping<Task, Resource> mapping = new Mapping<Task, Resource>("m", task, resource); mappings.add(mapping); Specification spec = new Specification(app, arch, mappings); Specification spec2 = Models.copy(spec); Assert.assertEquals(1, spec2.getApplication().getVertexCount()); Assert.assertTrue(spec2.getApplication().containsVertex(task)); Assert.assertEquals(1, spec2.getArchitecture().getVertexCount()); Assert.assertTrue(spec2.getArchitecture().containsVertex(resource)); Assert.assertEquals(1, spec2.getMappings().size()); Assert.assertEquals(mapping, spec2.getMappings().get(task).iterator().next()); Assert.assertEquals(mapping, spec2.getMappings().get(resource).iterator().next()); }
public static Specification copy(Specification specification) { Architecture<Resource, Link> sArchitecture = specification.getArchitecture(); Application<Task, Dependency> sApplication = specification.getApplication(); Mappings<Task, Resource> sMappings = specification.getMappings(); Routings<Task, Resource, Link> sRoutings = specification.getRoutings(); Architecture<Resource, Link> iArchitecture = copy(sArchitecture); Application<Task, Dependency> iApplication = copy(sApplication); Mappings<Task, Resource> iMappings = copyMappings(sMappings, iArchitecture, iApplication); Routings<Task, Resource, Link> iRoutings = copyRoutings(sApplication, sRoutings, iApplication, iArchitecture); return new Specification(iApplication, iArchitecture, iMappings, iRoutings); }
Models { public static Specification copy(Specification specification) { Architecture<Resource, Link> sArchitecture = specification.getArchitecture(); Application<Task, Dependency> sApplication = specification.getApplication(); Mappings<Task, Resource> sMappings = specification.getMappings(); Routings<Task, Resource, Link> sRoutings = specification.getRoutings(); Architecture<Resource, Link> iArchitecture = copy(sArchitecture); Application<Task, Dependency> iApplication = copy(sApplication); Mappings<Task, Resource> iMappings = copyMappings(sMappings, iArchitecture, iApplication); Routings<Task, Resource, Link> iRoutings = copyRoutings(sApplication, sRoutings, iApplication, iArchitecture); return new Specification(iApplication, iArchitecture, iMappings, iRoutings); } }
Models { public static Specification copy(Specification specification) { Architecture<Resource, Link> sArchitecture = specification.getArchitecture(); Application<Task, Dependency> sApplication = specification.getApplication(); Mappings<Task, Resource> sMappings = specification.getMappings(); Routings<Task, Resource, Link> sRoutings = specification.getRoutings(); Architecture<Resource, Link> iArchitecture = copy(sArchitecture); Application<Task, Dependency> iApplication = copy(sApplication); Mappings<Task, Resource> iMappings = copyMappings(sMappings, iArchitecture, iApplication); Routings<Task, Resource, Link> iRoutings = copyRoutings(sApplication, sRoutings, iApplication, iArchitecture); return new Specification(iApplication, iArchitecture, iMappings, iRoutings); }  }
Models { public static Specification copy(Specification specification) { Architecture<Resource, Link> sArchitecture = specification.getArchitecture(); Application<Task, Dependency> sApplication = specification.getApplication(); Mappings<Task, Resource> sMappings = specification.getMappings(); Routings<Task, Resource, Link> sRoutings = specification.getRoutings(); Architecture<Resource, Link> iArchitecture = copy(sArchitecture); Application<Task, Dependency> iApplication = copy(sApplication); Mappings<Task, Resource> iMappings = copyMappings(sMappings, iArchitecture, iApplication); Routings<Task, Resource, Link> iRoutings = copyRoutings(sApplication, sRoutings, iApplication, iArchitecture); return new Specification(iApplication, iArchitecture, iMappings, iRoutings); }  static Iterable<Task> filterCommunications(final Iterable<Task> iterable); static Iterable<Task> filterProcesses(final Iterable<Task> iterable); static boolean isProcess(Task task); static boolean isCommunication(Task task); static List<DirectedLink> getOutLinks(Architecture<Resource, Link> architecture, Resource r0); static List<DirectedLink> getInLinks(Architecture<Resource, Link> architecture, Resource r0); static List<DirectedLink> getLinks(Architecture<Resource, Link> architecture); static List<DirectedLink> getLinks(Architecture<Resource, Link> architecture, Link link); static Map<String, Element> getElementsMap(Specification specification); static Set<Element> getElements(Specification specification); static Iterable<E> filterType(final Iterable<E> iterable, final String... types); static Specification copy(Specification specification); static Routings<Task, Resource, Link> copyRoutings(Application<Task, Dependency> sApplication,
			Routings<Task, Resource, Link> sRoutings, Application<Task, Dependency> iApplication,
			Architecture<Resource, Link> iArchitecture); static Mappings<Task, Resource> copyMappings(Mappings<Task, Resource> sMappings,
			Architecture<Resource, Link> iArchitecture, Application<Task, Dependency> iApplication); static Application<Task, Dependency> copy(Application<Task, Dependency> sApplication); static Architecture<Resource, Link> copy(Architecture<Resource, Link> sArchitecture); @SuppressWarnings("unchecked") static E copy(Element element); @SuppressWarnings("unchecked") static M copy(Mapping<?, ?> mapping); static void setAttributes(IAttributes e, Attributes attributes); static Specification clone(Specification specification); static Application<T, D> clone(Application<T, D> sApplication); static Architecture<R, L> clone(Architecture<R, L> sArchitecture); static void filterByResources(Specification specification, Collection<Resource> resources); static void filter(Specification specification, Collection<Function<Task, Dependency>> functions); static void filterByFunctionName(Specification specification, Collection<String> functions); static void filterByFunctionName(Specification specification, String... functions); }
Models { public static Specification copy(Specification specification) { Architecture<Resource, Link> sArchitecture = specification.getArchitecture(); Application<Task, Dependency> sApplication = specification.getApplication(); Mappings<Task, Resource> sMappings = specification.getMappings(); Routings<Task, Resource, Link> sRoutings = specification.getRoutings(); Architecture<Resource, Link> iArchitecture = copy(sArchitecture); Application<Task, Dependency> iApplication = copy(sApplication); Mappings<Task, Resource> iMappings = copyMappings(sMappings, iArchitecture, iApplication); Routings<Task, Resource, Link> iRoutings = copyRoutings(sApplication, sRoutings, iApplication, iArchitecture); return new Specification(iApplication, iArchitecture, iMappings, iRoutings); }  static Iterable<Task> filterCommunications(final Iterable<Task> iterable); static Iterable<Task> filterProcesses(final Iterable<Task> iterable); static boolean isProcess(Task task); static boolean isCommunication(Task task); static List<DirectedLink> getOutLinks(Architecture<Resource, Link> architecture, Resource r0); static List<DirectedLink> getInLinks(Architecture<Resource, Link> architecture, Resource r0); static List<DirectedLink> getLinks(Architecture<Resource, Link> architecture); static List<DirectedLink> getLinks(Architecture<Resource, Link> architecture, Link link); static Map<String, Element> getElementsMap(Specification specification); static Set<Element> getElements(Specification specification); static Iterable<E> filterType(final Iterable<E> iterable, final String... types); static Specification copy(Specification specification); static Routings<Task, Resource, Link> copyRoutings(Application<Task, Dependency> sApplication,
			Routings<Task, Resource, Link> sRoutings, Application<Task, Dependency> iApplication,
			Architecture<Resource, Link> iArchitecture); static Mappings<Task, Resource> copyMappings(Mappings<Task, Resource> sMappings,
			Architecture<Resource, Link> iArchitecture, Application<Task, Dependency> iApplication); static Application<Task, Dependency> copy(Application<Task, Dependency> sApplication); static Architecture<Resource, Link> copy(Architecture<Resource, Link> sArchitecture); @SuppressWarnings("unchecked") static E copy(Element element); @SuppressWarnings("unchecked") static M copy(Mapping<?, ?> mapping); static void setAttributes(IAttributes e, Attributes attributes); static Specification clone(Specification specification); static Application<T, D> clone(Application<T, D> sApplication); static Architecture<R, L> clone(Architecture<R, L> sArchitecture); static void filterByResources(Specification specification, Collection<Resource> resources); static void filter(Specification specification, Collection<Function<Task, Dependency>> functions); static void filterByFunctionName(Specification specification, Collection<String> functions); static void filterByFunctionName(Specification specification, String... functions);  }