From 1f74c4c1ccb3c963a8faf1eedc9c0549f8160ac5 Mon Sep 17 00:00:00 2001 From: FloBoJa Date: Fri, 12 Jan 2024 10:50:14 +0100 Subject: [PATCH] Apply Palladio Clean Up rules --- .../core/cli/RetrieverApplication.java | 22 +- .../RetrieverConfigurationImpl.java | 50 +-- .../RetrieverWorkflowConfiguration.java | 6 +- .../gui/RetrieverConfigurationDelegate.java | 7 +- .../retriever/core/gui/RetrieverTab.java | 129 ++++---- .../retriever/core/gui/RetrieverTabGroup.java | 2 +- .../core/gui/ServiceConfigurationManager.java | 26 +- .../core/gui/ServiceConfigurationView.java | 110 ++++--- .../retriever/core/gui/TreeEditListener.java | 54 ++-- .../retriever/core/main/Retriever.java | 33 +- .../core/main/RetrieverException.java | 4 +- .../core/service/AnalystCollection.java | 6 +- .../core/service/DiscovererCollection.java | 4 +- .../core/service/PerformanceAnalyst.java | 4 +- .../core/service/RuleCollection.java | 8 +- .../core/workflow/PersistenceJob.java | 29 +- .../retriever/core/workflow/PlantUmlJob.java | 30 +- .../RetrieverBlackboardInteractingJob.java | 9 +- .../retriever/core/workflow/RetrieverJob.java | 88 +++--- .../core/workflow/SeffMergerJob.java | 50 +-- .../core/workflow/TypeMergerJob.java | 15 +- .../extraction/discoverers/CsvDiscoverer.java | 9 +- .../discoverers/EcmaScriptDiscoverer.java | 9 +- .../discoverers/JavaDiscoverer.java | 11 +- .../discoverers/JsonDiscoverer.java | 11 +- .../discoverers/PropertiesDiscoverer.java | 11 +- .../extraction/discoverers/SqlDiscoverer.java | 9 +- .../extraction/discoverers/XmlDiscoverer.java | 9 +- .../discoverers/YamlDiscoverer.java | 14 +- .../discoverers/wrappers/YamlMapper.java | 18 +- .../blackboard/RetrieverBlackboard.java | 70 ++--- .../commonalities/CompUnitOrName.java | 31 +- .../extraction/commonalities/Component.java | 39 ++- .../commonalities/ComponentBuilder.java | 34 +-- .../extraction/commonalities/Composite.java | 46 ++- .../commonalities/CompositeBuilder.java | 125 ++++---- .../commonalities/DependencyUtils.java | 23 +- .../commonalities/EntireInterface.java | 26 +- .../commonalities/JavaInterfaceName.java | 23 +- .../commonalities/JavaOperationName.java | 29 +- .../extraction/commonalities/Name.java | 11 +- .../extraction/commonalities/Operation.java | 25 +- .../commonalities/OperationInterface.java | 16 +- .../commonalities/PCMDetectionResult.java | 84 +++--- .../extraction/commonalities/Provisions.java | 44 ++- .../commonalities/ProvisionsBuilder.java | 23 +- .../extraction/commonalities/RESTName.java | 96 +++--- .../commonalities/Requirements.java | 54 ++-- .../commonalities/RequirementsBuilder.java | 41 ++- .../extraction/engine/DockerParser.java | 20 +- .../extraction/engine/MapMerger.java | 8 +- .../extraction/engine/NameConverter.java | 4 +- .../extraction/engine/PCMDetector.java | 213 ++++++------- .../extraction/engine/PCMInstanceCreator.java | 251 +++++++-------- .../retriever/extraction/engine/Rule.java | 14 +- .../extraction/engine/RuleHelper.java | 237 ++++++++------- .../engine/ServiceConfiguration.java | 157 +++++----- .../discovery/RepositoryDecompositor.java | 163 +++++----- .../mocore/discovery/SimpleDiscoverer.java | 2 +- .../mocore/orchestration/PcmOrchestrator.java | 2 +- .../element/AtomicComponentProcessor.java | 2 +- .../processor/element/ComponentProcessor.java | 13 +- .../processor/element/CompositeProcessor.java | 2 +- .../element/DeploymentProcessor.java | 4 +- .../processor/element/InterfaceProcessor.java | 17 +- .../LinkResourceSpecificationProcessor.java | 16 +- .../ServiceEffectSpecificationProcessor.java | 4 +- .../processor/element/SignatureProcessor.java | 14 +- .../ComponentAllocationRelationProcessor.java | 2 +- .../ComponentAssemblyRelationProcessor.java | 62 ++-- ...ntSignatureProvisionRelationProcessor.java | 2 +- ...eProvisionDelegationRelationProcessor.java | 15 +- ...equirementDelegationRelationProcessor.java | 15 +- .../CompositionRelationProcessor.java | 2 +- ...DeploymentDeploymentRelationProcessor.java | 12 +- .../InterfaceProvisionRelationProcessor.java | 14 +- ...InterfaceRequirementRelationProcessor.java | 14 +- ...esourceSpecificationRelationProcessor.java | 2 +- ...eEffectSpecificationRelationProcessor.java | 2 +- .../SignatureProvisionRelationProcessor.java | 2 +- .../surrogate/element/AtomicComponent.java | 8 +- .../mocore/surrogate/element/Component.java | 4 +- .../mocore/surrogate/element/Composite.java | 6 +- .../mocore/surrogate/element/Deployment.java | 6 +- .../mocore/surrogate/element/Interface.java | 6 +- .../element/LinkResourceSpecification.java | 8 +- .../mocore/surrogate/element/PcmElement.java | 12 +- .../element/ServiceEffectSpecification.java | 4 +- .../mocore/surrogate/element/Signature.java | 6 +- .../relation/ComponentAllocationRelation.java | 9 +- .../relation/ComponentAssemblyRelation.java | 10 +- .../ComponentSignatureProvisionRelation.java | 10 +- .../CompositeProvisionDelegationRelation.java | 10 +- ...ompositeRequirementDelegationRelation.java | 11 +- .../relation/CompositionRelation.java | 8 +- .../DeploymentDeploymentRelation.java | 9 +- .../relation/InterfaceProvisionRelation.java | 9 +- .../InterfaceRequirementRelation.java | 9 +- .../LinkResourceSpecificationRelation.java | 10 +- .../ServiceEffectSpecificationRelation.java | 10 +- .../relation/SignatureProvisionRelation.java | 9 +- .../transformation/AllocationTransformer.java | 29 +- .../transformation/RepositoryTransformer.java | 285 +++++++++--------- .../ResourceEnvironmentTransformer.java | 68 +++-- .../transformation/SystemTransformer.java | 82 ++--- .../retriever/mocore/workflow/MoCoReJob.java | 37 +-- .../mocore/discovery/DecompositorTest.java | 10 +- .../discovery/RepositoryDecompositorTest.java | 23 +- .../orchestration/PcmOrchestratorTest.java | 52 ++-- .../element/AtomicComponentProcessorTest.java | 2 +- .../element/ComponentProcessorTest.java | 12 +- .../element/CompositeProcessorTest.java | 2 +- .../element/DeploymentProcessorTest.java | 8 +- .../element/InterfaceProcessorTest.java | 14 +- ...inkResourceSpecificationProcessorTest.java | 14 +- ...rviceEffectSpecificationProcessorTest.java | 10 +- .../element/SignatureProcessorTest.java | 14 +- ...ponentAllocationRelationProcessorTest.java | 10 +- ...omponentAssemblyRelationProcessorTest.java | 75 ++--- ...gnatureProvisionRelationProcessorTest.java | 15 +- ...visionDelegationRelationProcessorTest.java | 27 +- ...rementDelegationRelationProcessorTest.java | 27 +- .../CompositionRelationProcessorTest.java | 9 +- ...oymentDeploymentRelationProcessorTest.java | 132 ++++---- ...terfaceProvisionRelationProcessorTest.java | 10 +- ...rfaceRequirementRelationProcessorTest.java | 10 +- ...rceSpecificationRelationProcessorTest.java | 11 +- ...ectSpecificationRelationProcessorTest.java | 21 +- ...gnatureProvisionRelationProcessorTest.java | 10 +- .../mocore/surrogate/PcmSurrogateTest.java | 4 +- .../element/AtomicComponentTest.java | 10 +- .../surrogate/element/ComponentTest.java | 11 +- .../surrogate/element/CompositeTest.java | 10 +- .../surrogate/element/DeploymentTest.java | 10 +- .../surrogate/element/InterfaceTest.java | 10 +- .../LinkResourceSpecificationTest.java | 8 +- .../ServiceEffectSpecificationTest.java | 6 +- .../surrogate/element/SignatureTest.java | 10 +- .../ComponentAllocationRelationTest.java | 4 +- .../ComponentAssemblyRelationTest.java | 8 +- ...mponentSignatureProvisionRelationTest.java | 8 +- ...positeProvisionDelegationRelationTest.java | 27 +- ...siteRequirementDelegationRelationTest.java | 28 +- .../relation/CompositionRelationTest.java | 3 +- .../DeploymentDeploymentRelationTest.java | 4 +- .../InterfaceProvisionRelationTest.java | 4 +- .../InterfaceRequirementRelationTest.java | 4 +- ...LinkResourceSpecificationRelationTest.java | 4 +- ...erviceEffectSpecificationRelationTest.java | 14 +- .../SignatureProvisionRelationTest.java | 4 +- .../AllocationTransformerTest.java | 14 +- .../RepositoryTransformerTest.java | 146 ++++----- .../ResourceEnvironmentTransformerTest.java | 46 +-- .../transformation/SystemTransformerTest.java | 28 +- .../mocore/utility/ElementFactory.java | 40 +-- .../mocore/utility/PcmEvaluationUtility.java | 233 +++++++------- .../mocore/workflow/MoCoReJobTest.java | 74 ++--- .../retriever/test/integration/ACMETest.java | 14 +- .../retriever/test/integration/BasicTest.java | 19 +- .../test/integration/CaseStudyTest.java | 215 ++++++------- .../retriever/test/integration/JaxRsTest.java | 2 +- .../test/integration/PetclinicTest.java | 27 +- .../test/integration/PiggymetricsTest.java | 33 +- .../test/integration/SeffAssociationTest.java | 14 +- .../test/integration/SpringTest.java | 2 +- .../test/integration/TeaStoreTest.java | 11 +- .../retriever/test/model/CompositeTest.java | 94 +++--- .../retriever/test/model/InterfaceTest.java | 92 +++--- .../retriever/test/model/PathTest.java | 32 +- .../test/workflow/PersistenceJobTest.java | 14 +- .../test/workflow/PostAnalysisJobTest.java | 146 ++++----- .../test/workflow/casestudy/Entity.java | 4 +- .../workflow/casestudy/EntityRepository.java | 6 +- .../workflow/casestudy/EntityService.java | 8 +- .../utility/MethodDeclarationVisitor.java | 8 +- 175 files changed, 2859 insertions(+), 2761 deletions(-) diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java index 9f9a0bb5..715029f0 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java @@ -27,7 +27,7 @@ public class RetrieverApplication implements IApplication { - private static Options createOptions(Set availableRuleIDs) { + private static Options createOptions(final Set availableRuleIDs) { final Options options = new Options(); options .addRequiredOption("i", "input-directory", true, @@ -54,10 +54,10 @@ private static void printHelp(final Options options) { } @Override - public Object start(IApplicationContext context) throws Exception { + public Object start(final IApplicationContext context) throws Exception { - Set availableRules = new RuleCollection().getServices(); - Set availableRuleIDs = availableRules.stream() + final Set availableRules = new RuleCollection().getServices(); + final Set availableRuleIDs = availableRules.stream() .map(Rule::getID) .collect(Collectors.toSet()); @@ -77,7 +77,7 @@ public Object start(IApplicationContext context) throws Exception { printHelp(options); } - RetrieverConfiguration configuration = new RetrieverConfigurationImpl(); + final RetrieverConfiguration configuration = new RetrieverConfigurationImpl(); try { configuration.setInputFolder(URI.createFileURI(URI.decode(Paths.get(cmd.getOptionValue("i")) @@ -101,25 +101,25 @@ public Object start(IApplicationContext context) throws Exception { // Enable all discoverers, in case a selected rule depends on them. // TODO: This is unnecessary once rule dependencies are in place - ServiceConfiguration discovererConfig = configuration.getConfig(Discoverer.class); - for (Discoverer discoverer : new DiscovererCollection().getServices()) { + final ServiceConfiguration discovererConfig = configuration.getConfig(Discoverer.class); + for (final Discoverer discoverer : new DiscovererCollection().getServices()) { discovererConfig.select(discoverer); } - ServiceConfiguration ruleConfig = configuration.getConfig(Rule.class); + final ServiceConfiguration ruleConfig = configuration.getConfig(Rule.class); // Extract and check rules - Set requestedRuleIDs = Arrays.stream(cmd.getOptionValue("r") + final Set requestedRuleIDs = Arrays.stream(cmd.getOptionValue("r") .split(",")) .map(String::strip) .collect(Collectors.toSet()); - Set rules = availableRules.stream() + final Set rules = availableRules.stream() .filter(x -> requestedRuleIDs.contains(x.getID())) .collect(Collectors.toSet()); if (rules.isEmpty()) { System.err.println("Invalid rules: " + cmd.getOptionValue("r")); return -1; } - for (Rule rule : rules) { + for (final Rule rule : rules) { ruleConfig.select(rule); } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java index 6f574057..a2246e11 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java @@ -45,47 +45,47 @@ public RetrieverConfigurationImpl() { this(new HashMap<>()); } - public RetrieverConfigurationImpl(Map attributes) { + public RetrieverConfigurationImpl(final Map attributes) { this.attributes = Objects.requireNonNull(attributes); this.serviceConfigs = new HashMap<>(); ServiceCollection discovererCollection = null; try { discovererCollection = new DiscovererCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { LOG.error("Exception occurred while discovering discoverers!"); discovererCollection = new EmptyCollection<>(); } - ServiceConfiguration discovererConfig = new ServiceConfiguration<>(discovererCollection, + final ServiceConfiguration discovererConfig = new ServiceConfiguration<>(discovererCollection, RULE_ENGINE_SELECTED_DISCOVERERS, RULE_ENGINE_DISCOVERER_CONFIG_PREFIX); - serviceConfigs.put(Discoverer.class, discovererConfig); + this.serviceConfigs.put(Discoverer.class, discovererConfig); ServiceCollection ruleCollection = null; try { ruleCollection = new RuleCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { LOG.error("Exception occurred while discovering rules!"); ruleCollection = new EmptyCollection<>(); } - ServiceConfiguration ruleConfig = new ServiceConfiguration<>(ruleCollection, RULE_ENGINE_SELECTED_RULES, - RULE_ENGINE_RULE_CONFIG_PREFIX); + final ServiceConfiguration ruleConfig = new ServiceConfiguration<>(ruleCollection, + RULE_ENGINE_SELECTED_RULES, RULE_ENGINE_RULE_CONFIG_PREFIX); ruleConfig.addDependencyProvider(discovererConfig); - serviceConfigs.put(Rule.class, ruleConfig); + this.serviceConfigs.put(Rule.class, ruleConfig); ServiceCollection analystCollection = null; try { analystCollection = new AnalystCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { LOG.error("Exception occurred while discovering analysts!"); analystCollection = new EmptyCollection<>(); } - ServiceConfiguration analystConfig = new ServiceConfiguration<>(analystCollection, + final ServiceConfiguration analystConfig = new ServiceConfiguration<>(analystCollection, RULE_ENGINE_SELECTED_ANALYSTS, RULE_ENGINE_ANALYST_CONFIG_PREFIX); analystConfig.addDependencyProvider(discovererConfig); analystConfig.addDependencyProvider(ruleConfig); - serviceConfigs.put(Analyst.class, analystConfig); + this.serviceConfigs.put(Analyst.class, analystConfig); - applyAttributeMap(attributes); + this.applyAttributeMap(attributes); } public void applyAttributeMap(final Map attributeMap) { @@ -94,57 +94,57 @@ public void applyAttributeMap(final Map attributeMap) { } if (attributeMap.get(RULE_ENGINE_INPUT_PATH) != null) { - setInputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_INPUT_PATH))); + this.setInputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_INPUT_PATH))); } if (attributeMap.get(RULE_ENGINE_OUTPUT_PATH) != null) { - setOutputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_OUTPUT_PATH))); + this.setOutputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_OUTPUT_PATH))); } - for (ServiceConfiguration serviceConfig : serviceConfigs.values()) { + for (final ServiceConfiguration serviceConfig : this.serviceConfigs.values()) { serviceConfig.applyAttributeMap(attributeMap); } } @Override public Map getAttributes() { - return attributes; + return this.attributes; } @Override public URI getInputFolder() { - return inputFolder; + return this.inputFolder; } @Override public URI getOutputFolder() { - return outputFolder; + return this.outputFolder; } @Override - public void setInputFolder(URI inputFolder) { + public void setInputFolder(final URI inputFolder) { this.inputFolder = inputFolder; } @Override - public void setOutputFolder(URI outputFolder) { + public void setOutputFolder(final URI outputFolder) { this.outputFolder = outputFolder; } @Override - public ServiceConfiguration getConfig(Class serviceClass) { + public ServiceConfiguration getConfig(final Class serviceClass) { // serviceConfig only contains legal mappings @SuppressWarnings("unchecked") - ServiceConfiguration serviceConfig = (ServiceConfiguration) serviceConfigs.get(serviceClass); + final ServiceConfiguration serviceConfig = (ServiceConfiguration) this.serviceConfigs.get(serviceClass); return serviceConfig; } public Map toMap() { final Map result = new HashMap<>(); - result.put(RULE_ENGINE_INPUT_PATH, getInputFolder()); - result.put(RULE_ENGINE_OUTPUT_PATH, getOutputFolder()); + result.put(RULE_ENGINE_INPUT_PATH, this.getInputFolder()); + result.put(RULE_ENGINE_OUTPUT_PATH, this.getOutputFolder()); - for (ServiceConfiguration serviceConfig : serviceConfigs.values()) { + for (final ServiceConfiguration serviceConfig : this.serviceConfigs.values()) { result.putAll(serviceConfig.toMap()); } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverWorkflowConfiguration.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverWorkflowConfiguration.java index 30e035e2..074c1cea 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverWorkflowConfiguration.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverWorkflowConfiguration.java @@ -16,14 +16,14 @@ public class RetrieverWorkflowConfiguration extends AbstractWorkflowBasedRunConf @Override public void setDefaults() { - configuration = new RetrieverConfigurationImpl(); + this.configuration = new RetrieverConfigurationImpl(); } public RetrieverConfiguration getRetrieverConfiguration() { - return configuration; + return this.configuration; } - public void setRetrieverConfiguration(RetrieverConfiguration configuration) { + public void setRetrieverConfiguration(final RetrieverConfiguration configuration) { this.configuration = configuration; } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverConfigurationDelegate.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverConfigurationDelegate.java index da21e58c..c15c0565 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverConfigurationDelegate.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverConfigurationDelegate.java @@ -15,13 +15,14 @@ public class RetrieverConfigurationDelegate extends AbstractWorkflowBasedLaunchConfigurationDelegate { @Override - protected IJob createWorkflowJob(RetrieverWorkflowConfiguration config, ILaunch launch) throws CoreException { + protected IJob createWorkflowJob(final RetrieverWorkflowConfiguration config, final ILaunch launch) + throws CoreException { return new RetrieverJob(config.getRetrieverConfiguration()); } @Override - protected RetrieverWorkflowConfiguration deriveConfiguration(ILaunchConfiguration configuration, String mode) - throws CoreException { + protected RetrieverWorkflowConfiguration deriveConfiguration(final ILaunchConfiguration configuration, + final String mode) throws CoreException { final RetrieverWorkflowConfiguration analyzerConfiguration = new RetrieverWorkflowConfiguration(); analyzerConfiguration.setRetrieverConfiguration(new RetrieverConfigurationImpl(configuration.getAttributes())); diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTab.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTab.java index 3c4c26f0..de7c8259 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTab.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTab.java @@ -49,59 +49,59 @@ public class RetrieverTab extends AbstractLaunchConfigurationTab { public RetrieverTab() { // Create the default path of this Eclipse application - defaultPath = Paths.get(".") + this.defaultPath = Paths.get(".") .toAbsolutePath() .normalize() .toString(); // Create a listener for GUI modification events - modifyListener = e -> { + this.modifyListener = e -> { // e may be null here! - setDirty(true); - updateLaunchConfigurationDialog(); + this.setDirty(true); + this.updateLaunchConfigurationDialog(); }; ServiceCollection discovererCollection = null; try { discovererCollection = new DiscovererCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { Logger.getLogger(RetrieverTab.class) .error("Exception occurred while discovering discoverers!"); discovererCollection = new EmptyCollection<>(); } - ServiceConfiguration discovererConfig = new ServiceConfiguration<>(discovererCollection, + final ServiceConfiguration discovererConfig = new ServiceConfiguration<>(discovererCollection, RetrieverConfigurationImpl.RULE_ENGINE_SELECTED_DISCOVERERS, RetrieverConfigurationImpl.RULE_ENGINE_DISCOVERER_CONFIG_PREFIX); - discovererConfigManager = new ServiceConfigurationManager<>(discovererConfig); + this.discovererConfigManager = new ServiceConfigurationManager<>(discovererConfig); ServiceCollection ruleCollection = null; try { ruleCollection = new RuleCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { Logger.getLogger(RetrieverTab.class) .error("Exception occurred while discovering rules!"); ruleCollection = new EmptyCollection<>(); } - ServiceConfiguration ruleConfig = new ServiceConfiguration<>(ruleCollection, + final ServiceConfiguration ruleConfig = new ServiceConfiguration<>(ruleCollection, RetrieverConfigurationImpl.RULE_ENGINE_SELECTED_RULES, RetrieverConfigurationImpl.RULE_ENGINE_RULE_CONFIG_PREFIX); ruleConfig.addDependencyProvider(discovererConfig); - ruleConfigView = new ServiceConfigurationView<>(ruleConfig, modifyListener); + this.ruleConfigView = new ServiceConfigurationView<>(ruleConfig, this.modifyListener); ServiceCollection analystCollection = null; try { analystCollection = new AnalystCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { Logger.getLogger(RetrieverTab.class) .error("Exception occurred while discovering analysts!"); analystCollection = new EmptyCollection<>(); } - ServiceConfiguration analystConfig = new ServiceConfiguration<>(analystCollection, + final ServiceConfiguration analystConfig = new ServiceConfiguration<>(analystCollection, RetrieverConfigurationImpl.RULE_ENGINE_SELECTED_ANALYSTS, RetrieverConfigurationImpl.RULE_ENGINE_ANALYST_CONFIG_PREFIX); analystConfig.addDependencyProvider(discovererConfig); analystConfig.addDependencyProvider(ruleConfig); - analystConfigView = new ServiceConfigurationView<>(analystConfig, modifyListener); + this.analystConfigView = new ServiceConfigurationView<>(analystConfig, this.modifyListener); } @@ -112,57 +112,57 @@ public Image getImage() { } @Override - public void createControl(Composite parent) { + public void createControl(final Composite parent) { // Create a new Composite to hold the page's controls - Composite container = new Composite(parent, SWT.NONE); - setControl(container); + final Composite container = new Composite(parent, SWT.NONE); + this.setControl(container); container.setLayout(new GridLayout()); // Create file input area for input - in = new Text(container, SWT.SINGLE | SWT.BORDER); - TabHelper.createFolderInputSection(container, modifyListener, "File In", in, "File In", getShell(), - defaultPath); + this.in = new Text(container, SWT.SINGLE | SWT.BORDER); + TabHelper.createFolderInputSection(container, this.modifyListener, "File In", this.in, "File In", + this.getShell(), this.defaultPath); // Create file input area for output - out = new Text(container, SWT.SINGLE | SWT.BORDER); - TabHelper.createFolderInputSection(container, modifyListener, "File Out", out, "File Out", getShell(), - defaultPath); + this.out = new Text(container, SWT.SINGLE | SWT.BORDER); + TabHelper.createFolderInputSection(container, this.modifyListener, "File Out", this.out, "File Out", + this.getShell(), this.defaultPath); // Create tree view for rule and analyst configuration // Do not create a view for discoverers, they can always be selected automatically. // If a discoverer is added that requires configuration, this view has to be added back. - ruleConfigView.createControl(container); - analystConfigView.createControl(container); + this.ruleConfigView.createControl(container); + this.analystConfigView.createControl(container); } - private boolean validateFolderInput(Text widget) { + private boolean validateFolderInput(final Text widget) { if ((widget == null) || (widget.getText() == null) || widget.getText() .isBlank()) { - return error("Blank input."); + return this.error("Blank input."); } try { - URI uri = getURI(widget); - Path path = Paths.get(CommonPlugin.asLocalURI(uri) + final URI uri = getURI(widget); + final Path path = Paths.get(CommonPlugin.asLocalURI(uri) .devicePath()); if (!Files.exists(path)) { - return error("The file located by '" + uri + "'does not exist."); + return this.error("The file located by '" + uri + "'does not exist."); } - } catch (Exception e) { - return error(e.getLocalizedMessage()); + } catch (final Exception e) { + return this.error(e.getLocalizedMessage()); } - return error(null); + return this.error(null); } private boolean error(final String message) { - setErrorMessage(message); + this.setErrorMessage(message); return message == null; } - private static URI getURI(Text widget) { - String text = URI.decode(widget.getText()); - URI uri = URI.createURI(text); + private static URI getURI(final Text widget) { + final String text = URI.decode(widget.getText()); + final URI uri = URI.createURI(text); if (uri.isPlatform() || uri.isFile()) { return uri; } @@ -172,39 +172,40 @@ private static URI getURI(Text widget) { } @Override - public boolean isValid(ILaunchConfiguration launchConfig) { - return validateFolderInput(in) && validateFolderInput(out); + public boolean isValid(final ILaunchConfiguration launchConfig) { + return this.validateFolderInput(this.in) && this.validateFolderInput(this.out); } @Override - public void initializeFrom(ILaunchConfiguration configuration) { - setText(configuration, in, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH); - setText(configuration, out, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH); + public void initializeFrom(final ILaunchConfiguration configuration) { + this.setText(configuration, this.in, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH); + this.setText(configuration, this.out, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH); - discovererConfigManager.initializeFrom(configuration); - ruleConfigView.initializeFrom(configuration); - analystConfigView.initializeFrom(configuration); + this.discovererConfigManager.initializeFrom(configuration); + this.ruleConfigView.initializeFrom(configuration); + this.analystConfigView.initializeFrom(configuration); } - private void setText(ILaunchConfiguration configuration, Text textWidget, String attributeName) { + private void setText(final ILaunchConfiguration configuration, final Text textWidget, final String attributeName) { try { textWidget.setText(configuration.getAttribute(attributeName, "")); } catch (final Exception e) { - LaunchConfigPlugin.errorLogger(getName(), attributeName, e.getMessage()); - error(e.getLocalizedMessage()); + LaunchConfigPlugin.errorLogger(this.getName(), attributeName, e.getMessage()); + this.error(e.getLocalizedMessage()); } } @Override - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH, in); - setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH, out); - discovererConfigManager.performApply(configuration); - ruleConfigView.performApply(configuration); - analystConfigView.performApply(configuration); + public void performApply(final ILaunchConfigurationWorkingCopy configuration) { + this.setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH, this.in); + this.setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH, this.out); + this.discovererConfigManager.performApply(configuration); + this.ruleConfigView.performApply(configuration); + this.analystConfigView.performApply(configuration); } - private void setAttribute(ILaunchConfigurationWorkingCopy configuration, String attributeName, Text textWidget) { + private void setAttribute(final ILaunchConfigurationWorkingCopy configuration, final String attributeName, + final Text textWidget) { try { if (textWidget.getText() .isEmpty()) { @@ -213,28 +214,28 @@ private void setAttribute(ILaunchConfigurationWorkingCopy configuration, String configuration.setAttribute(attributeName, getURI(textWidget).toString()); } } catch (final Exception e) { - error(e.getLocalizedMessage()); + this.error(e.getLocalizedMessage()); } } @Override - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - setText(in, defaultPath); - setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH, in); + public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) { + this.setText(this.in, this.defaultPath); + this.setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH, this.in); - setText(out, defaultPath); - setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH, out); + this.setText(this.out, this.defaultPath); + this.setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH, this.out); - discovererConfigManager.setDefaults(configuration); - ruleConfigView.setDefaults(configuration); - analystConfigView.setDefaults(configuration); + this.discovererConfigManager.setDefaults(configuration); + this.ruleConfigView.setDefaults(configuration); + this.analystConfigView.setDefaults(configuration); } private void setText(final Text textWidget, final String attributeName) { try { textWidget.setText(attributeName); } catch (final Exception e) { - error(e.getMessage()); + this.error(e.getMessage()); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTabGroup.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTabGroup.java index 16990ef4..765dd9f3 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTabGroup.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTabGroup.java @@ -18,6 +18,6 @@ public void createTabs(final ILaunchConfigurationDialog dialog, final String mod tabs.add(new RetrieverTab()); tabs.add(new DebugEnabledCommonTab()); - setTabs(tabs.toArray(new ILaunchConfigurationTab[0])); + this.setTabs(tabs.toArray(new ILaunchConfigurationTab[0])); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationManager.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationManager.java index 694c324e..9a5619bd 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationManager.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationManager.java @@ -14,41 +14,41 @@ public class ServiceConfigurationManager { private final ServiceConfiguration serviceConfiguration; - public ServiceConfigurationManager(ServiceConfiguration serviceConfiguration) { + public ServiceConfigurationManager(final ServiceConfiguration serviceConfiguration) { this.serviceConfiguration = serviceConfiguration; } - public void initializeFrom(ILaunchConfiguration configuration) { + public void initializeFrom(final ILaunchConfiguration configuration) { try { - serviceConfiguration.applyAttributeMap(configuration.getAttributes()); - } catch (CoreException e) { + this.serviceConfiguration.applyAttributeMap(configuration.getAttributes()); + } catch (final CoreException e) { LaunchConfigPlugin.log(IStatus.ERROR, e.getMessage()); } } - public void performApply(ILaunchConfigurationWorkingCopy configuration) { + public void performApply(final ILaunchConfigurationWorkingCopy configuration) { // Update the LaunchConfiguration - writeServiceConfigAttributes(configuration); + this.writeServiceConfigAttributes(configuration); } /** * Called when a new launch configuration is created, to set the values to sensible defaults. - * + * * @param configuration * the new launch configuration */ - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - writeServiceConfigAttributes(configuration); + public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) { + this.writeServiceConfigAttributes(configuration); } - private void writeServiceConfigAttributes(ILaunchConfigurationWorkingCopy configuration) { - Map attributes = serviceConfiguration.toMap(); - for (Map.Entry attribute : attributes.entrySet()) { + private void writeServiceConfigAttributes(final ILaunchConfigurationWorkingCopy configuration) { + final Map attributes = this.serviceConfiguration.toMap(); + for (final Map.Entry attribute : attributes.entrySet()) { configuration.setAttribute(attribute.getKey(), attribute.getValue()); } } public ServiceConfiguration getServiceConfiguration() { - return serviceConfiguration; + return this.serviceConfiguration; } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationView.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationView.java index 20d12155..0522251f 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationView.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationView.java @@ -30,90 +30,98 @@ public class ServiceConfigurationView extends ServiceConfigur private final ModifyListener modifyListener; - public ServiceConfigurationView(ServiceConfiguration serviceConfiguration, ModifyListener modifyListener) { + public ServiceConfigurationView(final ServiceConfiguration serviceConfiguration, + final ModifyListener modifyListener) { super(serviceConfiguration); - configTreeItems = new HashMap<>(); - serviceCheckboxes = new HashMap<>(); + this.configTreeItems = new HashMap<>(); + this.serviceCheckboxes = new HashMap<>(); this.modifyListener = modifyListener; } - public void createControl(Composite container) { - Tree tree = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION); - TreeColumn nameColumn = new TreeColumn(tree, SWT.NONE); + public void createControl(final Composite container) { + final Tree tree = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION); + final TreeColumn nameColumn = new TreeColumn(tree, SWT.NONE); nameColumn.setWidth(200); - TreeColumn valueColumn = new TreeColumn(tree, SWT.NONE); + final TreeColumn valueColumn = new TreeColumn(tree, SWT.NONE); valueColumn.setWidth(200); - tree.addListener(SWT.Selection, new TreeEditListener(tree, modifyListener, SERVICE_CONFIGURATION_VALUE_COLUMN)); + tree.addListener(SWT.Selection, + new TreeEditListener(tree, this.modifyListener, SERVICE_CONFIGURATION_VALUE_COLUMN)); - List sortedServices = getServiceConfiguration().getAvailable() + final List sortedServices = this.getServiceConfiguration() + .getAvailable() .stream() .sorted(Comparator.comparing(T::getName)) .collect(Collectors.toList()); - for (T service : sortedServices) { - TreeItem serviceItem = new TreeItem(tree, SWT.NONE); + for (final T service : sortedServices) { + final TreeItem serviceItem = new TreeItem(tree, SWT.NONE); serviceItem.setText(0, service.getClass() .getSimpleName()); - addCheckboxTo(serviceItem, service); + this.addCheckboxTo(serviceItem, service); if (service.getConfigurationKeys() != null) { - String serviceId = service.getID(); - configTreeItems.putIfAbsent(serviceId, new HashMap<>()); - for (String configKey : service.getConfigurationKeys()) { - TreeItem propertyItem = new TreeItem(serviceItem, SWT.NONE); + final String serviceId = service.getID(); + this.configTreeItems.putIfAbsent(serviceId, new HashMap<>()); + for (final String configKey : service.getConfigurationKeys()) { + final TreeItem propertyItem = new TreeItem(serviceItem, SWT.NONE); propertyItem.setText(0, configKey); - configTreeItems.get(serviceId) + this.configTreeItems.get(serviceId) .put(configKey, propertyItem); } } } } - private void addCheckboxTo(TreeItem item, T service) { - Tree tree = item.getParent(); - TreeEditor editor = new TreeEditor(tree); - Button checkbox = new Button(tree, SWT.CHECK); + private void addCheckboxTo(final TreeItem item, final T service) { + final Tree tree = item.getParent(); + final TreeEditor editor = new TreeEditor(tree); + final Button checkbox = new Button(tree, SWT.CHECK); checkbox.addSelectionListener(new SelectionListener() { @Override - public void widgetSelected(SelectionEvent e) { + public void widgetSelected(final SelectionEvent e) { if (((Button) e.getSource()).getSelection()) { - getServiceConfiguration().select(service); + ServiceConfigurationView.this.getServiceConfiguration() + .select(service); } else { - getServiceConfiguration().deselect(service); + ServiceConfigurationView.this.getServiceConfiguration() + .deselect(service); } - modifyListener.modifyText(null); + ServiceConfigurationView.this.modifyListener.modifyText(null); } @Override - public void widgetDefaultSelected(SelectionEvent e) { + public void widgetDefaultSelected(final SelectionEvent e) { } }); checkbox.pack(); - serviceCheckboxes.put(service.getID(), checkbox); + this.serviceCheckboxes.put(service.getID(), checkbox); editor.minimumWidth = checkbox.getSize().x; editor.horizontalAlignment = SWT.LEFT; editor.setEditor(checkbox, item, SERVICE_CONFIGURATION_VALUE_COLUMN); } @Override - public void initializeFrom(ILaunchConfiguration configuration) { + public void initializeFrom(final ILaunchConfiguration configuration) { super.initializeFrom(configuration); - for (T service : getServiceConfiguration().getAvailable()) { - String id = service.getID(); - initializeCheckbox(service, serviceCheckboxes.get(id)); - initializeTreeItems(service, configTreeItems.get(id)); + for (final T service : this.getServiceConfiguration() + .getAvailable()) { + final String id = service.getID(); + this.initializeCheckbox(service, this.serviceCheckboxes.get(id)); + this.initializeTreeItems(service, this.configTreeItems.get(id)); } } - private void initializeCheckbox(T service, Button checkbox) { - boolean selected = getServiceConfiguration().isManuallySelected(service); + private void initializeCheckbox(final T service, final Button checkbox) { + final boolean selected = this.getServiceConfiguration() + .isManuallySelected(service); checkbox.setSelection(selected); } - private void initializeTreeItems(T service, Map treeItems) { - Map strings = getServiceConfiguration().getWholeConfig(service.getID()); - for (Entry entry : treeItems.entrySet()) { + private void initializeTreeItems(final T service, final Map treeItems) { + final Map strings = this.getServiceConfiguration() + .getWholeConfig(service.getID()); + for (final Entry entry : treeItems.entrySet()) { String value = strings.get(entry.getKey()); if (value == null) { value = ""; @@ -124,14 +132,16 @@ private void initializeTreeItems(T service, Map treeItems) { } @Override - public void performApply(ILaunchConfigurationWorkingCopy configuration) { + public void performApply(final ILaunchConfigurationWorkingCopy configuration) { // Update the ServiceConfiguration with the values from the tree items - for (T service : getServiceConfiguration().getAvailable()) { - for (Entry entry : configTreeItems.get(service.getID()) + for (final T service : this.getServiceConfiguration() + .getAvailable()) { + for (final Entry entry : this.configTreeItems.get(service.getID()) .entrySet()) { - TreeItem treeItem = entry.getValue(); - String configurationValue = treeItem.getText(SERVICE_CONFIGURATION_VALUE_COLUMN); - getServiceConfiguration().setConfig(service.getID(), entry.getKey(), configurationValue); + final TreeItem treeItem = entry.getValue(); + final String configurationValue = treeItem.getText(SERVICE_CONFIGURATION_VALUE_COLUMN); + this.getServiceConfiguration() + .setConfig(service.getID(), entry.getKey(), configurationValue); } } @@ -140,17 +150,19 @@ public void performApply(ILaunchConfigurationWorkingCopy configuration) { /** * Called when a new launch configuration is created, to set the values to sensible defaults. - * + * * @param configuration * the new launch configuration */ - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - writeServiceConfigAttributes(configuration); + @Override + public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) { + this.writeServiceConfigAttributes(configuration); } - private void writeServiceConfigAttributes(ILaunchConfigurationWorkingCopy configuration) { - Map attributes = getServiceConfiguration().toMap(); - for (Map.Entry attribute : attributes.entrySet()) { + private void writeServiceConfigAttributes(final ILaunchConfigurationWorkingCopy configuration) { + final Map attributes = this.getServiceConfiguration() + .toMap(); + for (final Map.Entry attribute : attributes.entrySet()) { configuration.setAttribute(attribute.getKey(), attribute.getValue()); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/TreeEditListener.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/TreeEditListener.java index 36dc2451..ae1ffe9b 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/TreeEditListener.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/TreeEditListener.java @@ -21,60 +21,60 @@ public class TreeEditListener implements Listener { private final ModifyListener modifyListener; private final int column; - public TreeEditListener(Tree tree, ModifyListener modifyListener, int column) { + public TreeEditListener(final Tree tree, final ModifyListener modifyListener, final int column) { this.tree = tree; this.modifyListener = modifyListener; this.column = column; - editor = new TreeEditor(tree); + this.editor = new TreeEditor(tree); } // Editable TreeItems adapted from // https://git.eclipse.org/c/platform/eclipse.platform.swt.git/ // plain/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet111.java @Override - public void handleEvent(Event event) { + public void handleEvent(final Event event) { final TreeItem item = (TreeItem) event.item; - if ((item != null) && (item == lastItem[0]) && (item.getParentItem() != null)) { - boolean showBorder = true; - final Composite composite = new Composite(tree, SWT.NONE); + if ((item != null) && (item == this.lastItem[0]) && (item.getParentItem() != null)) { + final boolean showBorder = true; + final Composite composite = new Composite(this.tree, SWT.NONE); if (showBorder) { composite.setBackground(new Color(0, 0, 0)); } final Text text = new Text(composite, SWT.NONE); final int inset = showBorder ? 1 : 0; composite.addListener(SWT.Resize, e1 -> { - Rectangle rect1 = composite.getClientArea(); + final Rectangle rect1 = composite.getClientArea(); text.setBounds(rect1.x + inset, rect1.y + inset, rect1.width - (inset * 2), rect1.height - (inset * 2)); }); - Listener textListener = e2 -> { + final Listener textListener = e2 -> { switch (e2.type) { case SWT.FocusOut: - item.setText(column, text.getText()); - modifyListener.modifyText(null); + item.setText(this.column, text.getText()); + this.modifyListener.modifyText(null); composite.dispose(); break; case SWT.Verify: - String newText = text.getText(); - String leftText = newText.substring(0, e2.start); - String rightText = newText.substring(e2.end); - GC gc = new GC(text); + final String newText = text.getText(); + final String leftText = newText.substring(0, e2.start); + final String rightText = newText.substring(e2.end); + final GC gc = new GC(text); Point size = gc.textExtent(leftText + e2.text + rightText); gc.dispose(); size = text.computeSize(size.x, SWT.DEFAULT); - editor.horizontalAlignment = SWT.LEFT; - editor.setColumn(column); - Rectangle itemRect = item.getBounds(column), rect2 = tree.getClientArea(); - editor.minimumWidth = Math.max(size.x, itemRect.width) + (inset * 2); - int left = itemRect.x, right = rect2.x + rect2.width; - editor.minimumWidth = Math.min(editor.minimumWidth, right - left); - editor.minimumHeight = size.y + (inset * 2); - editor.layout(); + this.editor.horizontalAlignment = SWT.LEFT; + this.editor.setColumn(this.column); + final Rectangle itemRect = item.getBounds(this.column), rect2 = this.tree.getClientArea(); + this.editor.minimumWidth = Math.max(size.x, itemRect.width) + (inset * 2); + final int left = itemRect.x, right = rect2.x + rect2.width; + this.editor.minimumWidth = Math.min(this.editor.minimumWidth, right - left); + this.editor.minimumHeight = size.y + (inset * 2); + this.editor.layout(); break; case SWT.Traverse: switch (e2.detail) { case SWT.TRAVERSE_RETURN: - item.setText(column, text.getText()); - modifyListener.modifyText(null); + item.setText(this.column, text.getText()); + this.modifyListener.modifyText(null); // FALL THROUGH case SWT.TRAVERSE_ESCAPE: composite.dispose(); @@ -90,12 +90,12 @@ public void handleEvent(Event event) { text.addListener(SWT.FocusOut, textListener); text.addListener(SWT.Traverse, textListener); text.addListener(SWT.Verify, textListener); - editor.setEditor(composite, item); - text.setText(item.getText(column)); + this.editor.setEditor(composite, item); + text.setText(item.getText(this.column)); text.selectAll(); text.setFocus(); } - lastItem[0] = item; + this.lastItem[0] = item; } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/Retriever.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/Retriever.java index f4b77e29..3dd32cf2 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/Retriever.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/Retriever.java @@ -40,7 +40,7 @@ public class Retriever { private static Repository pcm; - public Retriever(RetrieverBlackboard blackboard) { + public Retriever(final RetrieverBlackboard blackboard) { this.blackboard = blackboard; } @@ -53,7 +53,7 @@ public static Repository getPCMRepository() { return pcm; } - public void analyze(RetrieverConfiguration configuration, IProgressMonitor progressMonitor) + public void analyze(final RetrieverConfiguration configuration, final IProgressMonitor progressMonitor) throws RetrieverException { try { @@ -66,8 +66,8 @@ public void analyze(RetrieverConfiguration configuration, IProgressMonitor progr final Set rules = configuration.getConfig(Rule.class) .getSelected(); - executeWith(inPath, outPath, rules, blackboard); - } catch (Exception e) { + executeWith(inPath, outPath, rules, this.blackboard); + } catch (final Exception e) { throw new RetrieverException("Analysis did not complete successfully", e); } } @@ -84,7 +84,8 @@ public void analyze(RetrieverConfiguration configuration, IProgressMonitor progr * @param ruleDoc * the object containing the rules */ - public static void executeWith(Path projectPath, Path outPath, List model, Set rules) { + public static void executeWith(final Path projectPath, final Path outPath, final List model, + final Set rules) { executeWith(projectPath, outPath, model, rules); } @@ -100,7 +101,8 @@ public static void executeWith(Path projectPath, Path outPath, List rules, RetrieverBlackboard blackboard) { + private static void executeWith(final Path projectPath, final Path outPath, final Set rules, + final RetrieverBlackboard blackboard) { // Creates a PCM repository with systems, components, interfaces and roles // Parses the docker-compose file to get a mapping between microservice names and @@ -111,22 +113,23 @@ private static void executeWith(Path projectPath, Path outPath, Set rules, pcm = new PCMInstanceCreator(blackboard).createPCM(mapping); // Create the build file systems - Map repoCompLocations = blackboard.getRepositoryComponentLocations(); - Map invertedEntityLocations = new HashMap<>(); - for (Entry entry : repoCompLocations.entrySet()) { + final Map repoCompLocations = blackboard + .getRepositoryComponentLocations(); + final Map invertedEntityLocations = new HashMap<>(); + for (final Entry entry : repoCompLocations.entrySet()) { invertedEntityLocations.put(entry.getValue(), entry.getKey()); } - FluentSystemFactory create = new FluentSystemFactory(); - for (Entry> entry : blackboard.getSystemAssociations() + final FluentSystemFactory create = new FluentSystemFactory(); + for (final Entry> entry : blackboard.getSystemAssociations() .entrySet()) { // TODO better name - ISystem system = create.newSystem() + final ISystem system = create.newSystem() .withName(entry.getKey() .toString()); boolean hasChildren = false; - for (CompilationUnit compUnit : entry.getValue()) { - RepositoryComponent repoComp = invertedEntityLocations.get(compUnit); + for (final CompilationUnit compUnit : entry.getValue()) { + final RepositoryComponent repoComp = invertedEntityLocations.get(compUnit); // Only compilation units that have been processed by some other rule can be // added to a system if (repoComp != null) { @@ -157,7 +160,7 @@ private static void executeWith(Path projectPath, Path outPath, Set rules, * the path to a .class file containing the rules * @return the rules from the specified (via gui) file system place */ - public static Rule loadRules(String namespace, Path rulesFile) { + public static Rule loadRules(final String namespace, final Path rulesFile) { final File file = rulesFile.toFile(); diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/RetrieverException.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/RetrieverException.java index 1c16a8a8..34c405cd 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/RetrieverException.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/RetrieverException.java @@ -9,11 +9,11 @@ public class RetrieverException extends Exception { private static final long serialVersionUID = 8438995877350048404L; - public RetrieverException(String message) { + public RetrieverException(final String message) { super(message); } - public RetrieverException(String message, Throwable cause) { + public RetrieverException(final String message, final Throwable cause) { super(message, cause); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/AnalystCollection.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/AnalystCollection.java index 91559bc5..034e0c2c 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/AnalystCollection.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/AnalystCollection.java @@ -14,17 +14,17 @@ public class AnalystCollection implements ServiceCollection { private final Set analysts = new HashSet<>(); public AnalystCollection() throws CoreException { - for (IConfigurationElement extension : Platform.getExtensionRegistry() + for (final IConfigurationElement extension : Platform.getExtensionRegistry() .getConfigurationElementsFor(EXTENSION_POINT)) { final Object o = extension.createExecutableExtension("class"); if (o instanceof Analyst) { - analysts.add((Analyst) o); + this.analysts.add((Analyst) o); } } } @Override public Set getServices() { - return Collections.unmodifiableSet(analysts); + return Collections.unmodifiableSet(this.analysts); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/DiscovererCollection.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/DiscovererCollection.java index 67cc26bf..72bda92d 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/DiscovererCollection.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/DiscovererCollection.java @@ -20,13 +20,13 @@ public DiscovererCollection() throws CoreException, InvalidRegistryObjectExcepti .getConfigurationElementsFor(EXTENSION_POINT)) { final Object o = extension.createExecutableExtension("class"); if (o instanceof Discoverer) { - discoverer.add((Discoverer) o); + this.discoverer.add((Discoverer) o); } } } @Override public Set getServices() { - return Collections.unmodifiableSet(discoverer); + return Collections.unmodifiableSet(this.discoverer); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/PerformanceAnalyst.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/PerformanceAnalyst.java index 6c5aaa63..dcf84c4f 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/PerformanceAnalyst.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/PerformanceAnalyst.java @@ -22,8 +22,8 @@ public class PerformanceAnalyst implements Analyst { private static final String ANALYST_ID = "org.palladiosimulator.retriever.core.service.performance_analyst"; @Override - public IBlackboardInteractingJob create(RetrieverConfiguration configuration, - RetrieverBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/RuleCollection.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/RuleCollection.java index e94d2026..a32164f7 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/RuleCollection.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/RuleCollection.java @@ -11,20 +11,20 @@ public class RuleCollection implements ServiceCollection { public static final String EXTENSION_POINT = "org.palladiosimulator.retriever.extraction.rule"; - private Set rules = new HashSet<>(); + private final Set rules = new HashSet<>(); public RuleCollection() throws CoreException { - for (IConfigurationElement extension : Platform.getExtensionRegistry() + for (final IConfigurationElement extension : Platform.getExtensionRegistry() .getConfigurationElementsFor(EXTENSION_POINT)) { final Object o = extension.createExecutableExtension("class"); if (o instanceof Rule) { - rules.add((Rule) o); + this.rules.add((Rule) o); } } } @Override public Set getServices() { - return rules; + return this.rules; } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PersistenceJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PersistenceJob.java index c8272f1c..528b7232 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PersistenceJob.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PersistenceJob.java @@ -28,8 +28,9 @@ public class PersistenceJob implements IBlackboardInteractingJob blackboard, URI inputFolder, URI outputFolder, String repositoryKey, - String systemKey, String allocationKey, String resourceEnvironmentKey) { + public PersistenceJob(final Blackboard blackboard, final URI inputFolder, final URI outputFolder, + final String repositoryKey, final String systemKey, final String allocationKey, + final String resourceEnvironmentKey) { this.blackboard = Objects.requireNonNull(blackboard); this.repositoryKey = Objects.requireNonNull(repositoryKey); @@ -50,26 +51,26 @@ public PersistenceJob(Blackboard blackboard, URI inputFolder, URI output } @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { // Fetch input from blackboard monitor.subTask("Retrieving job input from blackboard"); - Repository repository = (Repository) this.blackboard.getPartition(repositoryKey); - System system = (System) this.blackboard.getPartition(systemKey); - ResourceEnvironment resourceEnvironment = (ResourceEnvironment) this.blackboard - .getPartition(resourceEnvironmentKey); - Allocation allocation = (Allocation) this.blackboard.getPartition(allocationKey); + final Repository repository = (Repository) this.blackboard.getPartition(this.repositoryKey); + final System system = (System) this.blackboard.getPartition(this.systemKey); + final ResourceEnvironment resourceEnvironment = (ResourceEnvironment) this.blackboard + .getPartition(this.resourceEnvironmentKey); + final Allocation allocation = (Allocation) this.blackboard.getPartition(this.allocationKey); // Make blackboard models persistent by saving them as files monitor.subTask("Persisting models"); - ModelSaver.saveRepository(repository, outputFolder, projectName); - ModelSaver.saveSystem(system, outputFolder, projectName); - ModelSaver.saveResourceEnvironment(resourceEnvironment, outputFolder, projectName); - ModelSaver.saveAllocation(allocation, outputFolder, projectName); + ModelSaver.saveRepository(repository, this.outputFolder, this.projectName); + ModelSaver.saveSystem(system, this.outputFolder, this.projectName); + ModelSaver.saveResourceEnvironment(resourceEnvironment, this.outputFolder, this.projectName); + ModelSaver.saveAllocation(allocation, this.outputFolder, this.projectName); monitor.done(); } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { // No cleanup required for the job } @@ -79,7 +80,7 @@ public String getName() { } @Override - public void setBlackboard(Blackboard blackboard) { + public void setBlackboard(final Blackboard blackboard) { this.blackboard = Objects.requireNonNull(blackboard); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PlantUmlJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PlantUmlJob.java index 929ab9d1..f48b37e1 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PlantUmlJob.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PlantUmlJob.java @@ -7,6 +7,7 @@ import org.apache.log4j.Logger; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -30,44 +31,45 @@ public class PlantUmlJob extends AbstractBlackboardInteractingJob { - public RetrieverJob(RetrieverConfiguration configuration) { + public RetrieverJob(final RetrieverConfiguration configuration) { super.setBlackboard(new RetrieverBlackboard()); - super.addAll(createDiscovererJobs(configuration)); + super.addAll(this.createDiscovererJobs(configuration)); - super.addAll(createRuleJobs(configuration)); + super.addAll(this.createRuleJobs(configuration)); - super.addAll(createBuildRulesJob(configuration)); + super.addAll(this.createBuildRulesJob(configuration)); - super.add(new RetrieverBlackboardInteractingJob(configuration, getBlackboard())); + super.add(new RetrieverBlackboardInteractingJob(configuration, this.getBlackboard())); - super.addAll(createAnalystJobs(configuration)); + super.addAll(this.createAnalystJobs(configuration)); // Generate service effect specifications based on AST nodes and merge them into repository - super.add(new Ast2SeffJob(getBlackboard(), RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_SEFF_ASSOCIATIONS, + super.add(new Ast2SeffJob(this.getBlackboard(), + RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_SEFF_ASSOCIATIONS, RetrieverBlackboardKeys.RULE_ENGINE_AST2SEFF_OUTPUT_REPOSITORY)); - super.add(new SeffMergerJob(myBlackboard, RetrieverBlackboardKeys.RULE_ENGINE_AST2SEFF_OUTPUT_REPOSITORY, + super.add(new SeffMergerJob(this.myBlackboard, RetrieverBlackboardKeys.RULE_ENGINE_AST2SEFF_OUTPUT_REPOSITORY, RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY)); // Refine model and create final repository, system, allocation, & resource environment - super.add(new MoCoReJob(getBlackboard(), RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY, + super.add(new MoCoReJob(this.getBlackboard(), RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY, RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY, RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_SYSTEM, RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_ALLOCATION, RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_RESOURCE_ENVIRONMENT)); // Merge data & failure types into output repository - super.add(new TypeMergerJob(getBlackboard(), RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY, + super.add(new TypeMergerJob(this.getBlackboard(), RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY, RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY)); // Persist repository, system, allocation, & resource environment model from blackboard into // file system - super.add(new PersistenceJob(getBlackboard(), configuration.getInputFolder(), configuration.getOutputFolder(), - RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY, + super.add(new PersistenceJob(this.getBlackboard(), configuration.getInputFolder(), + configuration.getOutputFolder(), RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY, RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_SYSTEM, RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_ALLOCATION, RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_RESOURCE_ENVIRONMENT)); - super.add(new PlantUmlJob(configuration, getBlackboard())); + super.add(new PlantUmlJob(configuration, this.getBlackboard())); } - private List createRuleJobs(RetrieverConfiguration configuration) { - List jobs = new ArrayList<>(); + private List createRuleJobs(final RetrieverConfiguration configuration) { + final List jobs = new ArrayList<>(); - for (Collection step : configuration.getConfig(Rule.class) + for (final Collection step : configuration.getConfig(Rule.class) .getExecutionOrder()) { - ParallelJob parentJob = new ParallelJob(); - for (Rule rule : step) { + final ParallelJob parentJob = new ParallelJob(); + for (final Rule rule : step) { // Assume only build rules depend on build rules. if (rule.isBuildRule()) { continue; } - IBlackboardInteractingJob ruleJob = rule.create(configuration, myBlackboard); + final IBlackboardInteractingJob ruleJob = rule.create(configuration, + this.myBlackboard); parentJob.add(ruleJob); - logger.info("Adding rule job \"" + ruleJob.getName() + "\""); + this.logger.info("Adding rule job \"" + ruleJob.getName() + "\""); } jobs.add(parentJob); } @@ -81,20 +83,21 @@ private List createRuleJobs(RetrieverConfiguration configuration) { return jobs; } - private List createBuildRulesJob(RetrieverConfiguration configuration) { - List jobs = new ArrayList<>(); + private List createBuildRulesJob(final RetrieverConfiguration configuration) { + final List jobs = new ArrayList<>(); - for (Collection step : configuration.getConfig(Rule.class) + for (final Collection step : configuration.getConfig(Rule.class) .getExecutionOrder()) { - ParallelJob parentJob = new ParallelJob(); - for (Rule rule : step) { + final ParallelJob parentJob = new ParallelJob(); + for (final Rule rule : step) { // Assume only build rules depend on build rules. if (!rule.isBuildRule()) { continue; } - IBlackboardInteractingJob ruleJob = rule.create(configuration, myBlackboard); + final IBlackboardInteractingJob ruleJob = rule.create(configuration, + this.myBlackboard); parentJob.add(ruleJob); - logger.info("Adding build rule job \"" + ruleJob.getName() + "\""); + this.logger.info("Adding build rule job \"" + ruleJob.getName() + "\""); } jobs.add(parentJob); } @@ -102,17 +105,17 @@ private List createBuildRulesJob(RetrieverConfiguration configurati return jobs; } - private List createDiscovererJobs(RetrieverConfiguration configuration) { - List jobs = new ArrayList<>(); + private List createDiscovererJobs(final RetrieverConfiguration configuration) { + final List jobs = new ArrayList<>(); - for (Collection step : configuration.getConfig(Discoverer.class) + for (final Collection step : configuration.getConfig(Discoverer.class) .getExecutionOrder()) { - ParallelJob parentJob = new ParallelJob(); - for (Discoverer discoverer : step) { - IBlackboardInteractingJob discovererJob = discoverer.create(configuration, - myBlackboard); + final ParallelJob parentJob = new ParallelJob(); + for (final Discoverer discoverer : step) { + final IBlackboardInteractingJob discovererJob = discoverer.create(configuration, + this.myBlackboard); parentJob.add(discovererJob); - logger.info("Adding discoverer job \"" + discovererJob.getName() + "\""); + this.logger.info("Adding discoverer job \"" + discovererJob.getName() + "\""); } jobs.add(parentJob); } @@ -120,16 +123,17 @@ private List createDiscovererJobs(RetrieverConfiguration configurat return jobs; } - private List createAnalystJobs(RetrieverConfiguration configuration) { - List jobs = new ArrayList<>(); + private List createAnalystJobs(final RetrieverConfiguration configuration) { + final List jobs = new ArrayList<>(); - for (Collection step : configuration.getConfig(Analyst.class) + for (final Collection step : configuration.getConfig(Analyst.class) .getExecutionOrder()) { - ParallelJob parentJob = new ParallelJob(); - for (Analyst analyst : step) { - IBlackboardInteractingJob analystJob = analyst.create(configuration, myBlackboard); + final ParallelJob parentJob = new ParallelJob(); + for (final Analyst analyst : step) { + final IBlackboardInteractingJob analystJob = analyst.create(configuration, + this.myBlackboard); parentJob.add(analystJob); - logger.info("Adding analyst job \"" + analystJob.getName() + "\""); + this.logger.info("Adding analyst job \"" + analystJob.getName() + "\""); } jobs.add(parentJob); } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/SeffMergerJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/SeffMergerJob.java index 2da4047a..3601dffa 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/SeffMergerJob.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/SeffMergerJob.java @@ -35,23 +35,24 @@ public class SeffMergerJob implements IBlackboardInteractingJob blackboard, String sourceSeffRepositoryKey, - String destinationSeffRepositoryKey) { + public SeffMergerJob(final Blackboard blackboard, final String sourceSeffRepositoryKey, + final String destinationSeffRepositoryKey) { this.blackboard = Objects.requireNonNull(blackboard); this.sourceSeffRepositoryKey = sourceSeffRepositoryKey; this.destinationSeffRepositoryKey = destinationSeffRepositoryKey; } @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { // Fetch input from blackboard monitor.subTask("Retrieving source and destination repository from blackboard"); - Repository sourceRepository = (Repository) this.blackboard.getPartition(this.sourceSeffRepositoryKey); - Repository destinationRepository = (Repository) this.blackboard.getPartition(this.destinationSeffRepositoryKey); + final Repository sourceRepository = (Repository) this.blackboard.getPartition(this.sourceSeffRepositoryKey); + final Repository destinationRepository = (Repository) this.blackboard + .getPartition(this.destinationSeffRepositoryKey); // Move seffs from source to destination repository monitor.subTask("Merging ServiceEffectSpecificications from source with destination repository"); - for (RepositoryComponent component : sourceRepository.getComponents__Repository()) { + for (final RepositoryComponent component : sourceRepository.getComponents__Repository()) { if (!(component instanceof BasicComponent)) { continue; } @@ -59,8 +60,9 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan // Assumes that each component from source repository has a counterpart with the same // name in destination // repository. Otherwise, exception is thrown. - BasicComponent sourceComponent = (BasicComponent) component; - Optional destinationComponentOption = destinationRepository.getComponents__Repository() + final BasicComponent sourceComponent = (BasicComponent) component; + final Optional destinationComponentOption = destinationRepository + .getComponents__Repository() .stream() .filter(otherComponent -> otherComponent.getEntityName() .equals(sourceComponent.getEntityName())) @@ -72,15 +74,15 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan LOG.warn("Failed to find destination component " + sourceComponent.getEntityName() + "!"); continue; } - BasicComponent destinationComponent = destinationComponentOption.get(); + final BasicComponent destinationComponent = destinationComponentOption.get(); // Overwrite seffs within destination component - List sourceSeffs = List + final List sourceSeffs = List .copyOf(sourceComponent.getServiceEffectSpecifications__BasicComponent()); - for (ServiceEffectSpecification sourceSeff : sourceSeffs) { + for (final ServiceEffectSpecification sourceSeff : sourceSeffs) { // Retrieve destination signature for seff, throw if signature is not provided by // destination component - Optional destinationSignatureOption = destinationComponent + final Optional destinationSignatureOption = destinationComponent .getProvidedRoles_InterfaceProvidingEntity() .stream() .filter(role -> role instanceof OperationProvidedRole) @@ -98,7 +100,7 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan .getEntityName() + " in component " + destinationComponent.getEntityName() + "!"); continue; } - OperationSignature destinationSignature = destinationSignatureOption.get(); + final OperationSignature destinationSignature = destinationSignatureOption.get(); // Set component and signature of source seff to destination elements sourceSeff.setBasicComponent_ServiceEffectSpecification(destinationComponent); @@ -106,17 +108,17 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan // Adapt external call actions to new repository -> Swap signatures and required // roles - EList behaviorSteps = ((ResourceDemandingSEFF) sourceSeff).getSteps_Behaviour(); - for (AbstractAction action : behaviorSteps) { + final EList behaviorSteps = ((ResourceDemandingSEFF) sourceSeff).getSteps_Behaviour(); + for (final AbstractAction action : behaviorSteps) { if (!(action instanceof ExternalCallAction)) { continue; } - ExternalCallAction externalCallAction = (ExternalCallAction) action; - String calledSignatureEntityName = externalCallAction.getCalledService_ExternalService() + final ExternalCallAction externalCallAction = (ExternalCallAction) action; + final String calledSignatureEntityName = externalCallAction.getCalledService_ExternalService() .getEntityName(); // Fetch called signature from destination repository - Optional calledSignatureOption = destinationRepository + final Optional calledSignatureOption = destinationRepository .getInterfaces__Repository() .stream() .filter(interFace -> interFace instanceof OperationInterface) @@ -130,10 +132,10 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan LOG.warn("Failed to find called signature for " + calledSignatureEntityName + "!"); continue; } - OperationSignature calledSignature = calledSignatureOption.get(); + final OperationSignature calledSignature = calledSignatureOption.get(); // Fetch required role from destination repository - Optional requiredRoleOption = destinationComponent + final Optional requiredRoleOption = destinationComponent .getRequiredRoles_InterfaceRequiringEntity() .stream() .filter(role -> role instanceof OperationRequiredRole) @@ -149,14 +151,14 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan .getEntityName() + "#" + calledSignature.getEntityName() + "!"); continue; } - OperationRequiredRole requiredRole = requiredRoleOption.get(); + final OperationRequiredRole requiredRole = requiredRoleOption.get(); externalCallAction.setCalledService_ExternalService(calledSignature); externalCallAction.setRole_ExternalService(requiredRole); } // Find optional already existing and conflicting seff in destination component - Optional optionalDestinationSeff = destinationComponent + final Optional optionalDestinationSeff = destinationComponent .getServiceEffectSpecifications__BasicComponent() .stream() .filter(destinationSeff -> destinationSeff.getDescribedService__SEFF() @@ -176,7 +178,7 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { // No cleanup required for the job } @@ -186,7 +188,7 @@ public String getName() { } @Override - public void setBlackboard(Blackboard blackboard) { + public void setBlackboard(final Blackboard blackboard) { this.blackboard = Objects.requireNonNull(blackboard); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/TypeMergerJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/TypeMergerJob.java index 9782728b..5fe2ae1d 100644 --- a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/TypeMergerJob.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/TypeMergerJob.java @@ -19,19 +19,20 @@ public class TypeMergerJob implements IBlackboardInteractingJob blackboard, String sourceTypeRepositoryKey, - String destinationTypeRepositoryKey) { + public TypeMergerJob(final Blackboard blackboard, final String sourceTypeRepositoryKey, + final String destinationTypeRepositoryKey) { this.blackboard = Objects.requireNonNull(blackboard); this.sourceTypeRepositoryKey = sourceTypeRepositoryKey; this.destinationTypeRepositoryKey = destinationTypeRepositoryKey; } @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { // Fetch input from blackboard monitor.subTask("Retrieving source and destination repository from blackboard"); - Repository sourceRepository = (Repository) this.blackboard.getPartition(this.sourceTypeRepositoryKey); - Repository destinationRepository = (Repository) this.blackboard.getPartition(this.destinationTypeRepositoryKey); + final Repository sourceRepository = (Repository) this.blackboard.getPartition(this.sourceTypeRepositoryKey); + final Repository destinationRepository = (Repository) this.blackboard + .getPartition(this.destinationTypeRepositoryKey); // Move types from source to destination repository monitor.subTask("Merging types from source into destination repository"); @@ -43,7 +44,7 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { // No cleanup required for the job } @@ -53,7 +54,7 @@ public String getName() { } @Override - public void setBlackboard(Blackboard blackboard) { + public void setBlackboard(final Blackboard blackboard) { this.blackboard = Objects.requireNonNull(blackboard); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/CsvDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/CsvDiscoverer.java index 510435eb..170253df 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/CsvDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/CsvDiscoverer.java @@ -45,20 +45,21 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map> csvs = new HashMap<>(); - Discoverer.find(root, ".csv", logger) + Discoverer.find(root, ".csv", this.logger) .forEach(p -> { final List records = new LinkedList<>(); try (Reader reader = new FileReader(p.toFile())) { DEFAULT.parse(reader) .forEach(records::add); } catch (final IllegalStateException | IOException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } csvs.put(p, records); }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, csvs); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, csvs); } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/EcmaScriptDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/EcmaScriptDiscoverer.java index de72fc4a..d7ffa8ae 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/EcmaScriptDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/EcmaScriptDiscoverer.java @@ -42,9 +42,9 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map compilationUnits = new HashMap<>(); - Stream.concat(Discoverer.find(root, ".js", logger), Discoverer.find(root, ".ts", logger)) + Stream.concat(Discoverer.find(root, ".js", this.logger), Discoverer.find(root, ".ts", this.logger)) .forEach(p -> { try { final CompilationUnitTree compilationUnit = Parser.create() @@ -53,10 +53,11 @@ public void execute(final IProgressMonitor monitor) throws JobFailedException, U }); compilationUnits.put(p, compilationUnit); } catch (NashornException | IOException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, compilationUnits); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, compilationUnits); } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JavaDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JavaDiscoverer.java index c0703b2c..61795b1a 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JavaDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JavaDiscoverer.java @@ -42,7 +42,7 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map compilationUnits = new HashMap<>(); final ASTParser parser = ASTParser.newParser(AST.getJLSLatest()); parser.setKind(ASTParser.K_COMPILATION_UNIT); @@ -53,10 +53,10 @@ public void execute(final IProgressMonitor monitor) throws JobFailedException, U parser.setCompilerOptions( Map.of(JavaCore.COMPILER_SOURCE, latestJavaVersion, JavaCore.COMPILER_COMPLIANCE, latestJavaVersion, JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, latestJavaVersion)); - final String[] classpathEntries = Discoverer.find(root, ".jar", logger) + final String[] classpathEntries = Discoverer.find(root, ".jar", this.logger) .map(Path::toString) .toArray(String[]::new); - final String[] sourceFilePaths = Discoverer.find(root, ".java", logger) + final String[] sourceFilePaths = Discoverer.find(root, ".java", this.logger) .map(Path::toString) .toArray(String[]::new); try { @@ -69,9 +69,10 @@ public void acceptAST(final String sourceFilePath, final CompilationUnit ast) { } }, monitor); } catch (IllegalArgumentException | IllegalStateException e) { - logger.error(String.format("No Java files in %s could be transposed.", root), e); + this.logger.error(String.format("No Java files in %s could be transposed.", root), e); } - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, compilationUnits); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, compilationUnits); } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JsonDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JsonDiscoverer.java index 976fae23..8cdcae88 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JsonDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JsonDiscoverer.java @@ -43,19 +43,20 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map jsons = new HashMap<>(); - Discoverer.find(root, ".json", logger) + Discoverer.find(root, ".json", this.logger) .forEach(p -> { try (BufferedReader reader = new BufferedReader(new FileReader(p.toFile()))) { - String jsonSource = reader.lines() + final String jsonSource = reader.lines() .collect(Collectors.joining(System.lineSeparator())); jsons.put(p, new JSONObject(jsonSource)); } catch (ClassCastException | IOException | JSONException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, jsons); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, jsons); } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/PropertiesDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/PropertiesDiscoverer.java index 4cdef159..77eb49c4 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/PropertiesDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/PropertiesDiscoverer.java @@ -41,19 +41,20 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map propertyFiles = new HashMap<>(); - Discoverer.find(root, ".properties", logger) + Discoverer.find(root, ".properties", this.logger) .forEach(p -> { try (Reader reader = new FileReader(p.toFile())) { - Properties properties = new Properties(); + final Properties properties = new Properties(); properties.load(reader); propertyFiles.put(p, properties); } catch (final IOException | IllegalArgumentException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, propertyFiles); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, propertyFiles); } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/SqlDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/SqlDiscoverer.java index 5c6aa92a..b5216efb 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/SqlDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/SqlDiscoverer.java @@ -43,17 +43,18 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map sqls = new HashMap<>(); - Discoverer.find(root, ".sql", logger) + Discoverer.find(root, ".sql", this.logger) .forEach(p -> { try (Reader reader = new FileReader(p.toFile())) { sqls.put(p, CCJSqlParserUtil.parse(reader)); } catch (final IOException | JSQLParserException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, sqls); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, sqls); } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/XmlDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/XmlDiscoverer.java index 985b05a6..26fec6f0 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/XmlDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/XmlDiscoverer.java @@ -43,14 +43,14 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map xmls = new HashMap<>(); - Discoverer.find(root, ".xml", logger) + Discoverer.find(root, ".xml", this.logger) .forEach(p -> { try (Reader reader = new FileReader(p.toFile())) { xmls.put(p, new SAXBuilder().build(reader)); } catch (IOException | JDOMException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); @@ -61,7 +61,8 @@ public void execute(final IProgressMonitor monitor) throws JobFailedException, U .toString() .equalsIgnoreCase("pom.xml")) .forEach(p -> poms.put(p, xmls.get(p))); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, poms); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, poms); } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/YamlDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/YamlDiscoverer.java index 9660783e..d2606633 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/YamlDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/YamlDiscoverer.java @@ -47,23 +47,25 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map yamls = new HashMap<>(); final Map mappers = new HashMap<>(); - Stream.concat(Discoverer.find(root, ".yml", logger), Discoverer.find(root, ".yaml", logger)) + Stream.concat(Discoverer.find(root, ".yml", this.logger), Discoverer.find(root, ".yaml", this.logger)) .forEach(p -> { try (Reader reader = new FileReader(p.toFile())) { - List yamlContents = new ArrayList<>(); + final List yamlContents = new ArrayList<>(); new Yaml().loadAll(reader) .forEach(yamlContents::add); yamls.put(p, yamlContents); mappers.put(p, new YamlMapper(yamlContents)); } catch (final IOException | YAMLException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, yamls); - getBlackboard().putDiscoveredFiles(MAPPER_PARTITION_KEY, mappers); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, yamls); + this.getBlackboard() + .putDiscoveredFiles(MAPPER_PARTITION_KEY, mappers); } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/wrappers/YamlMapper.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/wrappers/YamlMapper.java index 40a1c7b5..eb281742 100644 --- a/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/wrappers/YamlMapper.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/wrappers/YamlMapper.java @@ -7,20 +7,20 @@ public class YamlMapper implements Function> { private final Iterable subfiles; - public YamlMapper(Iterable content) { + public YamlMapper(final Iterable content) { this.subfiles = content; } @Override - public Optional apply(String fullKey) { - String[] segments = fullKey.split("\\."); + public Optional apply(final String fullKey) { + final String[] segments = fullKey.split("\\."); - for (Object subfile : subfiles) { + for (final Object subfile : this.subfiles) { boolean failed = false; Object currentNode = subfile; - for (String segment : segments) { - Optional nextNode = load(segment, currentNode); + for (final String segment : segments) { + final Optional nextNode = this.load(segment, currentNode); if (nextNode.isEmpty()) { failed = true; break; @@ -36,9 +36,9 @@ public Optional apply(String fullKey) { return Optional.empty(); } - private Optional load(String key, Object yamlObject) { - if (yamlObject instanceof Map map) { - Object value = map.get(key); + private Optional load(final String key, final Object yamlObject) { + if (yamlObject instanceof final Map map) { + final Object value = map.get(key); return Optional.ofNullable(value); } return Optional.empty(); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/blackboard/RetrieverBlackboard.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/blackboard/RetrieverBlackboard.java index 25108770..4ce42184 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/blackboard/RetrieverBlackboard.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/blackboard/RetrieverBlackboard.java @@ -30,80 +30,80 @@ public class RetrieverBlackboard extends Blackboard { public RetrieverBlackboard() { super(); - repositoryComponentLocations = new HashMap<>(); - systemAssociations = new HashMap<>(); - systemPaths = new HashMap<>(); - discovererIDs = new HashSet<>(); - pcmDetector = new PCMDetector(); - addPartition(KEY_SEFF_ASSOCIATIONS, new HashMap<>()); + this.repositoryComponentLocations = new HashMap<>(); + this.systemAssociations = new HashMap<>(); + this.systemPaths = new HashMap<>(); + this.discovererIDs = new HashSet<>(); + this.pcmDetector = new PCMDetector(); + this.addPartition(KEY_SEFF_ASSOCIATIONS, new HashMap<>()); } - public CompilationUnit putRepositoryComponentLocation(RepositoryComponent repoComp, - CompilationUnit compilationUnit) { - return repositoryComponentLocations.put(repoComp, compilationUnit); + public CompilationUnit putRepositoryComponentLocation(final RepositoryComponent repoComp, + final CompilationUnit compilationUnit) { + return this.repositoryComponentLocations.put(repoComp, compilationUnit); } public Map getRepositoryComponentLocations() { - return Collections.unmodifiableMap(repositoryComponentLocations); + return Collections.unmodifiableMap(this.repositoryComponentLocations); } - public void setPCMDetector(PCMDetector pcmDetector) { + public void setPCMDetector(final PCMDetector pcmDetector) { this.pcmDetector = pcmDetector; } public PCMDetector getPCMDetector() { - return pcmDetector; + return this.pcmDetector; } - public void addSystemAssociations(Path path, Set compilationUnits) { - systemAssociations.put(path, Collections.unmodifiableSet(compilationUnits)); + public void addSystemAssociations(final Path path, final Set compilationUnits) { + this.systemAssociations.put(path, Collections.unmodifiableSet(compilationUnits)); } public Map> getSystemAssociations() { - return Collections.unmodifiableMap(systemAssociations); + return Collections.unmodifiableMap(this.systemAssociations); } - public void putSystemPath(System system, Path path) { - systemPaths.put(system, path); + public void putSystemPath(final System system, final Path path) { + this.systemPaths.put(system, path); } - public void putSeffAssociation(ASTNode astNode, ServiceEffectSpecification seff) { + public void putSeffAssociation(final ASTNode astNode, final ServiceEffectSpecification seff) { @SuppressWarnings("unchecked") - Map seffAssociations = (Map) getPartition( - KEY_SEFF_ASSOCIATIONS); + final Map seffAssociations = (Map) this + .getPartition(KEY_SEFF_ASSOCIATIONS); seffAssociations.put(astNode, seff); } - public ServiceEffectSpecification getSeffAssociation(ASTNode astNode) { + public ServiceEffectSpecification getSeffAssociation(final ASTNode astNode) { @SuppressWarnings("unchecked") - Map seffAssociations = (Map) getPartition( - KEY_SEFF_ASSOCIATIONS); + final Map seffAssociations = (Map) this + .getPartition(KEY_SEFF_ASSOCIATIONS); return seffAssociations.get(astNode); } public Map getSeffAssociations() { @SuppressWarnings("unchecked") - Map seffAssociations = (Map) getPartition( - KEY_SEFF_ASSOCIATIONS); + final Map seffAssociations = (Map) this + .getPartition(KEY_SEFF_ASSOCIATIONS); return Collections.unmodifiableMap(seffAssociations); } - public void putDiscoveredFiles(String discovererID, Map pathsToFiles) { - discovererIDs.add(discovererID); - addPartition(discovererID, pathsToFiles); + public void putDiscoveredFiles(final String discovererID, final Map pathsToFiles) { + this.discovererIDs.add(discovererID); + this.addPartition(discovererID, pathsToFiles); } - public Map getDiscoveredFiles(String discovererID, Class fileClass) { - Object partition = getPartition(discovererID); + public Map getDiscoveredFiles(final String discovererID, final Class fileClass) { + final Object partition = this.getPartition(discovererID); if (!(partition instanceof Map)) { return new HashMap<>(); } @SuppressWarnings("unchecked") // Not unchecked. - Map map = (Map) partition; + final Map map = (Map) partition; if (map.isEmpty()) { return new HashMap<>(); } - boolean allEntriesHaveCorrectType = map.entrySet() + final boolean allEntriesHaveCorrectType = map.entrySet() .stream() .allMatch(entry -> entry.getKey() instanceof Path && fileClass.isInstance(entry.getValue())); if (!allEntriesHaveCorrectType) { @@ -115,10 +115,10 @@ public Map getDiscoveredFiles(String discovererID, Class fileCla } public Set getDiscoveredPaths() { - Set discoveredPaths = new HashSet<>(); - for (String discovererID : discovererIDs) { + final Set discoveredPaths = new HashSet<>(); + for (final String discovererID : this.discovererIDs) { @SuppressWarnings("unchecked") // Local data structure, this assumption is an invariant. - Map partition = (Map) getPartition(discovererID); + final Map partition = (Map) this.getPartition(discovererID); discoveredPaths.addAll(partition.keySet()); } return discoveredPaths; diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompUnitOrName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompUnitOrName.java index 52f1002a..3a73739a 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompUnitOrName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompUnitOrName.java @@ -13,36 +13,36 @@ public class CompUnitOrName { private final Optional compilationUnit; private final String name; - public CompUnitOrName(String name) { + public CompUnitOrName(final String name) { this.compilationUnit = Optional.empty(); this.name = name; } - public CompUnitOrName(CompilationUnit compilationUnit) { + public CompUnitOrName(final CompilationUnit compilationUnit) { this.compilationUnit = Optional.of(compilationUnit); this.name = toName(compilationUnit); } public boolean isUnit() { - return compilationUnit.isPresent(); + return this.compilationUnit.isPresent(); } public Optional compilationUnit() { - return compilationUnit; + return this.compilationUnit; } public String name() { - return name; + return this.name; } - private static String toName(CompilationUnit compilationUnit) { + private static String toName(final CompilationUnit compilationUnit) { @SuppressWarnings("unchecked") - List types = (List) compilationUnit.types(); + final List types = compilationUnit.types(); if (types.isEmpty()) { return "void"; } - AbstractTypeDeclaration firstTypeDecl = types.get(0); - ITypeBinding binding = firstTypeDecl.resolveBinding(); + final AbstractTypeDeclaration firstTypeDecl = types.get(0); + final ITypeBinding binding = firstTypeDecl.resolveBinding(); if (binding == null) { return firstTypeDecl.getName() .getFullyQualifiedName(); @@ -52,21 +52,18 @@ private static String toName(CompilationUnit compilationUnit) { @Override public int hashCode() { - return Objects.hash(compilationUnit, name); + return Objects.hash(this.compilationUnit, this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - CompUnitOrName other = (CompUnitOrName) obj; - return Objects.equals(compilationUnit, other.compilationUnit) && Objects.equals(name, other.name); + final CompUnitOrName other = (CompUnitOrName) obj; + return Objects.equals(this.compilationUnit, other.compilationUnit) && Objects.equals(this.name, other.name); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Component.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Component.java index 2f9f25d3..a45035f8 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Component.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Component.java @@ -7,7 +7,7 @@ /** * Components are {@code CompilationUnits}. They provide and require interfaces. - * + * * @see CompilationUnit * @author Florian Bossert */ @@ -16,63 +16,62 @@ public class Component { private final Requirements requirements; private final Provisions provisions; - public Component(CompUnitOrName compUnitOrName, Requirements requirements, Provisions provisions) { + public Component(final CompUnitOrName compUnitOrName, final Requirements requirements, + final Provisions provisions) { this.compUnitOrName = compUnitOrName; this.requirements = requirements; this.provisions = provisions; } public Requirements requirements() { - return requirements; + return this.requirements; } public Provisions provisions() { - return provisions; + return this.provisions; } public Optional compilationUnit() { - return compUnitOrName.compilationUnit(); + return this.compUnitOrName.compilationUnit(); } public String name() { - return compUnitOrName.name(); + return this.compUnitOrName.name(); } public CompUnitOrName identifier() { - return compUnitOrName; + return this.compUnitOrName; } @Override public int hashCode() { - return Objects.hash(compUnitOrName, provisions, requirements); + return Objects.hash(this.compUnitOrName, this.provisions, this.requirements); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Component other = (Component) obj; - return Objects.equals(compUnitOrName, other.compUnitOrName) && Objects.equals(provisions, other.provisions) - && Objects.equals(requirements, other.requirements); + final Component other = (Component) obj; + return Objects.equals(this.compUnitOrName, other.compUnitOrName) + && Objects.equals(this.provisions, other.provisions) + && Objects.equals(this.requirements, other.requirements); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("Name: "); - builder.append(name()); + builder.append(this.name()); builder.append("\nRequirements:\n\t"); - builder.append(requirements.toString() + builder.append(this.requirements.toString() .replace("\n", "\n\t")); builder.append("\nProvisions:\n\t"); - builder.append(provisions.toString() + builder.append(this.provisions.toString() .replace("\n", "\n\t")); return builder.toString(); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ComponentBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ComponentBuilder.java index e3231298..41fa93d9 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ComponentBuilder.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ComponentBuilder.java @@ -5,7 +5,7 @@ /** * Used to build {@code Component}s. - * + * * @see Component * @author Florian Bossert */ @@ -14,48 +14,46 @@ public class ComponentBuilder { private final RequirementsBuilder requirements; private final ProvisionsBuilder provisions; - public ComponentBuilder(CompUnitOrName compUnitOrName) { + public ComponentBuilder(final CompUnitOrName compUnitOrName) { this.compUnitOrName = compUnitOrName; this.requirements = new RequirementsBuilder(); this.provisions = new ProvisionsBuilder(); } public CompUnitOrName identifier() { - return compUnitOrName; + return this.compUnitOrName; } public RequirementsBuilder requirements() { - return requirements; + return this.requirements; } public ProvisionsBuilder provisions() { - return provisions; + return this.provisions; } - public Component create(Collection allDependencies, - Collection visibleProvisions) { - return new Component(compUnitOrName, requirements.create(allDependencies, visibleProvisions), - provisions.create(allDependencies)); + public Component create(final Collection allDependencies, + final Collection visibleProvisions) { + return new Component(this.compUnitOrName, this.requirements.create(allDependencies, visibleProvisions), + this.provisions.create(allDependencies)); } @Override public int hashCode() { - return Objects.hash(compUnitOrName, provisions, requirements); + return Objects.hash(this.compUnitOrName, this.provisions, this.requirements); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - ComponentBuilder other = (ComponentBuilder) obj; - return Objects.equals(compUnitOrName, other.compUnitOrName) && Objects.equals(provisions, other.provisions) - && Objects.equals(requirements, other.requirements); + final ComponentBuilder other = (ComponentBuilder) obj; + return Objects.equals(this.compUnitOrName, other.compUnitOrName) + && Objects.equals(this.provisions, other.provisions) + && Objects.equals(this.requirements, other.requirements); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Composite.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Composite.java index 3f83f24e..1acb87eb 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Composite.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Composite.java @@ -12,8 +12,8 @@ public class Composite { private final Set requirements; private final Set provisions; - public Composite(String name, Set parts, Set requirements, - Set provisions, Set internalInterfaces) { + public Composite(final String name, final Set parts, final Set requirements, + final Set provisions, final Set internalInterfaces) { this.name = name; this.parts = parts; this.internalInterfaces = internalInterfaces; @@ -22,70 +22,68 @@ public Composite(String name, Set parts, Set requ } public String name() { - return name; + return this.name; } public Set requirements() { - return requirements; + return this.requirements; } public Set provisions() { - return provisions; + return this.provisions; } public Set parts() { - return Collections.unmodifiableSet(parts); + return Collections.unmodifiableSet(this.parts); } public Set internalInterfaces() { - return Collections.unmodifiableSet(internalInterfaces); + return Collections.unmodifiableSet(this.internalInterfaces); } public boolean isSubsetOf(final Composite other) { return other.parts() - .containsAll(parts); + .containsAll(this.parts); } @Override public int hashCode() { - return Objects.hash(internalInterfaces, name, parts, provisions, requirements); + return Objects.hash(this.internalInterfaces, this.name, this.parts, this.provisions, this.requirements); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Composite other = (Composite) obj; - return Objects.equals(internalInterfaces, other.internalInterfaces) && Objects.equals(name, other.name) - && Objects.equals(parts, other.parts) && Objects.equals(provisions, other.provisions) - && Objects.equals(requirements, other.requirements); + final Composite other = (Composite) obj; + return Objects.equals(this.internalInterfaces, other.internalInterfaces) + && Objects.equals(this.name, other.name) && Objects.equals(this.parts, other.parts) + && Objects.equals(this.provisions, other.provisions) + && Objects.equals(this.requirements, other.requirements); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("Name: "); - builder.append(name); + builder.append(this.name); builder.append("\nRequirements:\n\t"); - builder.append(requirements.toString() + builder.append(this.requirements.toString() .replace("\n", "\n\t")); builder.append("\nProvisions:\n\t"); - builder.append(provisions.toString() + builder.append(this.provisions.toString() .replace("\n", "\n\t")); builder.append("\nInternal interfaces:\n"); - internalInterfaces.forEach(x -> builder.append('\t') + this.internalInterfaces.forEach(x -> builder.append('\t') .append(x.toString() .replace("\n", "\n\t")) .append('\n')); builder.append("\nParts:\n"); - parts.forEach(x -> builder.append('\t') + this.parts.forEach(x -> builder.append('\t') .append(x.toString() .replace("\n", "\n\t")) .append('\n')); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompositeBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompositeBuilder.java index 280deac3..224c5dc6 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompositeBuilder.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompositeBuilder.java @@ -18,48 +18,48 @@ public class CompositeBuilder { - private String name; - private Set explicitParts = new HashSet<>(); + private final String name; + private final Set explicitParts = new HashSet<>(); - public CompositeBuilder(String name) { + public CompositeBuilder(final String name) { this.name = name; } - public void addPart(ComponentBuilder componentBuilder) { - explicitParts.add(componentBuilder); + public void addPart(final ComponentBuilder componentBuilder) { + this.explicitParts.add(componentBuilder); } - public boolean hasPart(CompUnitOrName identifier) { - return explicitParts.stream() + public boolean hasPart(final CompUnitOrName identifier) { + return this.explicitParts.stream() .anyMatch(part -> part.identifier() .equals(identifier)); } public Collection getParts() { - return Set.copyOf(explicitParts); + return Set.copyOf(this.explicitParts); } - public Composite construct(Collection allComponents, Requirements compositeRequirements, - Provisions compositeProvisions, Collection visibleProvisions) { - Logger.getLogger(getClass()) - .warn("Constructing composite component " + name); + public Composite construct(final Collection allComponents, final Requirements compositeRequirements, + final Provisions compositeProvisions, final Collection visibleProvisions) { + Logger.getLogger(this.getClass()) + .warn("Constructing composite component " + this.name); - List allDependencies = new LinkedList<>(); - for (OperationInterface requirement : compositeRequirements) { + final List allDependencies = new LinkedList<>(); + for (final OperationInterface requirement : compositeRequirements) { allDependencies.add(requirement); } - for (OperationInterface provision : compositeProvisions) { + for (final OperationInterface provision : compositeProvisions) { allDependencies.add(provision); } // Create and add all explicit parts. - Set parts = explicitParts.stream() + final Set parts = this.explicitParts.stream() .map(x -> x.create(allDependencies, visibleProvisions)) .collect(Collectors.toSet()); - Set remainingComponents = new HashSet<>(allComponents); + final Set remainingComponents = new HashSet<>(allComponents); remainingComponents.removeAll(parts); - Set internalInterfaces = new HashSet<>(); + final Set internalInterfaces = new HashSet<>(); int previousPartCount = 0; int previousInternalInterfaceCount = 0; @@ -73,21 +73,21 @@ public Composite construct(Collection allComponents, Requirements com internalInterfaces); } while (parts.size() > previousPartCount && internalInterfaces.size() > previousInternalInterfaceCount); - List requirements = new ArrayList<>(); - List>> provisions = new ArrayList<>(); + final List requirements = new ArrayList<>(); + final List>> provisions = new ArrayList<>(); - for (Component part : parts) { + for (final Component part : parts) { requirements.addAll(part.requirements() .get()); provisions.add(part.provisions() .getGrouped()); } - Set externalRequirements = requirements.stream() + final Set externalRequirements = requirements.stream() .filter(x -> compositeRequirements.containsEntire(x)) .collect(Collectors.toSet()); - Set externalProvisions = MapMerger.merge(provisions) + final Set externalProvisions = MapMerger.merge(provisions) .entrySet() .stream() .filter(entry -> entry.getValue() @@ -96,24 +96,24 @@ public Composite construct(Collection allComponents, Requirements com .map(entry -> entry.getKey()) .collect(Collectors.toSet()); - return new Composite(name, parts, externalRequirements, externalProvisions, internalInterfaces); + return new Composite(this.name, parts, externalRequirements, externalProvisions, internalInterfaces); } // Writes to remainingComopnents, parts, and internalInterfaces. - private static void propagateProvisions(Set remainingComponents, - final Requirements compositeRequirements, final Provisions compositeProvisions, Set parts, - Set internalInterfaces) { + private static void propagateProvisions(final Set remainingComponents, + final Requirements compositeRequirements, final Provisions compositeProvisions, final Set parts, + final Set internalInterfaces) { - List newParts = new LinkedList<>(); - for (Component providingPart : parts) { - List traversedInterfaces = findRequiringComponents(remainingComponents, + final List newParts = new LinkedList<>(); + for (final Component providingPart : parts) { + final List traversedInterfaces = findRequiringComponents(remainingComponents, compositeRequirements, compositeProvisions, newParts, providingPart); - Queue sortedInterfaces = new PriorityQueue<>(traversedInterfaces); + final Queue sortedInterfaces = new PriorityQueue<>(traversedInterfaces); while (!sortedInterfaces.isEmpty()) { - OperationInterface iface = sortedInterfaces.poll(); + final OperationInterface iface = sortedInterfaces.poll(); boolean isRoot = true; - for (OperationInterface rootInterface : internalInterfaces) { + for (final OperationInterface rootInterface : internalInterfaces) { if (iface.isPartOf(rootInterface)) { isRoot = false; break; @@ -133,20 +133,20 @@ private static void propagateProvisions(Set remainingComponents, } // Writes to remainingComopnents, parts, and internalInterfaces. - private static void propagateRequirements(Set remainingComponents, - final Requirements compositeRequirements, final Provisions compositeProvisions, Set parts, - Set internalInterfaces) { + private static void propagateRequirements(final Set remainingComponents, + final Requirements compositeRequirements, final Provisions compositeProvisions, final Set parts, + final Set internalInterfaces) { - List newParts = new LinkedList<>(); - for (Component requiringPart : parts) { - List traversedInterfaces = findProvidingComponents(remainingComponents, + final List newParts = new LinkedList<>(); + for (final Component requiringPart : parts) { + final List traversedInterfaces = findProvidingComponents(remainingComponents, compositeRequirements, compositeProvisions, newParts, requiringPart); - Queue sortedInterfaces = new PriorityQueue<>(traversedInterfaces); + final Queue sortedInterfaces = new PriorityQueue<>(traversedInterfaces); while (!sortedInterfaces.isEmpty()) { - OperationInterface iface = sortedInterfaces.poll(); + final OperationInterface iface = sortedInterfaces.poll(); boolean isRoot = true; - for (OperationInterface rootInterface : internalInterfaces) { + for (final OperationInterface rootInterface : internalInterfaces) { if (iface.isPartOf(rootInterface)) { isRoot = false; break; @@ -166,11 +166,11 @@ private static void propagateRequirements(Set remainingComponents, } // May remove components from remainingComponents. - private static List findRequiringComponents(Set remainingComponents, - final Requirements compositeRequirements, final Provisions compositeProvisions, List newParts, - final Component providingComponent) { + private static List findRequiringComponents(final Set remainingComponents, + final Requirements compositeRequirements, final Provisions compositeProvisions, + final List newParts, final Component providingComponent) { - Stack provisions = new Stack<>(); + final Stack provisions = new Stack<>(); providingComponent.provisions() .get() .stream() @@ -180,10 +180,10 @@ private static List findRequiringComponents(Set r .filter(x -> !compositeProvisions.containsEntire(x)) .forEach(provisions::add); - List traversedOperations = new ArrayList<>(); + final List traversedOperations = new ArrayList<>(); while (!provisions.isEmpty()) { - OperationInterface provision = provisions.pop(); - Set requiringComponents = remainingComponents.stream() + final OperationInterface provision = provisions.pop(); + final Set requiringComponents = remainingComponents.stream() .filter(x -> x.requirements() .containsPartOf(provision)) .filter(x -> !providingComponent.equals(x)) @@ -201,11 +201,11 @@ private static List findRequiringComponents(Set r } // May remove components from remainingComponents. - private static List findProvidingComponents(Set remainingComponents, - final Requirements compositeRequirements, final Provisions compositeProvisions, List newParts, - final Component requiringComponent) { + private static List findProvidingComponents(final Set remainingComponents, + final Requirements compositeRequirements, final Provisions compositeProvisions, + final List newParts, final Component requiringComponent) { - Stack requirements = new Stack<>(); + final Stack requirements = new Stack<>(); requiringComponent.requirements() .get() .stream() @@ -215,10 +215,10 @@ private static List findProvidingComponents(Set r .filter(x -> !compositeProvisions.containsEntire(x)) .forEach(requirements::add); - List traversedOperations = new ArrayList<>(); + final List traversedOperations = new ArrayList<>(); while (!requirements.isEmpty()) { - OperationInterface requirement = requirements.pop(); - Set providingComponents = remainingComponents.stream() + final OperationInterface requirement = requirements.pop(); + final Set providingComponents = remainingComponents.stream() .filter(x -> x.provisions() .containsPartOf(requirement)) .filter(x -> !requiringComponent.equals(x)) @@ -237,21 +237,18 @@ private static List findProvidingComponents(Set r @Override public int hashCode() { - return Objects.hash(explicitParts, name); + return Objects.hash(this.explicitParts, this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - CompositeBuilder other = (CompositeBuilder) obj; - return Objects.equals(explicitParts, other.explicitParts) && Objects.equals(name, other.name); + final CompositeBuilder other = (CompositeBuilder) obj; + return Objects.equals(this.explicitParts, other.explicitParts) && Objects.equals(this.name, other.name); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/DependencyUtils.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/DependencyUtils.java index 31de061f..6ce2941a 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/DependencyUtils.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/DependencyUtils.java @@ -22,19 +22,19 @@ private DependencyUtils() throws IllegalAccessException { * Group all dependencies in {@code dependencies} by finding their common ancestors. Ensure that * no other dependency (not in {@code dependencies}, but in {@code allDependencies}) is included * into a group by accident. - * + * * @param * only for ease of calling */ public static Map> groupDependencies( - Collection dependencies, Collection allDependencies) { - Map> groupedDependencies = new HashMap<>(); - Queue sortedDependencies = new PriorityQueue<>(dependencies); + final Collection dependencies, final Collection allDependencies) { + final Map> groupedDependencies = new HashMap<>(); + final Queue sortedDependencies = new PriorityQueue<>(dependencies); while (!sortedDependencies.isEmpty()) { - OperationInterface grouplessDependency = sortedDependencies.poll(); + final OperationInterface grouplessDependency = sortedDependencies.poll(); boolean isRoot = true; - for (OperationInterface rootInterface : groupedDependencies.keySet()) { + for (final OperationInterface rootInterface : groupedDependencies.keySet()) { if (grouplessDependency.isPartOf(rootInterface)) { groupedDependencies.get(rootInterface) .add(grouplessDependency); @@ -43,8 +43,8 @@ public static Map commonInterfaceName = grouplessDependency.getName() + for (final OperationInterface rootInterface : groupedDependencies.keySet()) { + final Optional commonInterfaceName = grouplessDependency.getName() .getCommonInterface(rootInterface.getName()); boolean containsOtherDependency = false; @@ -52,10 +52,10 @@ public static Map Map interfaces = new HashSet<>(groupedDependencies.remove(rootInterface)); + final Set interfaces = new HashSet<>( + groupedDependencies.remove(rootInterface)); interfaces.add(commonInterface); interfaces.add(rootInterface); interfaces.add(grouplessDependency); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/EntireInterface.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/EntireInterface.java index 57058b54..d4590246 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/EntireInterface.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/EntireInterface.java @@ -11,22 +11,23 @@ public class EntireInterface implements OperationInterface { private final Optional binding; private final InterfaceName name; - public EntireInterface(InterfaceName name) { + public EntireInterface(final InterfaceName name) { this.binding = Optional.empty(); this.name = name; } - public EntireInterface(ITypeBinding binding, InterfaceName name) { + public EntireInterface(final ITypeBinding binding, final InterfaceName name) { this.binding = Optional.of(binding); this.name = name; } public Optional getBinding() { - return binding; + return this.binding; } + @Override public Name getName() { - return name; + return this.name; } @Override @@ -36,32 +37,29 @@ public Map> simplified() { @Override public String getInterface() { - return name.getInterfaces() + return this.name.getInterfaces() .get(0); } @Override public int hashCode() { - return Objects.hash(binding, name); + return Objects.hash(this.binding, this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - EntireInterface other = (EntireInterface) obj; - return Objects.equals(binding, other.binding) && Objects.equals(name, other.name); + final EntireInterface other = (EntireInterface) obj; + return Objects.equals(this.binding, other.binding) && Objects.equals(this.name, other.name); } @Override public String toString() { - return name.toString(); + return this.name.toString(); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaInterfaceName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaInterfaceName.java index 4b363cc0..5f661674 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaInterfaceName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaInterfaceName.java @@ -6,47 +6,44 @@ public class JavaInterfaceName implements InterfaceName { private final String name; - public JavaInterfaceName(String name) { + public JavaInterfaceName(final String name) { this.name = name; } @Override public String getName() { - return name; + return this.name; } @Override public List getInterfaces() { - return List.of(name); + return List.of(this.name); } @Override - public InterfaceName createInterface(String name) { + public InterfaceName createInterface(final String name) { return new JavaInterfaceName(name); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - JavaInterfaceName other = (JavaInterfaceName) obj; - return Objects.equals(name, other.name); + final JavaInterfaceName other = (JavaInterfaceName) obj; + return Objects.equals(this.name, other.name); } @Override public String toString() { - return name; + return this.name; } } \ No newline at end of file diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaOperationName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaOperationName.java index f8401e0c..6b0f35be 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaOperationName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaOperationName.java @@ -8,56 +8,53 @@ public class JavaOperationName implements OperationName { private final String iface; private final String method; - public JavaOperationName(String iface, String method) { + public JavaOperationName(final String iface, final String method) { this.iface = iface; this.method = method; } @Override - public Optional forInterface(String baseInterface) { - if (!iface.equals(baseInterface) && !baseInterface.startsWith(iface + "#")) { + public Optional forInterface(final String baseInterface) { + if (!this.iface.equals(baseInterface) && !baseInterface.startsWith(this.iface + "#")) { return Optional.empty(); } - return Optional.of(method); + return Optional.of(this.method); } @Override public List getInterfaces() { - return List.of(toString(), iface); + return List.of(this.toString(), this.iface); } @Override public String getInterface() { - return iface; + return this.iface; } @Override - public InterfaceName createInterface(String name) { + public InterfaceName createInterface(final String name) { return new JavaInterfaceName(name); } @Override public int hashCode() { - return Objects.hash(iface, method); + return Objects.hash(this.iface, this.method); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - JavaOperationName other = (JavaOperationName) obj; - return Objects.equals(iface, other.iface) && Objects.equals(method, other.method); + final JavaOperationName other = (JavaOperationName) obj; + return Objects.equals(this.iface, other.iface) && Objects.equals(this.method, other.method); } @Override public String toString() { - return iface + "#" + method; + return this.iface + "#" + this.method; } } \ No newline at end of file diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Name.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Name.java index 550ab40a..b87002e7 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Name.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Name.java @@ -16,9 +16,9 @@ public interface Name { /** * @returns the most specific common interface */ - default Optional getCommonInterface(Name other) { - Set interfaces = new HashSet<>(getInterfaces()); - for (String iface : other.getInterfaces()) { + default Optional getCommonInterface(final Name other) { + final Set interfaces = new HashSet<>(this.getInterfaces()); + for (final String iface : other.getInterfaces()) { if (interfaces.contains(iface)) { return Optional.of(iface); } @@ -26,7 +26,8 @@ default Optional getCommonInterface(Name other) { return Optional.empty(); } - default boolean isPartOf(String iface) { - return getInterfaces().contains(iface); + default boolean isPartOf(final String iface) { + return this.getInterfaces() + .contains(iface); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Operation.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Operation.java index fd1745bf..a966ddf7 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Operation.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Operation.java @@ -10,17 +10,18 @@ public class Operation implements OperationInterface { private final IMethodBinding binding; private final OperationName name; - public Operation(IMethodBinding binding, OperationName name) { + public Operation(final IMethodBinding binding, final OperationName name) { this.binding = binding; this.name = name; } public IMethodBinding getBinding() { - return binding; + return this.binding; } + @Override public OperationName getName() { - return name; + return this.name; } @Override @@ -30,31 +31,29 @@ public Map> simplified() { @Override public int hashCode() { - return Objects.hash(binding, name); + return Objects.hash(this.binding, this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - Operation other = (Operation) obj; - return Objects.equals(binding, other.binding) && Objects.equals(name, other.name); + final Operation other = (Operation) obj; + return Objects.equals(this.binding, other.binding) && Objects.equals(this.name, other.name); } @Override public String getInterface() { - return name.getInterface(); + return this.name.getInterface(); } @Override public String toString() { - return getName().toString(); + return this.getName() + .toString(); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationInterface.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationInterface.java index aa5fb573..8d9775a4 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationInterface.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationInterface.java @@ -13,15 +13,16 @@ public interface OperationInterface extends Comparable { */ String getInterface(); - default boolean isPartOf(OperationInterface other) { - return getName().isPartOf(other.getName() - .toString()); + default boolean isPartOf(final OperationInterface other) { + return this.getName() + .isPartOf(other.getName() + .toString()); } @Override - default int compareTo(OperationInterface other) { - boolean isSubset = this.isPartOf(other); - boolean isSuperset = other.isPartOf(this); + default int compareTo(final OperationInterface other) { + final boolean isSubset = this.isPartOf(other); + final boolean isSuperset = other.isPartOf(this); if (isSubset && isSuperset) { return 0; // equal } else if (isSubset) { @@ -30,7 +31,8 @@ default int compareTo(OperationInterface other) { return -1; } - return getName().toString() + return this.getName() + .toString() .compareTo(other.getName() .toString()); // disjoint } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/PCMDetectionResult.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/PCMDetectionResult.java index 19b8f2b0..4f62ef68 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/PCMDetectionResult.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/PCMDetectionResult.java @@ -14,24 +14,24 @@ public class PCMDetectionResult { private final Set composites; private final Map> operationInterfaces; - public PCMDetectionResult(Map components, - Map composites, ProvisionsBuilder compositeProvisions, - RequirementsBuilder compositeRequirements) { + public PCMDetectionResult(final Map components, + final Map composites, final ProvisionsBuilder compositeProvisions, + final RequirementsBuilder compositeRequirements) { // Collect globally visible provisions - Set temporaryComponents = PCMDetectionResult.createComponents(components, compositeProvisions, + final Set temporaryComponents = PCMDetectionResult.createComponents(components, compositeProvisions, compositeRequirements, Set.of()); - Set connectedComponents = PCMDetectionResult.collectConnectedComponents(temporaryComponents, + final Set connectedComponents = PCMDetectionResult.collectConnectedComponents(temporaryComponents, composites, compositeProvisions, compositeRequirements); - Set temporaryComposites = PCMDetectionResult.createCompositeComponents(connectedComponents, + final Set temporaryComposites = PCMDetectionResult.createCompositeComponents(connectedComponents, composites, compositeProvisions, compositeRequirements, Set.of()); - Set visibleProvisions = PCMDetectionResult.collectVisibleProvisions(connectedComponents, - temporaryComposites); + final Set visibleProvisions = PCMDetectionResult + .collectVisibleProvisions(connectedComponents, temporaryComposites); // TODO: Do not rebuild everything, that is theoretically not necessary since provisions do // not change. - Map connectedComponentBuilders = connectedComponents.stream() + final Map connectedComponentBuilders = connectedComponents.stream() .map(Component::identifier) .map(components::get) .collect(Collectors.toMap(ComponentBuilder::identifier, x -> x)); @@ -41,28 +41,28 @@ public PCMDetectionResult(Map components, compositeRequirements, visibleProvisions); this.composites = PCMDetectionResult.createCompositeComponents(this.components, composites, compositeProvisions, compositeRequirements, visibleProvisions); - this.operationInterfaces = createOperationInterfaces(); + this.operationInterfaces = this.createOperationInterfaces(); } - private static Set collectConnectedComponents(Set temporaryComponents, - Map composites, ProvisionsBuilder compositeProvisions, - RequirementsBuilder compositeRequirements) { - CompositeBuilder metaCompositeBuilder = new CompositeBuilder("Meta Composite"); - for (CompositeBuilder composite : composites.values()) { - for (ComponentBuilder part : composite.getParts()) { + private static Set collectConnectedComponents(final Set temporaryComponents, + final Map composites, final ProvisionsBuilder compositeProvisions, + final RequirementsBuilder compositeRequirements) { + final CompositeBuilder metaCompositeBuilder = new CompositeBuilder("Meta Composite"); + for (final CompositeBuilder composite : composites.values()) { + for (final ComponentBuilder part : composite.getParts()) { metaCompositeBuilder.addPart(part); } } - Composite metaComposite = metaCompositeBuilder.construct(temporaryComponents, + final Composite metaComposite = metaCompositeBuilder.construct(temporaryComponents, new RequirementsBuilder().create(Set.of(), Set.of()), new ProvisionsBuilder().create(Set.of()), Set.of()); return metaComposite.parts(); } - private static Set createComponents(Map components, - ProvisionsBuilder compositeProvisions, RequirementsBuilder compositeRequirements, - Set visibleProvisions) { - List allDependencies = new LinkedList<>(); + private static Set createComponents(final Map components, + final ProvisionsBuilder compositeProvisions, final RequirementsBuilder compositeRequirements, + final Set visibleProvisions) { + final List allDependencies = new LinkedList<>(); // TODO: Aren't the dependencies of free components missing here? Is that alright? allDependencies.addAll(compositeRequirements.toList()); allDependencies.addAll(compositeProvisions.toList()); @@ -73,23 +73,23 @@ private static Set createComponents(Map createCompositeComponents(Set freeComponents, - Map composites, ProvisionsBuilder compositeProvisions, - RequirementsBuilder compositeRequirements, Set visibleProvisions) { + private static Set createCompositeComponents(final Set freeComponents, + final Map composites, final ProvisionsBuilder compositeProvisions, + final RequirementsBuilder compositeRequirements, final Set visibleProvisions) { // Construct composites. Set constructedComposites = new HashSet<>(); - List allComposites = composites.values() + final List allComposites = composites.values() .stream() .map(x -> x.construct(freeComponents, compositeRequirements.create(visibleProvisions, visibleProvisions), compositeProvisions.create(visibleProvisions), visibleProvisions)) .collect(Collectors.toList()); // Remove redundant composites. - Set redundantComposites = new HashSet<>(); + final Set redundantComposites = new HashSet<>(); for (int i = 0; i < allComposites.size(); ++i) { - Composite subject = allComposites.get(i); - long subsetCount = allComposites.subList(i + 1, allComposites.size()) + final Composite subject = allComposites.get(i); + final long subsetCount = allComposites.subList(i + 1, allComposites.size()) .stream() .filter(x -> subject.isSubsetOf(x) || x.isSubsetOf(subject)) .count(); @@ -112,21 +112,21 @@ private static Set createCompositeComponents(Set freeCompo return constructedComposites; } - private static Set collectVisibleProvisions(Set components, - Set composites) { + private static Set collectVisibleProvisions(final Set components, + final Set composites) { // Collect globally visible provisions - Set provisions = new HashSet<>(); + final Set provisions = new HashSet<>(); // 1. Collect composite provisions composites.stream() .flatMap(x -> x.provisions() .stream()) .forEach(provisions::add); // 2. Collect bare components - Set containedComponents = composites.stream() + final Set containedComponents = composites.stream() .flatMap(x -> x.parts() .stream()) .collect(Collectors.toSet()); - Set bareComponents = components.stream() + final Set bareComponents = components.stream() .filter(x -> !containedComponents.contains(x)) .collect(Collectors.toSet()); // 3. Collect bare component provisions @@ -142,19 +142,23 @@ private static Set collectVisibleProvisions(Set c private Map> createOperationInterfaces() { // TODO: This has to include composite interfaces as well - List>> constructedOperationInterfaces = getComponents().stream() + final List>> constructedOperationInterfaces = this.getComponents() + .stream() .map(x -> x.provisions() .simplified()) .collect(Collectors.toList()); - getComponents().stream() + this.getComponents() + .stream() .map(x -> x.requirements() .simplified()) .forEach(x -> constructedOperationInterfaces.add(x)); - getCompositeComponents().stream() + this.getCompositeComponents() + .stream() .flatMap(x -> x.provisions() .stream()) .forEach(x -> constructedOperationInterfaces.add(x.simplified())); - getCompositeComponents().stream() + this.getCompositeComponents() + .stream() .flatMap(x -> x.requirements() .stream()) .forEach(x -> constructedOperationInterfaces.add(x.simplified())); @@ -162,14 +166,14 @@ private Map> createOperationInterfaces() { } public Set getComponents() { - return components; + return this.components; } public Set getCompositeComponents() { - return composites; + return this.composites; } public Map> getOperationInterfaces() { - return operationInterfaces; + return this.operationInterfaces; } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Provisions.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Provisions.java index 2acafc2f..68f2c430 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Provisions.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Provisions.java @@ -18,43 +18,44 @@ public class Provisions implements Iterable { private final Set provisions; private final Map> groupedProvisions; - public Provisions(Collection provisions, Collection allDependencies) { + public Provisions(final Collection provisions, + final Collection allDependencies) { this.provisions = Collections.unmodifiableSet(new HashSet<>(provisions)); this.groupedProvisions = DependencyUtils.groupDependencies(provisions, allDependencies); } public Set get() { - return provisions; + return this.provisions; } public Map> getGrouped() { - return groupedProvisions; + return this.groupedProvisions; } - public boolean containsPartOf(OperationInterface iface) { - return provisions.stream() + public boolean containsPartOf(final OperationInterface iface) { + return this.provisions.stream() .anyMatch(x -> x.isPartOf(iface)); } - public boolean containsEntire(OperationInterface iface) { - return provisions.stream() + public boolean containsEntire(final OperationInterface iface) { + return this.provisions.stream() .anyMatch(x -> iface.isPartOf(x)); } @Override public Iterator iterator() { - return provisions.iterator(); + return this.provisions.iterator(); } public Map> simplified() { - List>> simplifiedInterfaces = new LinkedList<>(); - for (OperationInterface root : groupedProvisions.keySet()) { - List simplifiedRoot = new ArrayList<>(root.simplified() + final List>> simplifiedInterfaces = new LinkedList<>(); + for (final OperationInterface root : this.groupedProvisions.keySet()) { + final List simplifiedRoot = new ArrayList<>(root.simplified() .values() .stream() .flatMap(x -> x.stream()) .collect(Collectors.toList())); - for (OperationInterface member : groupedProvisions.get(root)) { + for (final OperationInterface member : this.groupedProvisions.get(root)) { simplifiedRoot.addAll(member.simplified() .values() .stream() @@ -70,30 +71,27 @@ public Map> simplified() { @Override public int hashCode() { - return Objects.hash(provisions); + return Objects.hash(this.provisions); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Provisions other = (Provisions) obj; - return Objects.equals(provisions, other.provisions); + final Provisions other = (Provisions) obj; + return Objects.equals(this.provisions, other.provisions); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); - Map> simplified = simplified(); + final StringBuilder builder = new StringBuilder(); + final Map> simplified = this.simplified(); - for (OperationInterface iface : simplified.keySet()) { + for (final OperationInterface iface : simplified.keySet()) { builder.append(iface.getName()); simplified.get(iface) .forEach(x -> builder.append("\n\t") diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java index 9226a231..442e194c 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java @@ -9,39 +9,36 @@ public class ProvisionsBuilder { private final List provisions = new LinkedList<>(); - public void add(OperationInterface... provisions) { + public void add(final OperationInterface... provisions) { this.add(List.of(provisions)); } - public void add(Collection provisions) { + public void add(final Collection provisions) { this.provisions.addAll(provisions); } - public Provisions create(Collection allDependencies) { - return new Provisions(provisions, allDependencies); + public Provisions create(final Collection allDependencies) { + return new Provisions(this.provisions, allDependencies); } public List toList() { - return Collections.unmodifiableList(provisions); + return Collections.unmodifiableList(this.provisions); } @Override public int hashCode() { - return Objects.hash(provisions); + return Objects.hash(this.provisions); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - ProvisionsBuilder other = (ProvisionsBuilder) obj; - return Objects.equals(provisions, other.provisions); + final ProvisionsBuilder other = (ProvisionsBuilder) obj; + return Objects.equals(this.provisions, other.provisions); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RESTName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RESTName.java index c9512641..e89e7ff1 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RESTName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RESTName.java @@ -12,10 +12,11 @@ public class RESTName implements InterfaceName, OperationName { private final List path; private final Optional httpMethod; - public RESTName(String host, String path, Optional httpMethod) throws IllegalArgumentException { + public RESTName(final String host, final String path, final Optional httpMethod) + throws IllegalArgumentException { this.host = host; this.httpMethod = httpMethod; - Optional> parsedPath = parsePath(host + path); + final Optional> parsedPath = this.parsePath(host + path); if (parsedPath.isEmpty()) { throw new IllegalArgumentException("Could not parse path due to illegal format: \"" + path + "\""); } @@ -27,60 +28,60 @@ public RESTName(String host, String path, Optional httpMethod) throw @Override public String getName() { - return getInterface(); + return this.getInterface(); } @Override public String getInterface() { - return toString(); + return this.toString(); } @Override - public Optional forInterface(String baseInterface) { - if (!isPartOf(baseInterface)) { + public Optional forInterface(final String baseInterface) { + if (!this.isPartOf(baseInterface)) { return Optional.empty(); } - return Optional.of(getInterface()); + return Optional.of(this.getInterface()); } @Override public List getInterfaces() { - Stack> prefixes = new Stack<>(); + final Stack> prefixes = new Stack<>(); - if (path.size() > 0) { - prefixes.push(List.of(path.get(0))); - for (int i = 1; i < path.size(); i++) { - List prefix = new ArrayList<>(prefixes.peek()); - prefix.add(path.get(i)); + if (this.path.size() > 0) { + prefixes.push(List.of(this.path.get(0))); + for (int i = 1; i < this.path.size(); i++) { + final List prefix = new ArrayList<>(prefixes.peek()); + prefix.add(this.path.get(i)); prefixes.push(prefix); } } - List interfaces = new ArrayList<>(prefixes.size()); + final List interfaces = new ArrayList<>(prefixes.size()); - if (httpMethod.isPresent()) { - interfaces.add(getInterface()); + if (this.httpMethod.isPresent()) { + interfaces.add(this.getInterface()); } // Insert the prefixes in reverse since the most specific element is at index 0 there. while (!prefixes.empty()) { - interfaces.add(toName(prefixes.pop())); + interfaces.add(this.toName(prefixes.pop())); } // Always add root interface - interfaces.add(toName(List.of())); + interfaces.add(this.toName(List.of())); return interfaces; } @Override - public InterfaceName createInterface(String name) { - return new RESTName(host, name, Optional.empty()); + public InterfaceName createInterface(final String name) { + return new RESTName(this.host, name, Optional.empty()); } - private String toName(List path) { - StringBuilder name = new StringBuilder(); + private String toName(final List path) { + final StringBuilder name = new StringBuilder(); name.append("/"); for (int i = 0; i < path.size(); i++) { name.append(path.get(i)); @@ -88,22 +89,22 @@ private String toName(List path) { name.append("/"); } } - return host + name.toString(); + return this.host + name.toString(); } @Override public String toString() { - String pathString = toName(path); + final String pathString = this.toName(this.path); String methodString = ""; - if (httpMethod.isPresent()) { - methodString = "[" + httpMethod.get() + if (this.httpMethod.isPresent()) { + methodString = "[" + this.httpMethod.get() .toString() + "]"; } return pathString + methodString; } - private Optional> parsePath(String string) { - String[] segments = string.split("/"); + private Optional> parsePath(final String string) { + final String[] segments = string.split("/"); // Require at least a "/" after the host name if (segments.length == 1 && !string.endsWith("/")) { @@ -119,45 +120,38 @@ private Optional> parsePath(String string) { @Override public int hashCode() { - return Objects.hash(host, path, httpMethod); + return Objects.hash(this.host, this.path, this.httpMethod); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - RESTName other = (RESTName) obj; - return Objects.equals(host, other.host) && Objects.equals(path, other.path) - && Objects.equals(httpMethod, other.httpMethod); + final RESTName other = (RESTName) obj; + return Objects.equals(this.host, other.host) && Objects.equals(this.path, other.path) + && Objects.equals(this.httpMethod, other.httpMethod); } @Override - public boolean isPartOf(String iface) { - String[] parts = iface.split("\\["); - Optional> interfacePathOption = parsePath(parts[0]); + public boolean isPartOf(final String iface) { + final String[] parts = iface.split("\\["); + final Optional> interfacePathOption = this.parsePath(parts[0]); if (interfacePathOption.isEmpty()) { return false; } - List interfacePath = interfacePathOption.get(); - String otherHost = interfacePath.remove(0); - - if (!otherHost.equals(host)) { - return false; - } + final List interfacePath = interfacePathOption.get(); + final String otherHost = interfacePath.remove(0); - if (interfacePath.size() > path.size()) { + if (!otherHost.equals(this.host) || (interfacePath.size() > this.path.size())) { return false; } for (int i = 0; i < interfacePath.size(); i++) { - if (!path.get(i) + if (!this.path.get(i) .equals(interfacePath.get(i))) { return false; } @@ -166,14 +160,14 @@ public boolean isPartOf(String iface) { Optional ifaceHttpMethod = Optional.empty(); if (parts.length > 1) { // Assume that a '[' implies a ']'. - int end = parts[1].lastIndexOf(']'); - String httpMethodName = parts[1].substring(0, end); + final int end = parts[1].lastIndexOf(']'); + final String httpMethodName = parts[1].substring(0, end); ifaceHttpMethod = Optional.of(HTTPMethod.valueOf(httpMethodName)); } // TODO: If this.httpMethod.isEmpty(), see it as part of the other interface anyway. // This allows some imprecision from ECMAScript detection - if (interfacePath.size() == path.size() && ifaceHttpMethod.isPresent() && this.httpMethod.isPresent() + if (interfacePath.size() == this.path.size() && ifaceHttpMethod.isPresent() && this.httpMethod.isPresent() && !ifaceHttpMethod.equals(this.httpMethod)) { return false; } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Requirements.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Requirements.java index 708da684..1b1621d4 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Requirements.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Requirements.java @@ -18,56 +18,57 @@ public class Requirements implements Iterable { private final Set requirements; private final Map> groupedRequirements; - public Requirements(Collection requiredInterfaces, - Collection allDependencies, Collection visibleProvisions) { + public Requirements(final Collection requiredInterfaces, + final Collection allDependencies, + final Collection visibleProvisions) { this.requirements = new HashSet<>(); - List sortedProvisions = new ArrayList<>(visibleProvisions); + final List sortedProvisions = new ArrayList<>(visibleProvisions); Collections.sort(sortedProvisions); Collections.reverse(sortedProvisions); - for (OperationInterface requirement : requiredInterfaces) { + for (final OperationInterface requirement : requiredInterfaces) { OperationInterface generalizedRequirement = requirement; - for (OperationInterface provision : sortedProvisions) { + for (final OperationInterface provision : sortedProvisions) { if (requirement.isPartOf(provision)) { generalizedRequirement = provision; break; } } - requirements.add(generalizedRequirement); + this.requirements.add(generalizedRequirement); } - this.groupedRequirements = DependencyUtils.groupDependencies(requirements, allDependencies); + this.groupedRequirements = DependencyUtils.groupDependencies(this.requirements, allDependencies); } public Set get() { - return Collections.unmodifiableSet(requirements); + return Collections.unmodifiableSet(this.requirements); } - public boolean containsPartOf(OperationInterface iface) { - return requirements.stream() + public boolean containsPartOf(final OperationInterface iface) { + return this.requirements.stream() .anyMatch(x -> x.isPartOf(iface)); } - public boolean containsEntire(OperationInterface iface) { - return requirements.stream() + public boolean containsEntire(final OperationInterface iface) { + return this.requirements.stream() .anyMatch(x -> iface.isPartOf(x)); } @Override public Iterator iterator() { - return Collections.unmodifiableCollection(requirements) + return Collections.unmodifiableCollection(this.requirements) .iterator(); } public Map> simplified() { - List>> simplifiedInterfaces = new LinkedList<>(); - for (OperationInterface root : groupedRequirements.keySet()) { - List simplifiedRoot = new ArrayList<>(root.simplified() + final List>> simplifiedInterfaces = new LinkedList<>(); + for (final OperationInterface root : this.groupedRequirements.keySet()) { + final List simplifiedRoot = new ArrayList<>(root.simplified() .values() .stream() .flatMap(x -> x.stream()) .collect(Collectors.toList())); - for (OperationInterface member : groupedRequirements.get(root)) { + for (final OperationInterface member : this.groupedRequirements.get(root)) { simplifiedRoot.addAll(member.simplified() .values() .stream() @@ -83,30 +84,27 @@ public Map> simplified() { @Override public int hashCode() { - return Objects.hash(requirements); + return Objects.hash(this.requirements); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Requirements other = (Requirements) obj; - return Objects.equals(requirements, other.requirements); + final Requirements other = (Requirements) obj; + return Objects.equals(this.requirements, other.requirements); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); - Map> simplified = simplified(); + final StringBuilder builder = new StringBuilder(); + final Map> simplified = this.simplified(); - for (OperationInterface iface : simplified.keySet()) { + for (final OperationInterface iface : simplified.keySet()) { builder.append(iface.getName()); simplified.get(iface) .forEach(x -> builder.append("\n\t") diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RequirementsBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RequirementsBuilder.java index 823e6102..f33f35f6 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RequirementsBuilder.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RequirementsBuilder.java @@ -12,52 +12,49 @@ public class RequirementsBuilder { private final List requirements = new LinkedList<>(); private final Set weakRequirements = new HashSet<>(); - public void add(OperationInterface... interfaces) { + public void add(final OperationInterface... interfaces) { this.add(List.of(interfaces)); } - public void add(Collection interfaces) { - requirements.addAll(interfaces); + public void add(final Collection interfaces) { + this.requirements.addAll(interfaces); } - public void addWeakly(OperationInterface iface) { - weakRequirements.add(iface); + public void addWeakly(final OperationInterface iface) { + this.weakRequirements.add(iface); } - public void strengthenIfPresent(OperationInterface iface) { - if (weakRequirements.contains(iface)) { - weakRequirements.remove(iface); - requirements.add(iface); + public void strengthenIfPresent(final OperationInterface iface) { + if (this.weakRequirements.contains(iface)) { + this.weakRequirements.remove(iface); + this.requirements.add(iface); } } - public Requirements create(Collection allDependencies, - Collection visibleProvisions) { - return new Requirements(requirements, allDependencies, visibleProvisions); + public Requirements create(final Collection allDependencies, + final Collection visibleProvisions) { + return new Requirements(this.requirements, allDependencies, visibleProvisions); } public List toList() { - return Collections.unmodifiableList(requirements); + return Collections.unmodifiableList(this.requirements); } @Override public int hashCode() { - return Objects.hash(requirements, weakRequirements); + return Objects.hash(this.requirements, this.weakRequirements); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - RequirementsBuilder other = (RequirementsBuilder) obj; - return Objects.equals(requirements, other.requirements) - && Objects.equals(weakRequirements, other.weakRequirements); + final RequirementsBuilder other = (RequirementsBuilder) obj; + return Objects.equals(this.requirements, other.requirements) + && Objects.equals(this.weakRequirements, other.weakRequirements); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/DockerParser.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/DockerParser.java index 266a349f..cb03e20f 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/DockerParser.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/DockerParser.java @@ -35,15 +35,15 @@ public class DockerParser { private static final Logger LOG = Logger.getLogger(DockerParser.class); - public DockerParser(Path path, PCMDetector pcmDetector) { + public DockerParser(final Path path, final PCMDetector pcmDetector) { LOG.info("starting docker process"); this.path = path; this.pcmDetector = pcmDetector; - final InputStream input = getDockerFile(); + final InputStream input = this.getDockerFile(); final List services = extractServiceNames(input); - mapping = createServiceComponentMapping(services); + this.mapping = this.createServiceComponentMapping(services); } /** @@ -55,7 +55,7 @@ public DockerParser(Path path, PCMDetector pcmDetector) { private InputStream getDockerFile() { List paths = new ArrayList<>(); - try (Stream files = Files.walk(path)) { + try (Stream files = Files.walk(this.path)) { paths = files.filter(f -> f.getFileName() .toString() .contains(FILE_NAME)) @@ -86,7 +86,7 @@ private InputStream getDockerFile() { * @return the list of all service names found in the docker-compose file */ @SuppressWarnings("unchecked") - private static List extractServiceNames(InputStream stream) { + private static List extractServiceNames(final InputStream stream) { // final Yaml yaml = new Yaml(); final Map object = new HashMap<>(); // (Map) // yaml.load(stream); @@ -107,9 +107,9 @@ private static List extractServiceNames(InputStream stream) { * a list of all service names from a docker-compose file * @return the mapping between service names and Java model instances */ - private Map> createServiceComponentMapping(List serviceNames) { + private Map> createServiceComponentMapping(final List serviceNames) { - final Set components = pcmDetector.getCompilationUnits(); + final Set components = this.pcmDetector.getCompilationUnits(); final Map> serviceToCompMapping = new HashMap<>(); @@ -117,9 +117,9 @@ private Map> createServiceComponentMapping(List files = Files.walk(path)) { + try (Stream files = Files.walk(this.path)) { // TODO try to find a more robust heuristic final List foundPaths = files.filter(f -> f.toString() .contains(((AbstractTypeDeclaration) comp.types() @@ -149,7 +149,7 @@ private Map> createServiceComponentMapping(List> getMapping() { - return mapping; + return this.mapping; } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/MapMerger.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/MapMerger.java index 8153158c..bc4126e8 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/MapMerger.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/MapMerger.java @@ -13,11 +13,11 @@ private MapMerger() { throw new IllegalStateException(); } - public static Map> merge(Collection>> maps) { - Map> mergedMap = new HashMap<>(); + public static Map> merge(final Collection>> maps) { + final Map> mergedMap = new HashMap<>(); - for (Map> map : maps) { - for (Map.Entry> entry : map.entrySet()) { + for (final Map> map : maps) { + for (final Map.Entry> entry : map.entrySet()) { mergedMap.merge(entry.getKey(), entry.getValue(), (a, b) -> Stream.concat(a.stream(), b.stream()) .collect(Collectors.toList())); } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/NameConverter.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/NameConverter.java index ab6540a6..d696533b 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/NameConverter.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/NameConverter.java @@ -7,8 +7,8 @@ private NameConverter() { throw new IllegalStateException(); } - public static String toPCMIdentifier(ITypeBinding name) { - String fullName = name.getQualifiedName() + public static String toPCMIdentifier(final ITypeBinding name) { + final String fullName = name.getQualifiedName() .replace(".", "_"); // Erase type parameters in identifiers // TODO is this the right solution? diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMDetector.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMDetector.java index 6d6f8f3f..dd972466 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMDetector.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMDetector.java @@ -41,31 +41,31 @@ public class PCMDetector { private static final Logger LOG = Logger.getLogger(PCMDetector.class); - private Map components = new HashMap<>(); - private Map composites = new HashMap<>(); - private ProvisionsBuilder compositeProvisions = new ProvisionsBuilder(); - private RequirementsBuilder compositeRequirements = new RequirementsBuilder(); - private Set providedInterfaces = new HashSet<>(); + private final Map components = new HashMap<>(); + private final Map composites = new HashMap<>(); + private final ProvisionsBuilder compositeProvisions = new ProvisionsBuilder(); + private final RequirementsBuilder compositeRequirements = new RequirementsBuilder(); + private final Set providedInterfaces = new HashSet<>(); - private static String getFullUnitName(CompUnitOrName unit) { + private static String getFullUnitName(final CompUnitOrName unit) { // TODO this is potentially problematic, maybe restructure // On the other hand, it is still fit as a unique identifier, // since types cannot be declared multiple times. - List names = getFullUnitNames(unit); + final List names = getFullUnitNames(unit); if (!names.isEmpty()) { return names.get(0); } return null; } - private static List getFullUnitNames(CompUnitOrName unit) { + private static List getFullUnitNames(final CompUnitOrName unit) { if (!unit.isUnit()) { return List.of(unit.name()); } - List names = new ArrayList<>(); - for (Object type : unit.compilationUnit() + final List names = new ArrayList<>(); + for (final Object type : unit.compilationUnit() .get() .types()) { if (type instanceof AbstractTypeDeclaration) { @@ -76,135 +76,139 @@ private static List getFullUnitNames(CompUnitOrName unit) { return names; } - private static String getFullTypeName(AbstractTypeDeclaration type) { + private static String getFullTypeName(final AbstractTypeDeclaration type) { return type.getName() .getFullyQualifiedName(); } - public void detectComponent(CompUnitOrName unit) { + public void detectComponent(final CompUnitOrName unit) { if (!unit.isUnit()) { - components.put(unit, new ComponentBuilder(unit)); + this.components.put(unit, new ComponentBuilder(unit)); return; } - for (Object type : unit.compilationUnit() + for (final Object type : unit.compilationUnit() .get() .types()) { if (type instanceof TypeDeclaration) { - components.put(unit, new ComponentBuilder(unit)); - ITypeBinding binding = ((TypeDeclaration) type).resolveBinding(); - detectProvidedInterface(unit, binding); + this.components.put(unit, new ComponentBuilder(unit)); + final ITypeBinding binding = ((TypeDeclaration) type).resolveBinding(); + this.detectProvidedInterface(unit, binding); } } } - public void detectRequiredInterface(CompUnitOrName unit, InterfaceName interfaceName) { - detectRequiredInterface(unit, interfaceName, false); + public void detectRequiredInterface(final CompUnitOrName unit, final InterfaceName interfaceName) { + this.detectRequiredInterface(unit, interfaceName, false); } - public void detectRequiredInterface(CompUnitOrName unit, InterfaceName interfaceName, boolean compositeRequired) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); + public void detectRequiredInterface(final CompUnitOrName unit, final InterfaceName interfaceName, + final boolean compositeRequired) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); } - EntireInterface iface = new EntireInterface(interfaceName); - detectRequiredInterface(unit, compositeRequired, false, iface); + final EntireInterface iface = new EntireInterface(interfaceName); + this.detectRequiredInterface(unit, compositeRequired, false, iface); } - public void detectRequiredInterface(CompUnitOrName unit, FieldDeclaration field) { - detectRequiredInterface(unit, field, false, false); + public void detectRequiredInterface(final CompUnitOrName unit, final FieldDeclaration field) { + this.detectRequiredInterface(unit, field, false, false); } - public void detectRequiredInterfaceWeakly(CompUnitOrName unit, FieldDeclaration field) { - detectRequiredInterface(unit, field, false, true); + public void detectRequiredInterfaceWeakly(final CompUnitOrName unit, final FieldDeclaration field) { + this.detectRequiredInterface(unit, field, false, true); } - private void detectRequiredInterface(CompUnitOrName unit, FieldDeclaration field, boolean compositeRequired, - boolean detectWeakly) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); + private void detectRequiredInterface(final CompUnitOrName unit, final FieldDeclaration field, + final boolean compositeRequired, final boolean detectWeakly) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); } @SuppressWarnings("unchecked") - List ifaces = ((List) field.fragments()).stream() + final List ifaces = ((List) field.fragments()).stream() .map(x -> x.resolveBinding()) .filter(x -> x != null) .map(x -> x.getType()) .map(x -> new EntireInterface(x, new JavaInterfaceName(NameConverter.toPCMIdentifier(x)))) .collect(Collectors.toList()); - detectRequiredInterface(unit, compositeRequired, detectWeakly, ifaces); + this.detectRequiredInterface(unit, compositeRequired, detectWeakly, ifaces); } - public void detectRequiredInterface(CompUnitOrName unit, SingleVariableDeclaration parameter) { - detectRequiredInterface(unit, parameter, false); + public void detectRequiredInterface(final CompUnitOrName unit, final SingleVariableDeclaration parameter) { + this.detectRequiredInterface(unit, parameter, false); } - private void detectRequiredInterface(CompUnitOrName unit, SingleVariableDeclaration parameter, - boolean compositeRequired) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); + private void detectRequiredInterface(final CompUnitOrName unit, final SingleVariableDeclaration parameter, + final boolean compositeRequired) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); } - IVariableBinding parameterBinding = parameter.resolveBinding(); + final IVariableBinding parameterBinding = parameter.resolveBinding(); if (parameterBinding == null) { LOG.warn("Unresolved parameter binding " + parameter.getName() + " detected in " + getFullUnitName(unit) + "!"); return; } - ITypeBinding type = parameterBinding.getType(); - EntireInterface iface = new EntireInterface(type, new JavaInterfaceName(NameConverter.toPCMIdentifier(type))); - detectRequiredInterface(unit, compositeRequired, false, iface); + final ITypeBinding type = parameterBinding.getType(); + final EntireInterface iface = new EntireInterface(type, + new JavaInterfaceName(NameConverter.toPCMIdentifier(type))); + this.detectRequiredInterface(unit, compositeRequired, false, iface); } - private void detectRequiredInterface(CompUnitOrName unit, boolean compositeRequired, boolean detectWeakly, - OperationInterface iface) { - detectRequiredInterface(unit, compositeRequired, detectWeakly, List.of(iface)); + private void detectRequiredInterface(final CompUnitOrName unit, final boolean compositeRequired, + final boolean detectWeakly, final OperationInterface iface) { + this.detectRequiredInterface(unit, compositeRequired, detectWeakly, List.of(iface)); } - private void detectRequiredInterface(CompUnitOrName unit, boolean compositeRequired, boolean detectWeakly, - Collection ifaces) { - for (OperationInterface iface : ifaces) { - if (detectWeakly && !providedInterfaces.contains(iface)) { - components.get(unit) + private void detectRequiredInterface(final CompUnitOrName unit, final boolean compositeRequired, + final boolean detectWeakly, final Collection ifaces) { + for (final OperationInterface iface : ifaces) { + if (detectWeakly && !this.providedInterfaces.contains(iface)) { + this.components.get(unit) .requirements() .addWeakly(iface); if (compositeRequired) { - compositeRequirements.addWeakly(iface); + this.compositeRequirements.addWeakly(iface); } } else { - components.get(unit) + this.components.get(unit) .requirements() .add(iface); if (compositeRequired) { - compositeRequirements.add(iface); + this.compositeRequirements.add(iface); } } } } - public void detectProvidedInterface(CompUnitOrName unit, ITypeBinding iface) { + public void detectProvidedInterface(final CompUnitOrName unit, final ITypeBinding iface) { if (iface == null) { LOG.warn("Unresolved type binding detected in " + getFullUnitName(unit) + "!"); return; } - OperationInterface provision = new EntireInterface(iface, + final OperationInterface provision = new EntireInterface(iface, new JavaInterfaceName(NameConverter.toPCMIdentifier(iface))); - detectProvidedInterface(unit, provision); + this.detectProvidedInterface(unit, provision); } - public void detectProvidedOperation(CompUnitOrName unit, IMethodBinding method) { + public void detectProvidedOperation(final CompUnitOrName unit, final IMethodBinding method) { if (method == null) { LOG.warn("Unresolved method binding detected in " + getFullUnitName(unit) + "!"); return; } - detectProvidedOperation(unit, method.getDeclaringClass(), method); + this.detectProvidedOperation(unit, method.getDeclaringClass(), method); } - public void detectProvidedOperation(CompUnitOrName unit, ITypeBinding declaringIface, IMethodBinding method) { + public void detectProvidedOperation(final CompUnitOrName unit, final ITypeBinding declaringIface, + final IMethodBinding method) { if (declaringIface == null) { LOG.warn("Unresolved type binding detected in " + getFullUnitName(unit) + "!"); return; } - detectProvidedOperation(unit, NameConverter.toPCMIdentifier(declaringIface), method); + this.detectProvidedOperation(unit, NameConverter.toPCMIdentifier(declaringIface), method); } - public void detectProvidedOperation(CompUnitOrName unit, String declaringIface, IMethodBinding method) { + public void detectProvidedOperation(final CompUnitOrName unit, final String declaringIface, + final IMethodBinding method) { String operationName; if (method == null) { LOG.warn("Unresolved method binding detected in " + getFullUnitName(unit) + "!"); @@ -213,86 +217,91 @@ public void detectProvidedOperation(CompUnitOrName unit, String declaringIface, operationName = method.getName(); } - detectProvidedOperation(unit, method, new JavaOperationName(declaringIface, operationName)); + this.detectProvidedOperation(unit, method, new JavaOperationName(declaringIface, operationName)); } - public void detectProvidedOperation(CompUnitOrName unit, IMethodBinding method, OperationName name) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); + public void detectProvidedOperation(final CompUnitOrName unit, final IMethodBinding method, + final OperationName name) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); } - OperationInterface provision = new Operation(method, name); - detectProvidedInterface(unit, provision); + final OperationInterface provision = new Operation(method, name); + this.detectProvidedInterface(unit, provision); } - public void detectProvidedInterface(CompUnitOrName unit, OperationInterface provision) { - components.get(unit) + public void detectProvidedInterface(final CompUnitOrName unit, final OperationInterface provision) { + this.components.get(unit) .provisions() .add(provision); - providedInterfaces.add(provision); - components.values() + this.providedInterfaces.add(provision); + this.components.values() .stream() .forEach(component -> component.requirements() .strengthenIfPresent(provision)); } - public void detectPartOfComposite(CompUnitOrName unit, String compositeName) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); + public void detectPartOfComposite(final CompUnitOrName unit, final String compositeName) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); } - getComposite(compositeName).addPart(components.get(unit)); + this.getComposite(compositeName) + .addPart(this.components.get(unit)); } - public void detectCompositeRequiredInterface(CompUnitOrName unit, InterfaceName interfaceName) { - detectRequiredInterface(unit, interfaceName, true); + public void detectCompositeRequiredInterface(final CompUnitOrName unit, final InterfaceName interfaceName) { + this.detectRequiredInterface(unit, interfaceName, true); } - public void detectCompositeRequiredInterface(CompUnitOrName unit, FieldDeclaration field) { - detectRequiredInterface(unit, field, true, false); + public void detectCompositeRequiredInterface(final CompUnitOrName unit, final FieldDeclaration field) { + this.detectRequiredInterface(unit, field, true, false); } - public void detectCompositeRequiredInterface(CompUnitOrName unit, SingleVariableDeclaration parameter) { - detectRequiredInterface(unit, parameter, true); + public void detectCompositeRequiredInterface(final CompUnitOrName unit, final SingleVariableDeclaration parameter) { + this.detectRequiredInterface(unit, parameter, true); } - public void detectCompositeProvidedOperation(CompUnitOrName unit, IMethodBinding method) { - detectCompositeProvidedOperation(unit, method.getDeclaringClass(), method); + public void detectCompositeProvidedOperation(final CompUnitOrName unit, final IMethodBinding method) { + this.detectCompositeProvidedOperation(unit, method.getDeclaringClass(), method); } - public void detectCompositeProvidedOperation(CompUnitOrName unit, ITypeBinding declaringIface, - IMethodBinding method) { - detectCompositeProvidedOperation(unit, NameConverter.toPCMIdentifier(declaringIface), method); + public void detectCompositeProvidedOperation(final CompUnitOrName unit, final ITypeBinding declaringIface, + final IMethodBinding method) { + this.detectCompositeProvidedOperation(unit, NameConverter.toPCMIdentifier(declaringIface), method); } - public void detectCompositeProvidedOperation(CompUnitOrName unit, String declaringIface, IMethodBinding method) { - compositeProvisions.add(new Operation(method, new JavaOperationName(declaringIface, method.getName()))); - detectProvidedOperation(unit, declaringIface, method); + public void detectCompositeProvidedOperation(final CompUnitOrName unit, final String declaringIface, + final IMethodBinding method) { + this.compositeProvisions.add(new Operation(method, new JavaOperationName(declaringIface, method.getName()))); + this.detectProvidedOperation(unit, declaringIface, method); } - public void detectCompositeProvidedOperation(CompUnitOrName unit, IMethodBinding method, OperationName name) { - compositeProvisions.add(new Operation(method, name)); - detectProvidedOperation(unit, method, name); + public void detectCompositeProvidedOperation(final CompUnitOrName unit, final IMethodBinding method, + final OperationName name) { + this.compositeProvisions.add(new Operation(method, name)); + this.detectProvidedOperation(unit, method, name); } - private CompositeBuilder getComposite(String name) { - if (!composites.containsKey(name)) { - composites.put(name, new CompositeBuilder(name)); + private CompositeBuilder getComposite(final String name) { + if (!this.composites.containsKey(name)) { + this.composites.put(name, new CompositeBuilder(name)); } - return composites.get(name); + return this.composites.get(name); } public Set getCompilationUnits() { - return components.keySet(); + return this.components.keySet(); } public PCMDetectionResult getResult() { - return new PCMDetectionResult(components, composites, compositeProvisions, compositeRequirements); + return new PCMDetectionResult(this.components, this.composites, this.compositeProvisions, + this.compositeRequirements); } @Override public String toString() { - StringBuilder sb = new StringBuilder(142); + final StringBuilder sb = new StringBuilder(142); sb.append("[PCMDetector] {\n\tcomponents: {\n"); - components.entrySet() + this.components.entrySet() .forEach(entry -> { sb.append("\t\t\""); sb.append(entry.getKey()); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMInstanceCreator.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMInstanceCreator.java index 070ad3b6..d5210c02 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMInstanceCreator.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMInstanceCreator.java @@ -56,15 +56,15 @@ public class PCMInstanceCreator { private final Map compositeCreators; private final Map pcmInterfaces; - public PCMInstanceCreator(RetrieverBlackboard blackboard) { - existingDataTypesMap = new HashMap<>(); - existingCollectionDataTypes = new HashMap<>(); + public PCMInstanceCreator(final RetrieverBlackboard blackboard) { + this.existingDataTypesMap = new HashMap<>(); + this.existingCollectionDataTypes = new HashMap<>(); this.componentCompositeCreators = new HashMap<>(); this.ifaceCompositeCreators = new HashMap<>(); this.compositeCreators = new HashMap<>(); this.pcmInterfaces = new HashMap<>(); - create = new FluentRepositoryFactory(); - repository = create.newRepository() + this.create = new FluentRepositoryFactory(); + this.repository = this.create.newRepository() .withName(REPO_NAME); this.blackboard = blackboard; } @@ -73,23 +73,23 @@ private class Pair { private final T1 t1; private final T2 t2; - public Pair(T1 t1, T2 t2) { + public Pair(final T1 t1, final T2 t2) { this.t1 = t1; this.t2 = t2; } public T1 getT1() { - return t1; + return this.t1; } public T2 getT2() { - return t2; + return this.t2; } } - private void put(Map> map, K key, V value) { + private void put(final Map> map, final K key, final V value) { if (!map.containsKey(key)) { - map.put(key, new ArrayList()); + map.put(key, new ArrayList<>()); } map.get(key) .add(value); @@ -102,27 +102,27 @@ private void put(Map> map, K key, V value) { * a mapping between microservice names and java model instances * @return the PCM repository model */ - public Repository createPCM(Map> mapping) { - PCMDetectionResult detectionResult = blackboard.getPCMDetector() + public Repository createPCM(final Map> mapping) { + final PCMDetectionResult detectionResult = this.blackboard.getPCMDetector() .getResult(); final Set components = detectionResult.getComponents(); final Map> interfaces = detectionResult.getOperationInterfaces(); final Set composites = detectionResult.getCompositeComponents(); - createPCMInterfaces(interfaces); + this.createPCMInterfaces(interfaces); - for (Composite composite : composites) { - CompositeComponentCreator c = create.newCompositeComponent() + for (final Composite composite : composites) { + final CompositeComponentCreator c = this.create.newCompositeComponent() .withName(composite.name()); composite.parts() - .forEach(x -> componentCompositeCreators.put(x, c)); + .forEach(x -> this.componentCompositeCreators.put(x, c)); composite.internalInterfaces() - .forEach(x -> ifaceCompositeCreators.put(x.getInterface(), c)); - compositeCreators.put(composite, c); + .forEach(x -> this.ifaceCompositeCreators.put(x.getInterface(), c)); + this.compositeCreators.put(composite, c); - Set distinctInterfaces = new HashSet<>(); - for (OperationInterface compRequirement : composite.requirements()) { - org.palladiosimulator.pcm.repository.OperationInterface requiredInterface = pcmInterfaces + final Set distinctInterfaces = new HashSet<>(); + for (final OperationInterface compRequirement : composite.requirements()) { + final org.palladiosimulator.pcm.repository.OperationInterface requiredInterface = this.pcmInterfaces .get(compRequirement); if (distinctInterfaces.contains(requiredInterface)) { continue; @@ -132,8 +132,8 @@ public Repository createPCM(Map> mapping) { } distinctInterfaces.clear(); - for (OperationInterface compProvision : composite.provisions()) { - org.palladiosimulator.pcm.repository.OperationInterface providedInterface = pcmInterfaces + for (final OperationInterface compProvision : composite.provisions()) { + final org.palladiosimulator.pcm.repository.OperationInterface providedInterface = this.pcmInterfaces .get(compProvision); if (distinctInterfaces.contains(providedInterface)) { continue; @@ -143,15 +143,15 @@ public Repository createPCM(Map> mapping) { } } - createPCMComponents(components); + this.createPCMComponents(components); // Add assemblyConnections to composite component. - for (Composite composite : composites) { - CompositeComponentCreator c = compositeCreators.get(composite); - CompositeComponent builtComp = (CompositeComponent) c.build(); + for (final Composite composite : composites) { + final CompositeComponentCreator c = this.compositeCreators.get(composite); + final CompositeComponent builtComp = (CompositeComponent) c.build(); - Map>> innerRequirements = new HashMap<>(); - Map>> innerProvisions = new HashMap<>(); + final Map>> innerRequirements = new HashMap<>(); + final Map>> innerProvisions = new HashMap<>(); // Find requiredRoles builtComp.getAssemblyContexts__ComposedStructure() @@ -160,8 +160,8 @@ public Repository createPCM(Map> mapping) { .getRequiredRoles_InterfaceRequiringEntity() .stream() .map(OperationRequiredRole.class::cast) - .forEach(y -> put(innerRequirements, y.getRequiredInterface__OperationRequiredRole() - .getEntityName(), new Pair(y, x)))); + .forEach(y -> this.put(innerRequirements, y.getRequiredInterface__OperationRequiredRole() + .getEntityName(), new Pair<>(y, x)))); // Find providedRoles builtComp.getAssemblyContexts__ComposedStructure() @@ -170,15 +170,15 @@ public Repository createPCM(Map> mapping) { .getProvidedRoles_InterfaceProvidingEntity() .stream() .map(OperationProvidedRole.class::cast) - .forEach(y -> put(innerProvisions, y.getProvidedInterface__OperationProvidedRole() - .getEntityName(), new Pair(y, x)))); + .forEach(y -> this.put(innerProvisions, y.getProvidedInterface__OperationProvidedRole() + .getEntityName(), new Pair<>(y, x)))); // Match them up - for (OperationInterface internalInterface : composite.internalInterfaces()) { - String ifaceName = internalInterface.getInterface(); - for (Pair r : innerRequirements.getOrDefault(ifaceName, + for (final OperationInterface internalInterface : composite.internalInterfaces()) { + final String ifaceName = internalInterface.getInterface(); + for (final Pair r : innerRequirements.getOrDefault(ifaceName, List.of())) { - for (Pair p : innerProvisions.getOrDefault(ifaceName, + for (final Pair p : innerProvisions.getOrDefault(ifaceName, List.of())) { if (!r.getT2() .equals(p.getT2())) { @@ -188,57 +188,57 @@ public Repository createPCM(Map> mapping) { } } - Map outerRequirements = new HashMap<>(); + final Map outerRequirements = new HashMap<>(); builtComp.getRequiredRoles_InterfaceRequiringEntity() .stream() .map(OperationRequiredRole.class::cast) .forEach(x -> outerRequirements.put(x.getRequiredInterface__OperationRequiredRole() .getEntityName(), x)); - for (OperationInterface requiredInterface : composite.requirements()) { - String requiredInterfaceName = requiredInterface.getName() + for (final OperationInterface requiredInterface : composite.requirements()) { + final String requiredInterfaceName = requiredInterface.getName() .toString() .replace(".", "_"); - for (Pair r : innerRequirements + for (final Pair r : innerRequirements .getOrDefault(requiredInterfaceName, List.of())) { c.withRequiredDelegationConnection(r.getT2(), r.getT1(), outerRequirements.get(requiredInterfaceName)); } } - Map outerProvisions = new HashMap<>(); + final Map outerProvisions = new HashMap<>(); builtComp.getProvidedRoles_InterfaceProvidingEntity() .stream() .map(OperationProvidedRole.class::cast) .forEach(x -> outerProvisions.put(x.getProvidedInterface__OperationProvidedRole() .getEntityName(), x)); - for (OperationInterface providedInterface : composite.provisions()) { - String providedInterfaceName = providedInterface.getName() + for (final OperationInterface providedInterface : composite.provisions()) { + final String providedInterfaceName = providedInterface.getName() .toString() .replace(".", "_"); - for (Pair r : innerProvisions + for (final Pair r : innerProvisions .getOrDefault(providedInterfaceName, List.of())) { c.withProvidedDelegationConnection(r.getT2(), r.getT1(), outerProvisions.get(providedInterfaceName)); } } - repository.addToRepository(c); + this.repository.addToRepository(c); } - return repository.createRepositoryNow(); + return this.repository.createRepositoryNow(); } - private void createPCMInterfaces(Map> interfaces) { - Map signatureNameCount = new HashMap<>(); + private void createPCMInterfaces(final Map> interfaces) { + final Map signatureNameCount = new HashMap<>(); interfaces.forEach((inter, operations) -> { - String interName = inter.getName() + final String interName = inter.getName() .toString(); LOG.info("Current PCM Interface: " + interName); - String pcmInterfaceName = interName.replace(".", "_"); - OperationInterfaceCreator pcmInterface = create.newOperationInterface() + final String pcmInterfaceName = interName.replace(".", "_"); + final OperationInterfaceCreator pcmInterface = this.create.newOperationInterface() .withName(pcmInterfaceName); for (final Operation operation : operations) { @@ -246,48 +246,48 @@ private void createPCMInterfaces(Map> interf .forInterface(interName) .orElseThrow(); name = name.replace(".", "_"); - Integer oldCount = signatureNameCount.getOrDefault(name, 0); + final Integer oldCount = signatureNameCount.getOrDefault(name, 0); signatureNameCount.put(name, oldCount + 1); // Omit suffix for first occurrence. if (oldCount > 0) { name = name + "$" + signatureNameCount.get(name); } - OperationSignatureCreator signature = create.newOperationSignature() + OperationSignatureCreator signature = this.create.newOperationSignature() .withName(name); - IMethodBinding method = operation.getBinding(); + final IMethodBinding method = operation.getBinding(); if (method != null) { // parameter type for (final ITypeBinding parameter : method.getParameterTypes()) { - signature = handleSignatureDataType(signature, parameter.getName(), parameter, + signature = this.handleSignatureDataType(signature, parameter.getName(), parameter, parameter.getDimensions(), false); } // Return type: Cast Method Return Type to Variable // OrdinaryParameterImpl is sufficient since return types cannot be varargs. - ITypeBinding returned = method.getReturnType(); - signature = handleSignatureDataType(signature, "", returned, returned.getDimensions(), true); + final ITypeBinding returned = method.getReturnType(); + signature = this.handleSignatureDataType(signature, "", returned, returned.getDimensions(), true); } pcmInterface.withOperationSignature(signature); - Optional astNode = getDeclaration(method); - if (astNode.isPresent() && blackboard.getSeffAssociation(astNode.get()) == null) { - ResourceDemandingSEFF seff = create.newSeff() - .onSignature(create.fetchOfSignature(name)) + final Optional astNode = this.getDeclaration(method); + if (astNode.isPresent() && this.blackboard.getSeffAssociation(astNode.get()) == null) { + final ResourceDemandingSEFF seff = this.create.newSeff() + .onSignature(this.create.fetchOfSignature(name)) .buildRDSeff(); - blackboard.putSeffAssociation(astNode.get(), seff); + this.blackboard.putSeffAssociation(astNode.get(), seff); } } - repository.addToRepository(pcmInterface); - pcmInterfaces.put(inter, create.fetchOfOperationInterface(pcmInterfaceName)); + this.repository.addToRepository(pcmInterface); + this.pcmInterfaces.put(inter, this.create.fetchOfOperationInterface(pcmInterfaceName)); }); } - private Optional getDeclaration(IMethodBinding binding) { - return blackboard.getDiscoveredFiles(JAVA_DISCOVERER_ID, CompilationUnit.class) + private Optional getDeclaration(final IMethodBinding binding) { + return this.blackboard.getDiscoveredFiles(JAVA_DISCOVERER_ID, CompilationUnit.class) .values() .stream() .map(unit -> unit.findDeclaringNode(binding)) @@ -295,16 +295,16 @@ private Optional getDeclaration(IMethodBinding binding) { .findAny(); } - private void createPCMComponents(Set components) { + private void createPCMComponents(final Set components) { for (final Component comp : components) { - BasicComponentCreator pcmComp = create.newBasicComponent() + final BasicComponentCreator pcmComp = this.create.newBasicComponent() .withName(wrapName(comp.name())); - Set distinctInterfaces = new HashSet<>(); - for (OperationInterface provision : comp.provisions() + final Set distinctInterfaces = new HashSet<>(); + for (final OperationInterface provision : comp.provisions() .getGrouped() .keySet()) { - org.palladiosimulator.pcm.repository.OperationInterface providedInterface = pcmInterfaces + final org.palladiosimulator.pcm.repository.OperationInterface providedInterface = this.pcmInterfaces .get(provision); if (distinctInterfaces.contains(providedInterface)) { continue; @@ -319,16 +319,17 @@ private void createPCMComponents(Set components) { .stream() .flatMap(List::stream) .forEach(operation -> { - IMethodBinding method = operation.getBinding(); - Optional declaration = getDeclaration(method); + final IMethodBinding method = operation.getBinding(); + final Optional declaration = this.getDeclaration(method); if (declaration.isPresent()) { - pcmComp.withServiceEffectSpecification(blackboard.getSeffAssociation(declaration.get())); + pcmComp.withServiceEffectSpecification(this.blackboard.getSeffAssociation(declaration.get())); } }); distinctInterfaces.clear(); - for (OperationInterface requirement : comp.requirements()) { - org.palladiosimulator.pcm.repository.OperationInterface requiredInterface = fetchInterface(requirement); + for (final OperationInterface requirement : comp.requirements()) { + final org.palladiosimulator.pcm.repository.OperationInterface requiredInterface = this + .fetchInterface(requirement); if (distinctInterfaces.contains(requiredInterface)) { continue; } @@ -337,37 +338,37 @@ private void createPCMComponents(Set components) { .toString()); } - BasicComponent builtComp = pcmComp.build(); + final BasicComponent builtComp = pcmComp.build(); // Add component to its composite, if it is part of one. - CompositeComponentCreator c = componentCompositeCreators.get(comp); + final CompositeComponentCreator c = this.componentCompositeCreators.get(comp); if (c != null) { c.withAssemblyContext(builtComp); } if (!comp.compilationUnit() .isEmpty()) { - blackboard.putRepositoryComponentLocation(builtComp, comp.compilationUnit() + this.blackboard.putRepositoryComponentLocation(builtComp, comp.compilationUnit() .get()); } - repository.addToRepository(builtComp); + this.repository.addToRepository(builtComp); } } - private org.palladiosimulator.pcm.repository.OperationInterface fetchInterface(OperationInterface iface) { - if (pcmInterfaces.containsKey(iface)) { - return pcmInterfaces.get(iface); + private org.palladiosimulator.pcm.repository.OperationInterface fetchInterface(final OperationInterface iface) { + if (this.pcmInterfaces.containsKey(iface)) { + return this.pcmInterfaces.get(iface); } - for (OperationInterface registeredInterface : pcmInterfaces.keySet()) { + for (final OperationInterface registeredInterface : this.pcmInterfaces.keySet()) { if (iface.isPartOf(registeredInterface)) { - return pcmInterfaces.get(registeredInterface); + return this.pcmInterfaces.get(registeredInterface); } } throw new IllegalArgumentException(); } - private static Primitive convertPrimitive(ITypeBinding primT) { + private static Primitive convertPrimitive(final ITypeBinding primT) { switch (primT.getQualifiedName()) { case "boolean": return Primitive.BOOLEAN; @@ -392,11 +393,11 @@ private static Primitive convertPrimitive(ITypeBinding primT) { } } - private OperationSignatureCreator handleSignatureDataType(OperationSignatureCreator signature, String varName, - ITypeBinding variable, int varDimensions, boolean asReturnType) { + private OperationSignatureCreator handleSignatureDataType(final OperationSignatureCreator signature, + final String varName, final ITypeBinding variable, final int varDimensions, final boolean asReturnType) { // Parameter is a collection (extends Collection, is an array or a vararg) - DataType collectionType = handleCollectionType(variable, varDimensions); + final DataType collectionType = this.handleCollectionType(variable, varDimensions); if (collectionType != null) { if (asReturnType) { return signature.withReturnType(collectionType); @@ -405,7 +406,7 @@ private OperationSignatureCreator handleSignatureDataType(OperationSignatureCrea } // Check if type is a primitive type - Primitive prim = handlePrimitive(variable); + final Primitive prim = handlePrimitive(variable); if (prim != null) { if (asReturnType) { return signature.withReturnType(prim); @@ -415,15 +416,15 @@ private OperationSignatureCreator handleSignatureDataType(OperationSignatureCrea // Check if type is void (not part of pcm primitives) if ("void".equals(variable.getQualifiedName()) && asReturnType) { - if (!create.containsDataType("Void")) { - repository.addToRepository(create.newCompositeDataType() + if (!this.create.containsDataType("Void")) { + this.repository.addToRepository(this.create.newCompositeDataType() .withName("Void")); } - return signature.withReturnType(create.fetchOfDataType("Void")); + return signature.withReturnType(this.create.fetchOfDataType("Void")); } // Parameter is Composite Type - DataType compositeType = handleCompositeType(variable); + final DataType compositeType = this.handleCompositeType(variable); if (compositeType != null) { if (asReturnType) { return signature.withReturnType(compositeType); @@ -434,7 +435,7 @@ private OperationSignatureCreator handleSignatureDataType(OperationSignatureCrea return null; } - private DataType handleCollectionType(ITypeBinding ref, int dimensions) { + private DataType handleCollectionType(final ITypeBinding ref, final int dimensions) { // Base for the name of the collection data type String typeName = wrapName(ref); @@ -447,51 +448,51 @@ private DataType handleCollectionType(ITypeBinding ref, int dimensions) { } collectionTypeName = typeName; - if (existingCollectionDataTypes.containsKey(collectionTypeName)) { - return existingCollectionDataTypes.get(collectionTypeName); + if (this.existingCollectionDataTypes.containsKey(collectionTypeName)) { + return this.existingCollectionDataTypes.get(collectionTypeName); } - collectionType = createCollectionWithTypeArg(collectionTypeName, ref, dimensions - 1); + collectionType = this.createCollectionWithTypeArg(collectionTypeName, ref, dimensions - 1); } else if (isCollectionType(ref) && (ref.getTypeArguments().length > 0)) { // TODO: I do not think this works properly for deeper collection types (e.g. // List[]), especially the naming. typeName = wrapName(ref); - ITypeBinding typeArg = ref.getTypeArguments()[0]; - String argumentTypeName = wrapName(typeArg); + final ITypeBinding typeArg = ref.getTypeArguments()[0]; + final String argumentTypeName = wrapName(typeArg); collectionTypeName = typeName + "<" + argumentTypeName + ">"; LOG.info("Current Argument type name: " + argumentTypeName); - if (existingCollectionDataTypes.containsKey(collectionTypeName)) { - return existingCollectionDataTypes.get(collectionTypeName); + if (this.existingCollectionDataTypes.containsKey(collectionTypeName)) { + return this.existingCollectionDataTypes.get(collectionTypeName); } - collectionType = createCollectionWithTypeArg(collectionTypeName, typeArg, typeArg.getDimensions()); + collectionType = this.createCollectionWithTypeArg(collectionTypeName, typeArg, typeArg.getDimensions()); } if (collectionType != null) { - existingCollectionDataTypes.put(collectionTypeName, collectionType); - repository.addToRepository(collectionType); + this.existingCollectionDataTypes.put(collectionTypeName, collectionType); + this.repository.addToRepository(collectionType); } return collectionType; } - private CollectionDataType createCollectionWithTypeArg(String collectionTypeName, ITypeBinding typeArg, - int typeArgDimensions) { + private CollectionDataType createCollectionWithTypeArg(final String collectionTypeName, final ITypeBinding typeArg, + final int typeArgDimensions) { // Type argument is primitive - Primitive primitiveArg = handlePrimitive(typeArg); + final Primitive primitiveArg = handlePrimitive(typeArg); if (primitiveArg != null) { - return create.newCollectionDataType(collectionTypeName, primitiveArg); + return this.create.newCollectionDataType(collectionTypeName, primitiveArg); } // Type argument is a collection again // A type argument cannot be a vararg, therefore it is "ordinary" - DataType collectionArg = handleCollectionType(typeArg, typeArgDimensions); + final DataType collectionArg = this.handleCollectionType(typeArg, typeArgDimensions); if (collectionArg != null) { return FluentRepositoryFactory.newCollectionDataType(collectionTypeName, collectionArg); } // Type argument is a composite data type - DataType compositeArg = handleCompositeType(typeArg); + final DataType compositeArg = this.handleCompositeType(typeArg); if (compositeArg != null) { return FluentRepositoryFactory.newCollectionDataType(collectionTypeName, compositeArg); } @@ -499,9 +500,9 @@ private CollectionDataType createCollectionWithTypeArg(String collectionTypeName return null; } - private static boolean isCollectionType(ITypeBinding varClassifier) { + private static boolean isCollectionType(final ITypeBinding varClassifier) { - List refs = new ArrayList<>(); + final List refs = new ArrayList<>(); if (varClassifier.isClass()) { refs.addAll(List.of(varClassifier.getInterfaces())); @@ -512,7 +513,7 @@ private static boolean isCollectionType(ITypeBinding varClassifier) { refs.addAll(List.of(varClassifier.getInterfaces())); } - for (ITypeBinding ref : refs) { + for (final ITypeBinding ref : refs) { if ("java.util.Collection".equals(ref.getQualifiedName())) { return true; } @@ -521,7 +522,7 @@ private static boolean isCollectionType(ITypeBinding varClassifier) { return false; } - private static Primitive handlePrimitive(ITypeBinding variable) { + private static Primitive handlePrimitive(final ITypeBinding variable) { if (variable.isPrimitive()) { return convertPrimitive(variable); } @@ -532,26 +533,26 @@ private static Primitive handlePrimitive(ITypeBinding variable) { return null; } - private DataType handleCompositeType(ITypeBinding ref) { - String classifierName = wrapName(ref); + private DataType handleCompositeType(final ITypeBinding ref) { + final String classifierName = wrapName(ref); - if (!existingDataTypesMap.containsKey(classifierName)) { + if (!this.existingDataTypesMap.containsKey(classifierName)) { // TODO why is this commented out? // existingDataTypesMap.put(classifierName, createTypesRecursively(ref)); - existingDataTypesMap.put(classifierName, create.newCompositeDataType() + this.existingDataTypesMap.put(classifierName, this.create.newCompositeDataType() .withName(classifierName)); - repository.addToRepository(existingDataTypesMap.get(classifierName)); + this.repository.addToRepository(this.existingDataTypesMap.get(classifierName)); } - return create.fetchOfCompositeDataType(classifierName); + return this.create.fetchOfCompositeDataType(classifierName); } - private static String wrapName(ITypeBinding name) { + private static String wrapName(final ITypeBinding name) { return wrapName(name.getQualifiedName()); } - private static String wrapName(String name) { - String fullName = name.replace(".", "_"); + private static String wrapName(final String name) { + final String fullName = name.replace(".", "_"); // Erase type parameters in identifiers // TODO is this the right solution? if (fullName.contains("<")) { diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Rule.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Rule.java index d7502077..cc0b9e4f 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Rule.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Rule.java @@ -20,19 +20,19 @@ public interface Rule extends Service { public abstract boolean isBuildRule(); @Override - default IBlackboardInteractingJob create(RetrieverConfiguration configuration, - RetrieverBlackboard blackboard) { - Rule rule = this; - return new AbstractBlackboardInteractingJob() { + default IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { + final Rule rule = this; + return new AbstractBlackboardInteractingJob<>() { @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { - for (Path path : blackboard.getDiscoveredPaths()) { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + for (final Path path : blackboard.getDiscoveredPaths()) { rule.processRules(blackboard, path); } } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { } @Override diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java index f8f37a8a..03bb65a0 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java @@ -45,8 +45,8 @@ public class RuleHelper { private static final Logger LOG = Logger.getLogger(RuleHelper.class); - public static String getUnitName(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static String getUnitName(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); String name = "NO NAME"; for (final AbstractTypeDeclaration abstType : types) { @@ -57,8 +57,8 @@ public static String getUnitName(CompilationUnit unit) { return name; } - public static boolean isAbstraction(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isAbstraction(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final AbstractTypeDeclaration abstType : types) { if ((abstType instanceof TypeDeclaration) && ((TypeDeclaration) abstType).isInterface()) { @@ -68,8 +68,8 @@ public static boolean isAbstraction(CompilationUnit unit) { return false; } - public static boolean isUnitAnnotatedWithName(CompilationUnit unit, String... names) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isUnitAnnotatedWithName(final CompilationUnit unit, final String... names) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final String name : names) { for (final AbstractTypeDeclaration abstType : types) { @@ -81,31 +81,31 @@ public static boolean isUnitAnnotatedWithName(CompilationUnit unit, String... na return false; } - public static boolean isObjectAnnotatedWithName(BodyDeclaration body, String name) { + public static boolean isObjectAnnotatedWithName(final BodyDeclaration body, final String name) { return containsAnnotationWithName(cast(body.modifiers(), IExtendedModifier.class), name); } - public static boolean isObjectAnnotatedWithName(SingleVariableDeclaration parameter, String name) { + public static boolean isObjectAnnotatedWithName(final SingleVariableDeclaration parameter, final String name) { return containsAnnotationWithName(cast(parameter.modifiers(), IExtendedModifier.class), name); } - public static boolean isObjectAnnotatedWithName(TypeParameter parameter, String name) { + public static boolean isObjectAnnotatedWithName(final TypeParameter parameter, final String name) { return containsAnnotationWithName(cast(parameter.modifiers(), IExtendedModifier.class), name); } - public static boolean isObjectAnnotatedWithName(VariableDeclarationExpression expression, String name) { + public static boolean isObjectAnnotatedWithName(final VariableDeclarationExpression expression, final String name) { return containsAnnotationWithName(cast(expression.modifiers(), IExtendedModifier.class), name); } - public static boolean isObjectAnnotatedWithName(VariableDeclarationStatement statement, String name) { + public static boolean isObjectAnnotatedWithName(final VariableDeclarationStatement statement, final String name) { return containsAnnotationWithName(cast(statement.modifiers(), IExtendedModifier.class), name); } - public static boolean isClassifierAnnotatedWithName(BodyDeclaration abstTypeDecl, String name) { + public static boolean isClassifierAnnotatedWithName(final BodyDeclaration abstTypeDecl, final String name) { return containsAnnotationWithName(cast(abstTypeDecl.modifiers(), IExtendedModifier.class), name); } - private static boolean containsAnnotationWithName(List modifiers, String name) { + private static boolean containsAnnotationWithName(final List modifiers, final String name) { for (final IExtendedModifier mod : modifiers) { if (mod.isAnnotation()) { final Annotation anno = (Annotation) mod; @@ -120,33 +120,33 @@ private static boolean containsAnnotationWithName(List modifi return false; } - public static List getMethods(CompilationUnit unit) { + public static List getMethods(final CompilationUnit unit) { final List methods = new ArrayList<>(); // TODO: Methods of sub-classes are not returned - List types = cast(unit.types(), AbstractTypeDeclaration.class); + final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { methods.addAll(getMethods((TypeDeclaration) abstType)); } else if (abstType instanceof EnumDeclaration) { - EnumDeclaration enumDecl = (EnumDeclaration) abstType; + final EnumDeclaration enumDecl = (EnumDeclaration) abstType; - List bodies = cast(enumDecl.bodyDeclarations(), BodyDeclaration.class); + final List bodies = cast(enumDecl.bodyDeclarations(), BodyDeclaration.class); - for (BodyDeclaration body : bodies) { + for (final BodyDeclaration body : bodies) { if (body instanceof MethodDeclaration) { methods.add((MethodDeclaration) body); } } } else if (abstType instanceof AnnotationTypeDeclaration) { - AnnotationTypeDeclaration anno = (AnnotationTypeDeclaration) abstType; + final AnnotationTypeDeclaration anno = (AnnotationTypeDeclaration) abstType; - List bodies = cast(anno.bodyDeclarations(), BodyDeclaration.class); + final List bodies = cast(anno.bodyDeclarations(), BodyDeclaration.class); - for (BodyDeclaration body : bodies) { + for (final BodyDeclaration body : bodies) { if (body instanceof MethodDeclaration) { methods.add((MethodDeclaration) body); } @@ -157,12 +157,12 @@ public static List getMethods(CompilationUnit unit) { return methods; } - public static List getMethods(TypeDeclaration type) { + public static List getMethods(final TypeDeclaration type) { return List.of(type.getMethods()); } - public static List getMethods(Type type) { - ITypeBinding binding = type.resolveBinding(); + public static List getMethods(final Type type) { + final ITypeBinding binding = type.resolveBinding(); if (binding == null) { LOG.warn("Could not resolve type binding for \"" + type + "\". Returning empty list for getMethods"); return List.of(); @@ -171,33 +171,33 @@ public static List getMethods(Type type) { } } - public static List getFields(CompilationUnit unit) { + public static List getFields(final CompilationUnit unit) { final List fields = new ArrayList<>(); - List types = cast(unit.types(), AbstractTypeDeclaration.class); + final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; fields.addAll(List.of(type.getFields())); } else if (abstType instanceof EnumDeclaration) { - EnumDeclaration enumDecl = (EnumDeclaration) abstType; + final EnumDeclaration enumDecl = (EnumDeclaration) abstType; - List bodies = cast(enumDecl.bodyDeclarations(), BodyDeclaration.class); + final List bodies = cast(enumDecl.bodyDeclarations(), BodyDeclaration.class); - for (BodyDeclaration body : bodies) { + for (final BodyDeclaration body : bodies) { if (body instanceof FieldDeclaration) { fields.add((FieldDeclaration) body); } } } else if (abstType instanceof AnnotationTypeDeclaration) { - AnnotationTypeDeclaration anno = (AnnotationTypeDeclaration) abstType; + final AnnotationTypeDeclaration anno = (AnnotationTypeDeclaration) abstType; - List bodies = cast(anno.bodyDeclarations(), BodyDeclaration.class); + final List bodies = cast(anno.bodyDeclarations(), BodyDeclaration.class); - for (BodyDeclaration body : bodies) { + for (final BodyDeclaration body : bodies) { if (body instanceof FieldDeclaration) { fields.add((FieldDeclaration) body); } @@ -208,12 +208,12 @@ public static List getFields(CompilationUnit unit) { return fields; } - public static List getParameters(MethodDeclaration method) { + public static List getParameters(final MethodDeclaration method) { return cast(method.parameters(), SingleVariableDeclaration.class); } - public static boolean isMethodAnnotatedWithName(MethodDeclaration method, String... names) { - for (String name : names) { + public static boolean isMethodAnnotatedWithName(final MethodDeclaration method, final String... names) { + for (final String name : names) { if (isObjectAnnotatedWithName(method, name)) { return true; } @@ -221,9 +221,9 @@ public static boolean isMethodAnnotatedWithName(MethodDeclaration method, String return false; } - public static boolean isFieldAbstract(FieldDeclaration field) { - Type type = field.getType(); - ITypeBinding binding = type.resolveBinding(); + public static boolean isFieldAbstract(final FieldDeclaration field) { + final Type type = field.getType(); + final ITypeBinding binding = type.resolveBinding(); if (binding == null) { LOG.warn("field: \"" + field + "\", has type binding null => returning false for isFieldAbstract"); @@ -233,9 +233,9 @@ public static boolean isFieldAbstract(FieldDeclaration field) { return binding.isInterface(); } - public static boolean isParameterAbstract(SingleVariableDeclaration parameter) { - Type type = parameter.getType(); - ITypeBinding binding = type.resolveBinding(); + public static boolean isParameterAbstract(final SingleVariableDeclaration parameter) { + final Type type = parameter.getType(); + final ITypeBinding binding = type.resolveBinding(); if (binding == null) { LOG.warn("parameter: \"" + parameter + "\", has type binding null " @@ -246,9 +246,10 @@ public static boolean isParameterAbstract(SingleVariableDeclaration parameter) { return binding.isInterface(); } - public static boolean isParameterAClassAnnotatedWith(SingleVariableDeclaration parameter, String... names) { - Type type = parameter.getType(); - ITypeBinding binding = type.resolveBinding(); + public static boolean isParameterAClassAnnotatedWith(final SingleVariableDeclaration parameter, + final String... names) { + final Type type = parameter.getType(); + final ITypeBinding binding = type.resolveBinding(); if (binding == null) { LOG.warn("parameter: \"" + parameter + "\", has type binding null " @@ -257,7 +258,7 @@ public static boolean isParameterAClassAnnotatedWith(SingleVariableDeclaration p } for (final String name : names) { - for (IAnnotationBinding anno : binding.getAnnotations()) { + for (final IAnnotationBinding anno : binding.getAnnotations()) { if (anno.getName() .equals(name)) { return true; @@ -268,17 +269,17 @@ public static boolean isParameterAClassAnnotatedWith(SingleVariableDeclaration p return false; } - public static boolean isFieldModifiedExactlyWith(BodyDeclaration field, String... names) { + public static boolean isFieldModifiedExactlyWith(final BodyDeclaration field, final String... names) { return areModifiersExactly(cast(field.modifiers(), IExtendedModifier.class), names); } - private static boolean areModifiersExactly(List modifiers, String... names) { - Set nameSet = Set.of(names) + private static boolean areModifiersExactly(final List modifiers, final String... names) { + final Set nameSet = Set.of(names) .stream() .map(x -> x.toLowerCase(Locale.US)) .collect(Collectors.toSet()); - long exactModifierCount = modifiers.stream() + final long exactModifierCount = modifiers.stream() .filter(IExtendedModifier::isModifier) .map(Modifier.class::cast) .map(x -> x.getKeyword() @@ -290,14 +291,14 @@ private static boolean areModifiersExactly(List modifiers, St return exactModifierCount == names.length; } - public static boolean isParameterAnnotatedWith(SingleVariableDeclaration parameter, String name) { + public static boolean isParameterAnnotatedWith(final SingleVariableDeclaration parameter, final String name) { return isObjectAnnotatedWithName(parameter, name); } - public static boolean isUnitNamedWith(CompilationUnit unit, String name) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isUnitNamedWith(final CompilationUnit unit, final String name) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration type : types) { + for (final AbstractTypeDeclaration type : types) { if (type.getName() .getFullyQualifiedName() .equals(name)) { @@ -308,10 +309,10 @@ public static boolean isUnitNamedWith(CompilationUnit unit, String name) { return false; } - public static boolean isUnitAnEnum(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isUnitAnEnum(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration type : types) { + for (final AbstractTypeDeclaration type : types) { if (type instanceof EnumDeclaration) { return true; } @@ -319,16 +320,16 @@ public static boolean isUnitAnEnum(CompilationUnit unit) { return false; } - public static List getAllInterfaces(CompilationUnit unit) { - List interfaces = new ArrayList<>(); + public static List getAllInterfaces(final CompilationUnit unit) { + final List interfaces = new ArrayList<>(); - List types = cast(unit.types(), AbstractTypeDeclaration.class); + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; - List interfaceTypes = cast(type.superInterfaceTypes(), Type.class); + final List interfaceTypes = cast(type.superInterfaceTypes(), Type.class); interfaces.addAll(interfaceTypes); } } @@ -336,16 +337,16 @@ public static List getAllInterfaces(CompilationUnit unit) { return interfaces; } - public static boolean isFieldAnnotatedWithName(BodyDeclaration field, String name) { + public static boolean isFieldAnnotatedWithName(final BodyDeclaration field, final String name) { return containsAnnotationWithName(cast(field.modifiers(), IExtendedModifier.class), name); } - public static boolean isClassImplementing(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isClassImplementing(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (!type.isInterface() && (!type.superInterfaceTypes() .isEmpty())) { return true; @@ -355,12 +356,12 @@ public static boolean isClassImplementing(CompilationUnit unit) { return false; } - public static boolean isImplementingOrExtending(CompilationUnit unit, String ifaceName) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isImplementingOrExtending(final CompilationUnit unit, final String ifaceName) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (isImplementingOrExtending(type.resolveBinding(), ifaceName)) { return true; } @@ -369,7 +370,7 @@ public static boolean isImplementingOrExtending(CompilationUnit unit, String ifa return false; } - public static boolean isImplementingOrExtending(ITypeBinding binding, String ifaceName) { + public static boolean isImplementingOrExtending(final ITypeBinding binding, final String ifaceName) { if (binding == null) { LOG.warn( "binding is null => returning false for isImplementingOrExtending(binding, \"" + ifaceName + "\")"); @@ -379,38 +380,35 @@ public static boolean isImplementingOrExtending(ITypeBinding binding, String ifa if (equalsWithGeneric(binding.getName(), ifaceName)) { return true; } - ITypeBinding superClass = binding.getSuperclass(); + final ITypeBinding superClass = binding.getSuperclass(); if (superClass != null && isImplementingOrExtending(superClass, ifaceName)) { return true; } - for (ITypeBinding type : binding.getInterfaces()) { - if (equalsWithGeneric(type.getName(), ifaceName)) { - return true; - } - if (isImplementingOrExtending(type, ifaceName)) { + for (final ITypeBinding type : binding.getInterfaces()) { + if (equalsWithGeneric(type.getName(), ifaceName) || isImplementingOrExtending(type, ifaceName)) { return true; } } return false; } - private static boolean equalsWithGeneric(String withGeneric, String withoutGeneric) { + private static boolean equalsWithGeneric(final String withGeneric, final String withoutGeneric) { if (!withGeneric.startsWith(withoutGeneric)) { return false; } - String rest = withGeneric.substring(withoutGeneric.length()); + final String rest = withGeneric.substring(withoutGeneric.length()); if (!rest.isEmpty() && (!rest.startsWith("<") || !rest.endsWith(">"))) { return false; } return true; } - public static boolean isClassExtending(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isClassExtending(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (!type.isInterface() && (type.getSuperclassType() != null)) { return true; } @@ -419,14 +417,14 @@ public static boolean isClassExtending(CompilationUnit unit) { return false; } - public static Type getExtends(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static Type getExtends(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (!type.isInterface()) { - Type superclass = type.getSuperclassType(); + final Type superclass = type.getSuperclassType(); if (superclass != null) { return superclass; } @@ -437,12 +435,12 @@ public static Type getExtends(CompilationUnit unit) { return null; } - public static boolean isClassModifiedExactlyWith(CompilationUnit unit, String... names) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isClassModifiedExactlyWith(final CompilationUnit unit, final String... names) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (!type.isInterface()) { return areModifiersExactly(cast(type.modifiers(), IExtendedModifier.class), names); } @@ -451,11 +449,11 @@ public static boolean isClassModifiedExactlyWith(CompilationUnit unit, String... return false; } - public static boolean isMethodModifiedExactlyWith(BodyDeclaration method, String... names) { + public static boolean isMethodModifiedExactlyWith(final BodyDeclaration method, final String... names) { return areModifiersExactly(cast(method.modifiers(), IExtendedModifier.class), names); } - public static List getAllPublicMethods(CompilationUnit unit) { + public static List getAllPublicMethods(final CompilationUnit unit) { return getMethods(unit).stream() .filter(MethodDeclaration::isConstructor) .filter(x -> cast(x.modifiers(), IExtendedModifier.class).stream() @@ -465,29 +463,29 @@ public static List getAllPublicMethods(CompilationUnit unit) .collect(Collectors.toList()); } - public static List getConstructors(CompilationUnit unit) { + public static List getConstructors(final CompilationUnit unit) { return getMethods(unit).stream() .filter(MethodDeclaration::isConstructor) .collect(Collectors.toList()); } - public static boolean isConstructorAnnotatedWithName(MethodDeclaration constructor, String name) { + public static boolean isConstructorAnnotatedWithName(final MethodDeclaration constructor, final String name) { if (!constructor.isConstructor()) { return false; } return isMethodAnnotatedWithName(constructor, name); } - public static boolean isClassOfFieldAnnotatedWithName(FieldDeclaration field, String... names) { - ITypeBinding binding = field.getType() + public static boolean isClassOfFieldAnnotatedWithName(final FieldDeclaration field, final String... names) { + final ITypeBinding binding = field.getType() .resolveBinding(); if (binding == null) { LOG.warn("field: could not resolve type binding for \"" + field.getType() + "\" => returning false from isClassOfFieldAnnotatedWithName"); return false; } - IAnnotationBinding[] annotations = binding.getAnnotations(); - Set uniqueNames = Set.of(names); + final IAnnotationBinding[] annotations = binding.getAnnotations(); + final Set uniqueNames = Set.of(names); return List.of(annotations) .stream() @@ -495,13 +493,13 @@ public static boolean isClassOfFieldAnnotatedWithName(FieldDeclaration field, St .anyMatch(uniqueNames::contains); } - public static String getMethodAnnotationStringValue(MethodDeclaration method, String annotation) { + public static String getMethodAnnotationStringValue(final MethodDeclaration method, final String annotation) { return getMethodAnnotationStringValue(method, annotation, "value"); } - public static String getMethodAnnotationStringValue(MethodDeclaration method, String annotationName, - String memberName) { - List annotations = cast(method.modifiers(), IExtendedModifier.class).stream() + public static String getMethodAnnotationStringValue(final MethodDeclaration method, final String annotationName, + final String memberName) { + final List annotations = cast(method.modifiers(), IExtendedModifier.class).stream() .filter(x -> x.isAnnotation()) .map(Annotation.class::cast) .filter(x -> x.getTypeName() @@ -509,14 +507,14 @@ public static String getMethodAnnotationStringValue(MethodDeclaration method, St .endsWith(annotationName)) .collect(Collectors.toList()); - for (Annotation annotation : annotations) { + for (final Annotation annotation : annotations) { Expression expression = null; if (annotation.isSingleMemberAnnotation()) { - SingleMemberAnnotation smAnnotation = (SingleMemberAnnotation) annotation; + final SingleMemberAnnotation smAnnotation = (SingleMemberAnnotation) annotation; expression = smAnnotation.getValue(); } else if (annotation.isNormalAnnotation()) { - NormalAnnotation nAnnotation = (NormalAnnotation) annotation; + final NormalAnnotation nAnnotation = (NormalAnnotation) annotation; expression = cast(nAnnotation.values(), MemberValuePair.class).stream() .filter(x -> x.getName() .getIdentifier() @@ -536,7 +534,7 @@ public static String getMethodAnnotationStringValue(MethodDeclaration method, St return ((StringLiteral) expression).getLiteralValue(); } - Object compiledValue = expression.resolveConstantExpressionValue(); + final Object compiledValue = expression.resolveConstantExpressionValue(); if (compiledValue != null) { return compiledValue.toString(); } @@ -546,14 +544,15 @@ public static String getMethodAnnotationStringValue(MethodDeclaration method, St return null; } - public static String getUnitAnnotationStringValue(CompilationUnit unit, String annotation) { + public static String getUnitAnnotationStringValue(final CompilationUnit unit, final String annotation) { return getUnitAnnotationStringValue(unit, annotation, "value"); } - public static String getUnitAnnotationStringValue(CompilationUnit unit, String annotationName, String memberName) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static String getUnitAnnotationStringValue(final CompilationUnit unit, final String annotationName, + final String memberName) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - List annotations = types.stream() + final List annotations = types.stream() .map(y -> cast(y.modifiers(), IExtendedModifier.class).stream() .filter(x -> x.isAnnotation()) .map(Annotation.class::cast) @@ -561,16 +560,16 @@ public static String getUnitAnnotationStringValue(CompilationUnit unit, String a .getFullyQualifiedName() .endsWith(annotationName)) .collect(Collectors.toList())) - .collect(() -> new ArrayList(), (acc, x) -> acc.addAll(x), (acc1, acc2) -> acc1.addAll(acc2)); + .collect(() -> new ArrayList<>(), (acc, x) -> acc.addAll(x), (acc1, acc2) -> acc1.addAll(acc2)); - for (Annotation annotation : annotations) { + for (final Annotation annotation : annotations) { Expression expression = null; if (annotation.isSingleMemberAnnotation()) { - SingleMemberAnnotation smAnnotation = (SingleMemberAnnotation) annotation; + final SingleMemberAnnotation smAnnotation = (SingleMemberAnnotation) annotation; expression = smAnnotation.getValue(); } else if (annotation.isNormalAnnotation()) { - NormalAnnotation nAnnotation = (NormalAnnotation) annotation; + final NormalAnnotation nAnnotation = (NormalAnnotation) annotation; expression = cast(nAnnotation.values(), MemberValuePair.class).stream() .filter(x -> x.getName() .getIdentifier() @@ -595,7 +594,7 @@ public static String getUnitAnnotationStringValue(CompilationUnit unit, String a // Concentrate the warnings to this single method. It is necessary due to the // Eclipse JDT DOM API. @SuppressWarnings({ "unchecked", "rawtypes" }) - private static List cast(List list, Class clazz) { + private static List cast(final List list, final Class clazz) { if (!list.isEmpty() && !clazz.isInstance(list.get(0))) { throw new ClassCastException("Illegal cast in EclipseRuleHelper!" + "\n" + list.get(0) .getClass() + " -> " + clazz); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceConfiguration.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceConfiguration.java index 9a9a3670..04797dff 100644 --- a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceConfiguration.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceConfiguration.java @@ -21,16 +21,16 @@ public class ServiceConfiguration { private final Map> selectedDependencies; private final Set> dependencyProviders; - public ServiceConfiguration(ServiceCollection serviceCollection, String selectedServicesKey, - String serviceConfigKeyPrefix) { + public ServiceConfiguration(final ServiceCollection serviceCollection, final String selectedServicesKey, + final String serviceConfigKeyPrefix) { this.selectedServicesKey = selectedServicesKey; this.serviceConfigKeyPrefix = serviceConfigKeyPrefix; this.serviceConfigs = new HashMap<>(); this.services = new HashMap<>(); - for (T service : serviceCollection.getServices()) { + for (final T service : serviceCollection.getServices()) { this.services.put(service.getID(), service); - Map initializedConfig = new HashMap<>(); - for (String key : service.getConfigurationKeys()) { + final Map initializedConfig = new HashMap<>(); + for (final String key : service.getConfigurationKeys()) { initializedConfig.put(key, ""); } this.serviceConfigs.put(service.getID(), initializedConfig); @@ -41,19 +41,19 @@ public ServiceConfiguration(ServiceCollection serviceCollection, String selec this.dependencyProviders.add(this); } - public void addDependencyProvider(ServiceConfiguration dependencyProvider) { - dependencyProviders.add(dependencyProvider); + public void addDependencyProvider(final ServiceConfiguration dependencyProvider) { + this.dependencyProviders.add(dependencyProvider); } @SuppressWarnings("unchecked") - public void applyAttributeMap(Map attributeMap) { - Set serviceIds = (Set) attributeMap.get(selectedServicesKey); - for (Map.Entry serviceEntry : services.entrySet()) { - String serviceId = serviceEntry.getKey(); - T service = serviceEntry.getValue(); - if (attributeMap.get(serviceConfigKeyPrefix + serviceId) != null) { - serviceConfigs.put(serviceId, - (Map) attributeMap.get(serviceConfigKeyPrefix + serviceId)); + public void applyAttributeMap(final Map attributeMap) { + final Set serviceIds = (Set) attributeMap.get(this.selectedServicesKey); + for (final Map.Entry serviceEntry : this.services.entrySet()) { + final String serviceId = serviceEntry.getKey(); + final T service = serviceEntry.getValue(); + if (attributeMap.get(this.serviceConfigKeyPrefix + serviceId) != null) { + this.serviceConfigs.put(serviceId, + (Map) attributeMap.get(this.serviceConfigKeyPrefix + serviceId)); } if ((serviceIds != null) && serviceIds.contains(service.getID())) { this.select(service); @@ -62,64 +62,64 @@ public void applyAttributeMap(Map attributeMap) { } - public String getConfig(String serviceId, String key) { - Map config = serviceConfigs.get(serviceId); + public String getConfig(final String serviceId, final String key) { + final Map config = this.serviceConfigs.get(serviceId); if (config == null) { return null; } return config.get(key); } - public Map getWholeConfig(String serviceId) { - return Collections.unmodifiableMap(serviceConfigs.get(serviceId)); + public Map getWholeConfig(final String serviceId) { + return Collections.unmodifiableMap(this.serviceConfigs.get(serviceId)); } - public void setConfig(String serviceId, String key, String value) { - Map config = serviceConfigs.get(serviceId); + public void setConfig(final String serviceId, final String key, final String value) { + Map config = this.serviceConfigs.get(serviceId); if (config == null) { config = new HashMap<>(); - serviceConfigs.put(serviceId, config); + this.serviceConfigs.put(serviceId, config); } config.put(key, value); } - public void select(T service) { - manuallySelectedServices.add(service); - for (ServiceConfiguration dependencyProvider : dependencyProviders) { + public void select(final T service) { + this.manuallySelectedServices.add(service); + for (final ServiceConfiguration dependencyProvider : this.dependencyProviders) { dependencyProvider.selectDependenciesOf(service); } } - public void deselect(T service) { - manuallySelectedServices.remove(service); - for (ServiceConfiguration dependencyProvider : dependencyProviders) { + public void deselect(final T service) { + this.manuallySelectedServices.remove(service); + for (final ServiceConfiguration dependencyProvider : this.dependencyProviders) { dependencyProvider.deselectDependenciesOf(service); } } - public boolean isManuallySelected(T service) { - return manuallySelectedServices.contains(service); + public boolean isManuallySelected(final T service) { + return this.manuallySelectedServices.contains(service); } public Set getSelected() { - Set selectedServices = new HashSet<>(manuallySelectedServices); - selectedServices.addAll(selectedDependencies.keySet()); + final Set selectedServices = new HashSet<>(this.manuallySelectedServices); + selectedServices.addAll(this.selectedDependencies.keySet()); return Collections.unmodifiableSet(selectedServices); } public Queue> getExecutionOrder() { - List> executionOrder = new ArrayList<>(); - Queue remainingServices = new ArrayDeque<>(getSelected()); - List requiringServices = new LinkedList<>(); - Map> extendedRequirements = new HashMap<>(); + final List> executionOrder = new ArrayList<>(); + final Queue remainingServices = new ArrayDeque<>(this.getSelected()); + final List requiringServices = new LinkedList<>(); + final Map> extendedRequirements = new HashMap<>(); - for (T service : remainingServices) { + for (final T service : remainingServices) { extendedRequirements.put(service.getID(), new HashSet<>(service.getRequiredServices())); } // Rephrase all dependencies into requirements - for (T providingService : remainingServices) { - for (String dependentID : providingService.getDependentServices()) { + for (final T providingService : remainingServices) { + for (final String dependentID : providingService.getDependentServices()) { if (!extendedRequirements.containsKey(dependentID)) { continue; } @@ -129,14 +129,14 @@ public Queue> getExecutionOrder() { } while (!remainingServices.isEmpty()) { - T candidate = remainingServices.poll(); - String candidateID = candidate.getID(); - Set candidateRequirements = extendedRequirements.get(candidateID); - if (isRequiringAny(candidateRequirements, remainingServices) - || isRequiringAny(candidateRequirements, requiringServices)) { + final T candidate = remainingServices.poll(); + final String candidateID = candidate.getID(); + final Set candidateRequirements = extendedRequirements.get(candidateID); + if (this.isRequiringAny(candidateRequirements, remainingServices) + || this.isRequiringAny(candidateRequirements, requiringServices)) { requiringServices.add(candidate); } else { - addAfterRequirements(candidate, candidateRequirements, executionOrder); + this.addAfterRequirements(candidate, candidateRequirements, executionOrder); remainingServices.addAll(requiringServices); requiringServices.clear(); @@ -148,10 +148,11 @@ public Queue> getExecutionOrder() { return new ArrayDeque<>(executionOrder); } - private void addAfterRequirements(T service, Set serviceRequirements, List> executionOrder) { + private void addAfterRequirements(final T service, final Set serviceRequirements, + final List> executionOrder) { if (executionOrder.isEmpty() - || isRequiringAny(serviceRequirements, executionOrder.get(executionOrder.size() - 1))) { - Collection newStep = new ArrayList<>(); + || this.isRequiringAny(serviceRequirements, executionOrder.get(executionOrder.size() - 1))) { + final Collection newStep = new ArrayList<>(); newStep.add(service); executionOrder.add(newStep); return; @@ -159,8 +160,8 @@ private void addAfterRequirements(T service, Set serviceRequirements, Li Collection earliestCandidate = executionOrder.get(executionOrder.size() - 1); for (int i = executionOrder.size() - 2; i >= 0; i--) { - Collection currentStep = executionOrder.get(i); - if (isRequiringAny(serviceRequirements, currentStep)) { + final Collection currentStep = executionOrder.get(i); + if (this.isRequiringAny(serviceRequirements, currentStep)) { break; } earliestCandidate = currentStep; @@ -168,74 +169,74 @@ private void addAfterRequirements(T service, Set serviceRequirements, Li earliestCandidate.add(service); } - private boolean isRequiringAny(Set requirements, Collection services) { + private boolean isRequiringAny(final Set requirements, final Collection services) { return services.stream() .map(Service::getID) .anyMatch(requirements::contains); } public Collection getAvailable() { - return Collections.unmodifiableCollection(services.values()); + return Collections.unmodifiableCollection(this.services.values()); } - public void selectDependenciesOf(Service service) { - for (String dependencyID : service.getRequiredServices()) { - if (!services.containsKey(dependencyID)) { + public void selectDependenciesOf(final Service service) { + for (final String dependencyID : service.getRequiredServices()) { + if (!this.services.containsKey(dependencyID)) { continue; } - T dependency = services.get(dependencyID); - addDependingService(dependency, service); + final T dependency = this.services.get(dependencyID); + this.addDependingService(dependency, service); } } - private void addDependingService(T dependency, Service service) { - if (selectedDependencies.containsKey(dependency)) { - Set dependingServices = selectedDependencies.get(dependency); + private void addDependingService(final T dependency, final Service service) { + if (this.selectedDependencies.containsKey(dependency)) { + final Set dependingServices = this.selectedDependencies.get(dependency); dependingServices.add(service); } else { - Set dependingServices = new HashSet<>(); + final Set dependingServices = new HashSet<>(); dependingServices.add(service); - selectedDependencies.put(dependency, dependingServices); - for (ServiceConfiguration dependencyProvider : dependencyProviders) { + this.selectedDependencies.put(dependency, dependingServices); + for (final ServiceConfiguration dependencyProvider : this.dependencyProviders) { dependencyProvider.selectDependenciesOf(dependency); } } } - public void deselectDependenciesOf(Service service) { - for (String dependencyID : service.getRequiredServices()) { - if (!services.containsKey(dependencyID)) { + public void deselectDependenciesOf(final Service service) { + for (final String dependencyID : service.getRequiredServices()) { + if (!this.services.containsKey(dependencyID)) { continue; } - T dependency = services.get(dependencyID); - removeDependingService(dependency, service); + final T dependency = this.services.get(dependencyID); + this.removeDependingService(dependency, service); } } - private void removeDependingService(T dependency, Service service) { - if (!selectedDependencies.containsKey(dependency)) { + private void removeDependingService(final T dependency, final Service service) { + if (!this.selectedDependencies.containsKey(dependency)) { return; } - Set dependingServices = selectedDependencies.get(dependency); + final Set dependingServices = this.selectedDependencies.get(dependency); dependingServices.remove(service); // Remove not needed dependencies. if (dependingServices.isEmpty()) { - selectedDependencies.remove(dependency); + this.selectedDependencies.remove(dependency); } } public Map toMap() { final Map result = new HashMap<>(); - for (String serviceId : serviceConfigs.keySet()) { - result.put(serviceConfigKeyPrefix + serviceId, serviceConfigs.get(serviceId)); + for (final String serviceId : this.serviceConfigs.keySet()) { + result.put(this.serviceConfigKeyPrefix + serviceId, this.serviceConfigs.get(serviceId)); } - result.put(selectedServicesKey, serializeServices(manuallySelectedServices)); + result.put(this.selectedServicesKey, serializeServices(this.manuallySelectedServices)); return result; } - private static Set serializeServices(Iterable services) { - Set serviceIds = new HashSet<>(); - for (Service service : services) { + private static Set serializeServices(final Iterable services) { + final Set serviceIds = new HashSet<>(); + for (final Service service : services) { serviceIds.add(service.getID()); } return serviceIds; diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositor.java index 4fdadae5..283ab923 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositor.java @@ -44,45 +44,46 @@ */ public class RepositoryDecompositor implements Decompositor { @Override - public Collection> decompose(Repository repository) { + public Collection> decompose(final Repository repository) { // Fetch components, interface provisions and requirements, signatures, and service effect // specifications - Set atomicComponents = new HashSet<>(); - Set composites = new HashSet<>(); - Set compositions = new HashSet<>(); - Set interfaceProvisions = new HashSet<>(); - Set interfaceRequirements = new HashSet<>(); - Set signatureProvisions = new HashSet<>(); - Set seffProvisions = new HashSet<>(); - Set componentAssemblies = new HashSet<>(); - Set provisionDelegations = new HashSet<>(); - Set requirementDelegations = new HashSet<>(); + final Set atomicComponents = new HashSet<>(); + final Set composites = new HashSet<>(); + final Set compositions = new HashSet<>(); + final Set interfaceProvisions = new HashSet<>(); + final Set interfaceRequirements = new HashSet<>(); + final Set signatureProvisions = new HashSet<>(); + final Set seffProvisions = new HashSet<>(); + final Set componentAssemblies = new HashSet<>(); + final Set provisionDelegations = new HashSet<>(); + final Set requirementDelegations = new HashSet<>(); - for (RepositoryComponent repositoryComponent : repository.getComponents__Repository()) { + for (final RepositoryComponent repositoryComponent : repository.getComponents__Repository()) { Component component; if (repositoryComponent instanceof BasicComponent) { - AtomicComponent atomicComponent = new AtomicComponent((BasicComponent) repositoryComponent, false); + final AtomicComponent atomicComponent = new AtomicComponent((BasicComponent) repositoryComponent, + false); atomicComponents.add(atomicComponent); component = atomicComponent; // Basic component specific behavior // Fetch service effect specifications from basic component - for (org.palladiosimulator.pcm.seff.ServiceEffectSpecification seff : atomicComponent.getValue() + for (final org.palladiosimulator.pcm.seff.ServiceEffectSpecification seff : atomicComponent.getValue() .getServiceEffectSpecifications__BasicComponent()) { if (seff instanceof ResourceDemandingSEFF) { if (seff.getDescribedService__SEFF() instanceof OperationSignature) { - ServiceEffectSpecification seffWrapper = new ServiceEffectSpecification( + final ServiceEffectSpecification seffWrapper = new ServiceEffectSpecification( (ResourceDemandingSEFF) seff, false); - OperationSignature operationSignature = (OperationSignature) seff + final OperationSignature operationSignature = (OperationSignature) seff .getDescribedService__SEFF(); - Signature signature = new Signature(operationSignature, false); - Interface interFace = new Interface(operationSignature.getInterface__OperationSignature(), - false); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, - interFace, false); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, - interFace, false); - ComponentSignatureProvisionRelation componentSignatureProvision = new ComponentSignatureProvisionRelation( + final Signature signature = new Signature(operationSignature, false); + final Interface interFace = new Interface( + operationSignature.getInterface__OperationSignature(), false); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation( + signature, interFace, false); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation( + component, interFace, false); + final ComponentSignatureProvisionRelation componentSignatureProvision = new ComponentSignatureProvisionRelation( interfaceProvision, signatureProvision, false); seffProvisions.add(new ServiceEffectSpecificationRelation(componentSignatureProvision, seffWrapper, false)); @@ -90,111 +91,111 @@ public Collection> decompose(Repository repository) { } } } else if (repositoryComponent instanceof CompositeComponent) { - Composite composite = new Composite((CompositeComponent) repositoryComponent, false); + final Composite composite = new Composite((CompositeComponent) repositoryComponent, false); composites.add(composite); component = composite; // Composite specific behavior // Create composition relations for each composite - for (AssemblyContext assemblyContext : composite.getValue() + for (final AssemblyContext assemblyContext : composite.getValue() .getAssemblyContexts__ComposedStructure()) { - RepositoryComponent encapsulatedComponent = assemblyContext + final RepositoryComponent encapsulatedComponent = assemblyContext .getEncapsulatedComponent__AssemblyContext(); // Create appropriate wrapper for child component - Component childWrapper = getGenericWrapperFor(encapsulatedComponent); + final Component childWrapper = this.getGenericWrapperFor(encapsulatedComponent); if (childWrapper == null) { // Ignore child that cannot be wrapped continue; } // Create composition for composite & child - CompositionRelation composition = new CompositionRelation(composite, childWrapper, false); + final CompositionRelation composition = new CompositionRelation(composite, childWrapper, false); compositions.add(composition); } // Process connectors of composite component - for (Connector connector : composite.getValue() + for (final Connector connector : composite.getValue() .getConnectors__ComposedStructure()) { if (connector instanceof AssemblyConnector) { - AssemblyConnector assemblyConnector = (AssemblyConnector) connector; + final AssemblyConnector assemblyConnector = (AssemblyConnector) connector; // Wrap provider and consumer component - Component provider = getGenericWrapperFor( - assemblyConnector.getProvidingAssemblyContext_AssemblyConnector() - .getEncapsulatedComponent__AssemblyContext()); - Component consumer = getGenericWrapperFor( - assemblyConnector.getRequiringAssemblyContext_AssemblyConnector() - .getEncapsulatedComponent__AssemblyContext()); + final Component provider = this + .getGenericWrapperFor(assemblyConnector.getProvidingAssemblyContext_AssemblyConnector() + .getEncapsulatedComponent__AssemblyContext()); + final Component consumer = this + .getGenericWrapperFor(assemblyConnector.getRequiringAssemblyContext_AssemblyConnector() + .getEncapsulatedComponent__AssemblyContext()); // Wrap role interfaces - Interface providedInterface = new Interface( + final Interface providedInterface = new Interface( assemblyConnector.getProvidedRole_AssemblyConnector() .getProvidedInterface__OperationProvidedRole(), false); - Interface requiredInterface = new Interface( + final Interface requiredInterface = new Interface( assemblyConnector.getRequiredRole_AssemblyConnector() .getRequiredInterface__OperationRequiredRole(), false); // Create interface relations & component assembly relation - InterfaceProvisionRelation provisionRelation = new InterfaceProvisionRelation(provider, + final InterfaceProvisionRelation provisionRelation = new InterfaceProvisionRelation(provider, providedInterface, false); - InterfaceRequirementRelation requirementRelation = new InterfaceRequirementRelation(consumer, - requiredInterface, false); - ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, - requirementRelation, false); + final InterfaceRequirementRelation requirementRelation = new InterfaceRequirementRelation( + consumer, requiredInterface, false); + final ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation( + provisionRelation, requirementRelation, false); // Add assembly to discoverer componentAssemblies.add(assemblyRelation); } else if (connector instanceof ProvidedDelegationConnector) { - ProvidedDelegationConnector providedDelegationConnector = (ProvidedDelegationConnector) connector; + final ProvidedDelegationConnector providedDelegationConnector = (ProvidedDelegationConnector) connector; // Wrap the providing component & the inner and outer role's interfaces - Component connectorComponent = getGenericWrapperFor( + final Component connectorComponent = this.getGenericWrapperFor( providedDelegationConnector.getAssemblyContext_ProvidedDelegationConnector() .getEncapsulatedComponent__AssemblyContext()); - Interface innerInterface = new Interface( + final Interface innerInterface = new Interface( providedDelegationConnector.getInnerProvidedRole_ProvidedDelegationConnector() .getProvidedInterface__OperationProvidedRole(), false); - Interface outerInterface = new Interface( + final Interface outerInterface = new Interface( providedDelegationConnector.getOuterProvidedRole_ProvidedDelegationConnector() .getProvidedInterface__OperationProvidedRole(), false); // Create interface relations - InterfaceProvisionRelation innerInterfaceRelation = new InterfaceProvisionRelation( + final InterfaceProvisionRelation innerInterfaceRelation = new InterfaceProvisionRelation( connectorComponent, innerInterface, false); - InterfaceProvisionRelation outerInterfaceRelation = new InterfaceProvisionRelation(composite, - outerInterface, false); - CompositeProvisionDelegationRelation delegationRelation = new CompositeProvisionDelegationRelation( + final InterfaceProvisionRelation outerInterfaceRelation = new InterfaceProvisionRelation( + composite, outerInterface, false); + final CompositeProvisionDelegationRelation delegationRelation = new CompositeProvisionDelegationRelation( outerInterfaceRelation, innerInterfaceRelation, false); // Add delegation relation to discoverer provisionDelegations.add(delegationRelation); } else if (connector instanceof RequiredDelegationConnector) { - RequiredDelegationConnector requiredDelegationConnector = (RequiredDelegationConnector) connector; + final RequiredDelegationConnector requiredDelegationConnector = (RequiredDelegationConnector) connector; // Wrap the requiring component & the inner and outer role's interfaces - Component connectorComponent = getGenericWrapperFor( + final Component connectorComponent = this.getGenericWrapperFor( requiredDelegationConnector.getAssemblyContext_RequiredDelegationConnector() .getEncapsulatedComponent__AssemblyContext()); - Interface innerInterface = new Interface( + final Interface innerInterface = new Interface( requiredDelegationConnector.getInnerRequiredRole_RequiredDelegationConnector() .getRequiredInterface__OperationRequiredRole(), false); - Interface outerInterface = new Interface( + final Interface outerInterface = new Interface( requiredDelegationConnector.getOuterRequiredRole_RequiredDelegationConnector() .getRequiredInterface__OperationRequiredRole(), false); // Create interface relations & delegation relation - InterfaceRequirementRelation innerInterfaceRelation = new InterfaceRequirementRelation( + final InterfaceRequirementRelation innerInterfaceRelation = new InterfaceRequirementRelation( connectorComponent, innerInterface, false); - InterfaceRequirementRelation outerInterfaceRelation = new InterfaceRequirementRelation( + final InterfaceRequirementRelation outerInterfaceRelation = new InterfaceRequirementRelation( composite, outerInterface, false); - CompositeRequirementDelegationRelation delegationRelation = new CompositeRequirementDelegationRelation( + final CompositeRequirementDelegationRelation delegationRelation = new CompositeRequirementDelegationRelation( outerInterfaceRelation, innerInterfaceRelation, false); // Add delegation relation to discoverer @@ -208,17 +209,17 @@ public Collection> decompose(Repository repository) { // Behavior for generic repository components // Transform provided roles into interface provision relations - for (ProvidedRole providedRole : repositoryComponent.getProvidedRoles_InterfaceProvidingEntity()) { + for (final ProvidedRole providedRole : repositoryComponent.getProvidedRoles_InterfaceProvidingEntity()) { if (providedRole instanceof OperationProvidedRole) { - OperationProvidedRole operationProvidedRole = (OperationProvidedRole) providedRole; - Interface providerInterface = new Interface( + final OperationProvidedRole operationProvidedRole = (OperationProvidedRole) providedRole; + final Interface providerInterface = new Interface( operationProvidedRole.getProvidedInterface__OperationProvidedRole(), false); interfaceProvisions.add(new InterfaceProvisionRelation(component, providerInterface, false)); // Create signature provisions for provider interface - for (OperationSignature operationSignature : providerInterface.getValue() + for (final OperationSignature operationSignature : providerInterface.getValue() .getSignatures__OperationInterface()) { - Signature signatureWrapper = new Signature(operationSignature, false); + final Signature signatureWrapper = new Signature(operationSignature, false); signatureProvisions .add(new SignatureProvisionRelation(signatureWrapper, providerInterface, false)); } @@ -226,17 +227,17 @@ public Collection> decompose(Repository repository) { } // Transform required roles into interface requirement relations - for (RequiredRole requiredRole : repositoryComponent.getRequiredRoles_InterfaceRequiringEntity()) { + for (final RequiredRole requiredRole : repositoryComponent.getRequiredRoles_InterfaceRequiringEntity()) { if (requiredRole instanceof OperationRequiredRole) { - OperationRequiredRole operationRequiredRole = (OperationRequiredRole) requiredRole; - Interface consumerInterface = new Interface( + final OperationRequiredRole operationRequiredRole = (OperationRequiredRole) requiredRole; + final Interface consumerInterface = new Interface( operationRequiredRole.getRequiredInterface__OperationRequiredRole(), false); interfaceRequirements.add(new InterfaceRequirementRelation(component, consumerInterface, false)); // Create signature provisions for consumer interface - for (OperationSignature operationSignature : consumerInterface.getValue() + for (final OperationSignature operationSignature : consumerInterface.getValue() .getSignatures__OperationInterface()) { - Signature signatureWrapper = new Signature(operationSignature, false); + final Signature signatureWrapper = new Signature(operationSignature, false); signatureProvisions .add(new SignatureProvisionRelation(signatureWrapper, consumerInterface, false)); } @@ -244,24 +245,24 @@ public Collection> decompose(Repository repository) { } } - SimpleDiscoverer atomicComponentDiscoverer = new SimpleDiscoverer<>(atomicComponents, + final SimpleDiscoverer atomicComponentDiscoverer = new SimpleDiscoverer<>(atomicComponents, AtomicComponent.class); - SimpleDiscoverer compositeDiscoverer = new SimpleDiscoverer<>(composites, Composite.class); - SimpleDiscoverer compositionDiscoverer = new SimpleDiscoverer<>(compositions, + final SimpleDiscoverer compositeDiscoverer = new SimpleDiscoverer<>(composites, Composite.class); + final SimpleDiscoverer compositionDiscoverer = new SimpleDiscoverer<>(compositions, CompositionRelation.class); - SimpleDiscoverer signatureProvisionDiscoverer = new SimpleDiscoverer<>( + final SimpleDiscoverer signatureProvisionDiscoverer = new SimpleDiscoverer<>( signatureProvisions, SignatureProvisionRelation.class); - SimpleDiscoverer interfaceProvisionDiscoverer = new SimpleDiscoverer<>( + final SimpleDiscoverer interfaceProvisionDiscoverer = new SimpleDiscoverer<>( interfaceProvisions, InterfaceProvisionRelation.class); - SimpleDiscoverer interfaceRequirementDiscoverer = new SimpleDiscoverer<>( + final SimpleDiscoverer interfaceRequirementDiscoverer = new SimpleDiscoverer<>( interfaceRequirements, InterfaceRequirementRelation.class); - SimpleDiscoverer seffProvisionDiscoverer = new SimpleDiscoverer<>( + final SimpleDiscoverer seffProvisionDiscoverer = new SimpleDiscoverer<>( seffProvisions, ServiceEffectSpecificationRelation.class); - SimpleDiscoverer assemblyDiscoverer = new SimpleDiscoverer<>(componentAssemblies, - ComponentAssemblyRelation.class); - SimpleDiscoverer provisionDelegationDiscoverer = new SimpleDiscoverer<>( + final SimpleDiscoverer assemblyDiscoverer = new SimpleDiscoverer<>( + componentAssemblies, ComponentAssemblyRelation.class); + final SimpleDiscoverer provisionDelegationDiscoverer = new SimpleDiscoverer<>( provisionDelegations, CompositeProvisionDelegationRelation.class); - SimpleDiscoverer requirementDelegationDiscoverer = new SimpleDiscoverer<>( + final SimpleDiscoverer requirementDelegationDiscoverer = new SimpleDiscoverer<>( requirementDelegations, CompositeRequirementDelegationRelation.class); return List.of(atomicComponentDiscoverer, compositeDiscoverer, compositionDiscoverer, signatureProvisionDiscoverer, interfaceProvisionDiscoverer, interfaceRequirementDiscoverer, @@ -269,7 +270,7 @@ public Collection> decompose(Repository repository) { requirementDelegationDiscoverer); } - private Component getGenericWrapperFor(RepositoryComponent repositoryComponent) { + private Component getGenericWrapperFor(final RepositoryComponent repositoryComponent) { // Ignore components that are neither basic nor composite Component wrapper = null; if (repositoryComponent instanceof BasicComponent) { diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/SimpleDiscoverer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/SimpleDiscoverer.java index 54050dcc..d621b1dc 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/SimpleDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/SimpleDiscoverer.java @@ -13,7 +13,7 @@ * the type of {@link Replaceable} the discoverer provides */ public class SimpleDiscoverer extends Discoverer { - public SimpleDiscoverer(Set discoveries, Class discoveryType) { + public SimpleDiscoverer(final Set discoveries, final Class discoveryType) { super(discoveries, discoveryType); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestrator.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestrator.java index 274dec4f..30888848 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestrator.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestrator.java @@ -24,7 +24,7 @@ import tools.mdsd.mocore.framework.orchestration.Orchestrator; public class PcmOrchestrator extends Orchestrator { - public PcmOrchestrator(PcmSurrogate model) { + public PcmOrchestrator(final PcmSurrogate model) { super(model, new SignatureProcessor(model), new InterfaceProcessor(model), new DeploymentProcessor(model), new LinkResourceSpecificationProcessor(model), new ServiceEffectSpecificationProcessor(model), new SignatureProvisionRelationProcessor(model), new InterfaceProvisionRelationProcessor(model), diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessor.java index b1d60491..a2103708 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessor.java @@ -4,7 +4,7 @@ import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; public class AtomicComponentProcessor extends ComponentProcessor { - public AtomicComponentProcessor(PcmSurrogate model) { + public AtomicComponentProcessor(final PcmSurrogate model) { super(model, AtomicComponent.class); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessor.java index d8a5029b..138be4bf 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessor.java @@ -10,20 +10,21 @@ import tools.mdsd.mocore.framework.processor.Processor; public abstract class ComponentProcessor> extends Processor { - public ComponentProcessor(PcmSurrogate model, Class processableType) { + public ComponentProcessor(final PcmSurrogate model, final Class processableType) { super(model, processableType); } @Override - protected void refine(T discovery) { - List deploymentRelations = getModel().getByType(ComponentAllocationRelation.class); + protected void refine(final T discovery) { + final List deploymentRelations = this.getModel() + .getByType(ComponentAllocationRelation.class); deploymentRelations.removeIf(relation -> !relation.getSource() .equals(discovery)); if (deploymentRelations.isEmpty()) { - Deployment deployment = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation relation = new ComponentAllocationRelation(discovery, deployment, true); - addImplication(relation); + final Deployment deployment = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation relation = new ComponentAllocationRelation(discovery, deployment, true); + this.addImplication(relation); } } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessor.java index 4f686f90..fbbfe1ff 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessor.java @@ -4,7 +4,7 @@ import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; public class CompositeProcessor extends ComponentProcessor { - public CompositeProcessor(PcmSurrogate model) { + public CompositeProcessor(final PcmSurrogate model) { super(model, Composite.class); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessor.java index 5b851d98..021f199f 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessor.java @@ -6,12 +6,12 @@ import tools.mdsd.mocore.framework.processor.Processor; public class DeploymentProcessor extends Processor { - public DeploymentProcessor(PcmSurrogate model) { + public DeploymentProcessor(final PcmSurrogate model) { super(model, Deployment.class); } @Override - protected void refine(Deployment discovery) { + protected void refine(final Deployment discovery) { // No refinement needed when adding a deployment element } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/InterfaceProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/InterfaceProcessor.java index fb865cd0..52eae7ed 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/InterfaceProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/InterfaceProcessor.java @@ -12,13 +12,14 @@ public class InterfaceProcessor extends Processor { private static final String PLACEHOLDER_COMPONENT_NAME_PATTERN = "%s Provider"; - public InterfaceProcessor(PcmSurrogate model) { + public InterfaceProcessor(final PcmSurrogate model) { super(model, Interface.class); } @Override - protected void refine(Interface discovery) { - List providesRelations = getModel().getByType(InterfaceProvisionRelation.class); + protected void refine(final Interface discovery) { + final List providesRelations = this.getModel() + .getByType(InterfaceProvisionRelation.class); providesRelations.removeIf(relation -> !relation.getDestination() .equals(discovery)); @@ -26,12 +27,12 @@ protected void refine(Interface discovery) { // -> If no provision relation exists yet, add a placeholder provider and relation to the // model. if (providesRelations.isEmpty()) { - String interfaceName = discovery.getValue() + final String interfaceName = discovery.getValue() .getEntityName(); - String componentName = String.format(PLACEHOLDER_COMPONENT_NAME_PATTERN, interfaceName); - Component component = Component.getNamedPlaceholder(componentName); - InterfaceProvisionRelation relation = new InterfaceProvisionRelation(component, discovery, true); - addImplication(relation); + final String componentName = String.format(PLACEHOLDER_COMPONENT_NAME_PATTERN, interfaceName); + final Component component = Component.getNamedPlaceholder(componentName); + final InterfaceProvisionRelation relation = new InterfaceProvisionRelation(component, discovery, true); + this.addImplication(relation); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessor.java index c5e630df..cbec629a 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessor.java @@ -12,24 +12,24 @@ import tools.mdsd.mocore.framework.processor.Processor; public class LinkResourceSpecificationProcessor extends Processor { - public LinkResourceSpecificationProcessor(PcmSurrogate model) { + public LinkResourceSpecificationProcessor(final PcmSurrogate model) { super(model, LinkResourceSpecification.class); } @Override - protected void refine(LinkResourceSpecification discovery) { - List relations = this.getModel() + protected void refine(final LinkResourceSpecification discovery) { + final List relations = this.getModel() .getByType(LinkResourceSpecificationRelation.class); relations.removeIf(relation -> !Objects.equals(relation.getSource(), discovery)); if (relations.isEmpty()) { - Deployment sourcePlaceholder = Deployment.getUniquePlaceholder(); - Deployment destinationPlaceholder = Deployment.getUniquePlaceholder(); - DeploymentDeploymentRelation deploymentRelation = new DeploymentDeploymentRelation(sourcePlaceholder, + final Deployment sourcePlaceholder = Deployment.getUniquePlaceholder(); + final Deployment destinationPlaceholder = Deployment.getUniquePlaceholder(); + final DeploymentDeploymentRelation deploymentRelation = new DeploymentDeploymentRelation(sourcePlaceholder, destinationPlaceholder, true); - LinkResourceSpecificationRelation implicitRelation = new LinkResourceSpecificationRelation(discovery, + final LinkResourceSpecificationRelation implicitRelation = new LinkResourceSpecificationRelation(discovery, deploymentRelation, true); - addImplication(implicitRelation); + this.addImplication(implicitRelation); } } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessor.java index 204ca1ae..50fd0151 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessor.java @@ -6,12 +6,12 @@ import tools.mdsd.mocore.framework.processor.Processor; public class ServiceEffectSpecificationProcessor extends Processor { - public ServiceEffectSpecificationProcessor(PcmSurrogate model) { + public ServiceEffectSpecificationProcessor(final PcmSurrogate model) { super(model, ServiceEffectSpecification.class); } @Override - protected void refine(ServiceEffectSpecification discovery) { + protected void refine(final ServiceEffectSpecification discovery) { // TODO Evaluate whether refinement should be done for a single specification element } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessor.java index 1c635df6..29941621 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessor.java @@ -10,20 +10,22 @@ import tools.mdsd.mocore.framework.processor.Processor; public class SignatureProcessor extends Processor { - public SignatureProcessor(PcmSurrogate model) { + public SignatureProcessor(final PcmSurrogate model) { super(model, Signature.class); } @Override - protected void refine(Signature discovery) { + protected void refine(final Signature discovery) { // Add providing interface for signature if none exists - List interfaceRelations = getModel().getByType(SignatureProvisionRelation.class); + final List interfaceRelations = this.getModel() + .getByType(SignatureProvisionRelation.class); interfaceRelations.removeIf(relation -> !relation.getSource() .equals(discovery)); if (interfaceRelations.isEmpty()) { - Interface interfaceElement = Interface.getUniquePlaceholder(); - SignatureProvisionRelation relation = new SignatureProvisionRelation(discovery, interfaceElement, true); - addImplication(relation); + final Interface interfaceElement = Interface.getUniquePlaceholder(); + final SignatureProvisionRelation relation = new SignatureProvisionRelation(discovery, interfaceElement, + true); + this.addImplication(relation); } } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessor.java index 861e8a38..5750a751 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessor.java @@ -6,7 +6,7 @@ import tools.mdsd.mocore.framework.processor.RelationProcessor; public class ComponentAllocationRelationProcessor extends RelationProcessor { - public ComponentAllocationRelationProcessor(PcmSurrogate model) { + public ComponentAllocationRelationProcessor(final PcmSurrogate model) { super(model, ComponentAllocationRelation.class); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessor.java index 0cb9f753..6b4c617c 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessor.java @@ -15,80 +15,82 @@ import tools.mdsd.mocore.framework.processor.RelationProcessor; public class ComponentAssemblyRelationProcessor extends RelationProcessor { - public ComponentAssemblyRelationProcessor(PcmSurrogate model) { + public ComponentAssemblyRelationProcessor(final PcmSurrogate model) { super(model, ComponentAssemblyRelation.class); } @Override - protected void refine(ComponentAssemblyRelation discovery) { + protected void refine(final ComponentAssemblyRelation discovery) { // Identify all allocations of the providing and consuming component in the assembly - Component provider = discovery.getSource() + final Component provider = discovery.getSource() .getSource(); - Component consumer = discovery.getDestination() + final Component consumer = discovery.getDestination() .getSource(); - Interface providerConsumerInterface = discovery.getSource() + final Interface providerConsumerInterface = discovery.getSource() .getDestination(); - List providerAllocations = getAllocatedContainers(provider); - List consumerAllocations = getAllocatedContainers(consumer); + final List providerAllocations = this.getAllocatedContainers(provider); + final List consumerAllocations = this.getAllocatedContainers(consumer); // Add link between allocation containers of assembled components if needed if (providerAllocations.isEmpty()) { - Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation allocation = new ComponentAllocationRelation(provider, placeholderDeployment, - true); + final Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation allocation = new ComponentAllocationRelation(provider, + placeholderDeployment, true); providerAllocations.add(placeholderDeployment); this.addImplication(allocation); } if (consumerAllocations.isEmpty()) { - Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation allocation = new ComponentAllocationRelation(consumer, placeholderDeployment, - true); + final Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation allocation = new ComponentAllocationRelation(consumer, + placeholderDeployment, true); consumerAllocations.add(placeholderDeployment); this.addImplication(allocation); } - for (Deployment providerContainer : providerAllocations) { - for (Deployment consumerContainer : consumerAllocations) { + for (final Deployment providerContainer : providerAllocations) { + for (final Deployment consumerContainer : consumerAllocations) { if (!providerContainer.equals(consumerContainer)) { // Connect every providing container with each consuming one, except they are // the same container - DeploymentDeploymentRelation containerLink = new DeploymentDeploymentRelation(providerContainer, - consumerContainer, true); + final DeploymentDeploymentRelation containerLink = new DeploymentDeploymentRelation( + providerContainer, consumerContainer, true); this.addImplication(containerLink); } } } // Remove component assembly fully-placeholder relation (non-direct & non-indirect) - List assemblies = this.getModel() + final List assemblies = this.getModel() .getByType(ComponentAssemblyRelation.class); assemblies.removeIf(assembly -> !assembly.getSource() .isPlaceholder() || !assembly.getDestination() .isPlaceholder()); - for (ComponentAssemblyRelation placeholderAssembly : assemblies) { + for (final ComponentAssemblyRelation placeholderAssembly : assemblies) { if (discovery.equals(placeholderAssembly)) { continue; } - Component source = placeholderAssembly.getSource() + final Component source = placeholderAssembly.getSource() .getSource(); - Component destination = placeholderAssembly.getDestination() + final Component destination = placeholderAssembly.getDestination() .getSource(); - Interface sourceDestinationInterface = placeholderAssembly.getSource() + final Interface sourceDestinationInterface = placeholderAssembly.getSource() .getDestination(); // Placeholder are unique and can only be allocated to a single container - Optional optionalSourceContainer = getAllocatedContainers(source).stream() + final Optional optionalSourceContainer = this.getAllocatedContainers(source) + .stream() .findFirst(); - Optional optionalDestinationContainer = getAllocatedContainers(destination).stream() + final Optional optionalDestinationContainer = this.getAllocatedContainers(destination) + .stream() .findFirst(); if (optionalSourceContainer.isPresent() && optionalDestinationContainer.isPresent()) { - Deployment sourceContainer = optionalSourceContainer.get(); - Deployment destinationContainer = optionalDestinationContainer.get(); + final Deployment sourceContainer = optionalSourceContainer.get(); + final Deployment destinationContainer = optionalDestinationContainer.get(); // Container links are bi-directional => Parallel or inverse assemblies are valid - boolean isParallelAssembly = providerAllocations.contains(sourceContainer) + final boolean isParallelAssembly = providerAllocations.contains(sourceContainer) && consumerAllocations.contains(destinationContainer); - boolean isInverseAssembly = providerAllocations.contains(destinationContainer) + final boolean isInverseAssembly = providerAllocations.contains(destinationContainer) && consumerAllocations.contains(sourceContainer); if (isParallelAssembly || isInverseAssembly) { this.addImplications(this.getModel() @@ -106,8 +108,8 @@ protected void refine(ComponentAssemblyRelation discovery) { super.refine(discovery); } - private List getAllocatedContainers(Component component) { - List allocations = this.getModel() + private List getAllocatedContainers(final Component component) { + final List allocations = this.getModel() .getByType(ComponentAllocationRelation.class); return allocations.stream() .filter(allocation -> allocation.getSource() diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java index 72fcd9cf..36382b3a 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java @@ -7,7 +7,7 @@ public class ComponentSignatureProvisionRelationProcessor extends RelationProcessor { - public ComponentSignatureProvisionRelationProcessor(PcmSurrogate model) { + public ComponentSignatureProvisionRelationProcessor(final PcmSurrogate model) { super(model, ComponentSignatureProvisionRelation.class); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java index 2b58e65c..0bc6a4fd 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java @@ -12,24 +12,25 @@ public class CompositeProvisionDelegationRelationProcessor extends RelationProcessor { - public CompositeProvisionDelegationRelationProcessor(PcmSurrogate model) { + public CompositeProvisionDelegationRelationProcessor(final PcmSurrogate model) { super(model, CompositeProvisionDelegationRelation.class); } @Override - protected void refine(CompositeProvisionDelegationRelation discovery) { - Composite discoveryComposite = (Composite) discovery.getSource() + protected void refine(final CompositeProvisionDelegationRelation discovery) { + final Composite discoveryComposite = (Composite) discovery.getSource() .getSource(); - Component discoveryChild = discovery.getDestination() + final Component discoveryChild = discovery.getDestination() .getSource(); // Check if the sub-component is part of the composite already - List compositions = getModel().getByType(CompositionRelation.class); + final List compositions = this.getModel() + .getByType(CompositionRelation.class); compositions.removeIf(relation -> !discoveryComposite.equals(relation.getSource())); compositions.removeIf(relation -> !discoveryChild.equals(relation.getDestination())); if (compositions.isEmpty()) { - CompositionRelation composition = new CompositionRelation(discoveryComposite, discoveryChild, true); - addImplication(composition); + final CompositionRelation composition = new CompositionRelation(discoveryComposite, discoveryChild, true); + this.addImplication(composition); } super.refine(discovery); diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java index 8490eeb6..6ed1b6a5 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java @@ -12,24 +12,25 @@ public class CompositeRequirementDelegationRelationProcessor extends RelationProcessor { - public CompositeRequirementDelegationRelationProcessor(PcmSurrogate model) { + public CompositeRequirementDelegationRelationProcessor(final PcmSurrogate model) { super(model, CompositeRequirementDelegationRelation.class); } @Override - protected void refine(CompositeRequirementDelegationRelation discovery) { - Composite discoveryComposite = (Composite) discovery.getSource() + protected void refine(final CompositeRequirementDelegationRelation discovery) { + final Composite discoveryComposite = (Composite) discovery.getSource() .getSource(); - Component discoveryChild = discovery.getDestination() + final Component discoveryChild = discovery.getDestination() .getSource(); // Check if the sub-component is part of the composite already - List compositions = getModel().getByType(CompositionRelation.class); + final List compositions = this.getModel() + .getByType(CompositionRelation.class); compositions.removeIf(relation -> !discoveryComposite.equals(relation.getSource())); compositions.removeIf(relation -> !discoveryChild.equals(relation.getDestination())); if (compositions.isEmpty()) { - CompositionRelation composition = new CompositionRelation(discoveryComposite, discoveryChild, true); - addImplication(composition); + final CompositionRelation composition = new CompositionRelation(discoveryComposite, discoveryChild, true); + this.addImplication(composition); } super.refine(discovery); diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessor.java index 685b7c7d..b581c240 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessor.java @@ -6,7 +6,7 @@ import tools.mdsd.mocore.framework.processor.RelationProcessor; public class CompositionRelationProcessor extends RelationProcessor { - public CompositionRelationProcessor(PcmSurrogate model) { + public CompositionRelationProcessor(final PcmSurrogate model) { super(model, CompositionRelation.class); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java index c2ef920f..90ed13ed 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java @@ -12,21 +12,21 @@ public class DeploymentDeploymentRelationProcessor extends RelationProcessor { - public DeploymentDeploymentRelationProcessor(PcmSurrogate model) { + public DeploymentDeploymentRelationProcessor(final PcmSurrogate model) { super(model, DeploymentDeploymentRelation.class); } @Override - protected void refine(DeploymentDeploymentRelation discovery) { + protected void refine(final DeploymentDeploymentRelation discovery) { // Check whether a linking resource specification already exists for the link to be merged - List specifications = this.getModel() + final List specifications = this.getModel() .getByType(LinkResourceSpecificationRelation.class); specifications.removeIf(specification -> !Objects.equals(discovery, specification.getDestination())); if (specifications.isEmpty()) { // Add implicit placeholder specification, if no specification is found for this // deployment link - LinkResourceSpecification placeholderSpecification = LinkResourceSpecification.getUniquePlaceholder(); - LinkResourceSpecificationRelation implicitRelation = new LinkResourceSpecificationRelation( + final LinkResourceSpecification placeholderSpecification = LinkResourceSpecification.getUniquePlaceholder(); + final LinkResourceSpecificationRelation implicitRelation = new LinkResourceSpecificationRelation( placeholderSpecification, discovery, true); this.addImplication(implicitRelation); } @@ -35,7 +35,7 @@ protected void refine(DeploymentDeploymentRelation discovery) { } @Override - protected void replaceIndirectPlaceholders(DeploymentDeploymentRelation discovery) { + protected void replaceIndirectPlaceholders(final DeploymentDeploymentRelation discovery) { /* * TL;DR Indirect refinement of depl->depl relations is disabled because it leads to * information loss. diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessor.java index 8c8d2904..c05c3de9 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessor.java @@ -11,24 +11,24 @@ import tools.mdsd.mocore.framework.processor.RelationProcessor; public class InterfaceProvisionRelationProcessor extends RelationProcessor { - public InterfaceProvisionRelationProcessor(PcmSurrogate model) { + public InterfaceProvisionRelationProcessor(final PcmSurrogate model) { super(model, InterfaceProvisionRelation.class); } @Override - protected void refine(InterfaceProvisionRelation discovery) { - Interface commonInterface = discovery.getDestination(); + protected void refine(final InterfaceProvisionRelation discovery) { + final Interface commonInterface = discovery.getDestination(); // Get all requirements from model & filter for same interface as in discovery - List requirementRelations = this.getModel() + final List requirementRelations = this.getModel() .getByType(InterfaceRequirementRelation.class); requirementRelations.removeIf(relation -> !relation.getDestination() .equals(commonInterface)); // Create component assembly placeholder for pairs of provision & requirement relations - for (InterfaceRequirementRelation requirementRelation : requirementRelations) { - ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(discovery, requirementRelation, - true); + for (final InterfaceRequirementRelation requirementRelation : requirementRelations) { + final ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(discovery, + requirementRelation, true); this.addImplication(assemblyRelation); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessor.java index 4ad9ab4d..31f3d9b0 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessor.java @@ -12,24 +12,24 @@ public class InterfaceRequirementRelationProcessor extends RelationProcessor { - public InterfaceRequirementRelationProcessor(PcmSurrogate model) { + public InterfaceRequirementRelationProcessor(final PcmSurrogate model) { super(model, InterfaceRequirementRelation.class); } @Override - protected void refine(InterfaceRequirementRelation discovery) { - Interface commonInterface = discovery.getDestination(); + protected void refine(final InterfaceRequirementRelation discovery) { + final Interface commonInterface = discovery.getDestination(); // Get all requirements from model & filter for same interface as in discovery - List provisionRelations = this.getModel() + final List provisionRelations = this.getModel() .getByType(InterfaceProvisionRelation.class); provisionRelations.removeIf(relation -> !relation.getDestination() .equals(commonInterface)); // Create component assembly placeholder for pairs of provision & requirement relations - for (InterfaceProvisionRelation provisionRelation : provisionRelations) { - ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, discovery, - true); + for (final InterfaceProvisionRelation provisionRelation : provisionRelations) { + final ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, + discovery, true); this.addImplication(assemblyRelation); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java index 6315201e..a72cdb33 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java @@ -7,7 +7,7 @@ public class LinkResourceSpecificationRelationProcessor extends RelationProcessor { - public LinkResourceSpecificationRelationProcessor(PcmSurrogate model) { + public LinkResourceSpecificationRelationProcessor(final PcmSurrogate model) { super(model, LinkResourceSpecificationRelation.class); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java index 7e465069..140637e8 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java @@ -7,7 +7,7 @@ public class ServiceEffectSpecificationRelationProcessor extends RelationProcessor { - public ServiceEffectSpecificationRelationProcessor(PcmSurrogate model) { + public ServiceEffectSpecificationRelationProcessor(final PcmSurrogate model) { super(model, ServiceEffectSpecificationRelation.class); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessor.java index d6e2a5a9..5e9a66e3 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessor.java @@ -6,7 +6,7 @@ import tools.mdsd.mocore.framework.processor.RelationProcessor; public class SignatureProvisionRelationProcessor extends RelationProcessor { - public SignatureProvisionRelationProcessor(PcmSurrogate model) { + public SignatureProvisionRelationProcessor(final PcmSurrogate model) { super(model, SignatureProvisionRelation.class); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponent.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponent.java index 8a8ba6c6..ab380d72 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponent.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponent.java @@ -4,19 +4,19 @@ import org.palladiosimulator.pcm.repository.BasicComponent; public class AtomicComponent extends Component { - public AtomicComponent(BasicComponent value, boolean isPlaceholder) { + public AtomicComponent(final BasicComponent value, final boolean isPlaceholder) { super(value, isPlaceholder); } - public static AtomicComponent getNamedPlaceholder(String name) { - BasicComponent value = new FluentRepositoryFactory().newBasicComponent() + public static AtomicComponent getNamedPlaceholder(final String name) { + final BasicComponent value = new FluentRepositoryFactory().newBasicComponent() .withName(name) .build(); return new AtomicComponent(value, true); } public static AtomicComponent getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); + final String identifier = "Placeholder_" + getUniqueValue(); return getNamedPlaceholder(identifier); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Component.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Component.java index c6463032..8cdf6087 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Component.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Component.java @@ -3,11 +3,11 @@ import org.palladiosimulator.pcm.repository.RepositoryComponent; public class Component extends PcmElement { - public Component(T value, boolean isPlaceholder) { + public Component(final T value, final boolean isPlaceholder) { super(value, isPlaceholder); } - public static Component getNamedPlaceholder(String name) { + public static Component getNamedPlaceholder(final String name) { return AtomicComponent.getNamedPlaceholder(name); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Composite.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Composite.java index e2e924de..d20fccf9 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Composite.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Composite.java @@ -5,13 +5,13 @@ import org.palladiosimulator.pcm.repository.RepositoryComponent; public class Composite extends Component { - public Composite(CompositeComponent value, boolean isPlaceholder) { + public Composite(final CompositeComponent value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static Composite getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() + final String identifier = "Placeholder_" + getUniqueValue(); + final RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() .withName(identifier) .build(); return new Composite((CompositeComponent) value, true); diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Deployment.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Deployment.java index a91a119e..37b94f43 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Deployment.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Deployment.java @@ -4,13 +4,13 @@ import org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentFactory; public class Deployment extends PcmElement { - public Deployment(ResourceContainer value, boolean isPlaceholder) { + public Deployment(final ResourceContainer value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static Deployment getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); + final String identifier = "Placeholder_" + getUniqueValue(); + final ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); value.setEntityName(identifier); return new Deployment(value, true); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Interface.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Interface.java index 6078747a..b6e8889a 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Interface.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Interface.java @@ -4,13 +4,13 @@ import org.palladiosimulator.pcm.repository.OperationInterface; public class Interface extends PcmElement { - public Interface(OperationInterface value, boolean isPlaceholder) { + public Interface(final OperationInterface value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static Interface getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - OperationInterface value = new FluentRepositoryFactory().newOperationInterface() + final String identifier = "Placeholder_" + getUniqueValue(); + final OperationInterface value = new FluentRepositoryFactory().newOperationInterface() .withName(identifier) .build(); return new Interface(value, true); diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecification.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecification.java index 4d446a2c..93e75a4e 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecification.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecification.java @@ -4,15 +4,15 @@ import org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentFactory; public class LinkResourceSpecification extends PcmElement { - public LinkResourceSpecification(CommunicationLinkResourceSpecification value, boolean isPlaceholder) { + public LinkResourceSpecification(final CommunicationLinkResourceSpecification value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static LinkResourceSpecification getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - double failureProbability = 0D; + final String identifier = "Placeholder_" + getUniqueValue(); + final double failureProbability = 0D; - CommunicationLinkResourceSpecification value = ResourceenvironmentFactory.eINSTANCE + final CommunicationLinkResourceSpecification value = ResourceenvironmentFactory.eINSTANCE .createCommunicationLinkResourceSpecification(); value.setId(identifier); value.setFailureProbability(failureProbability); diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/PcmElement.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/PcmElement.java index b738bfdc..ba395a71 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/PcmElement.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/PcmElement.java @@ -6,29 +6,31 @@ import tools.mdsd.mocore.framework.surrogate.Element; public abstract class PcmElement extends Element { - protected PcmElement(T value, boolean isPlaceholder) { + protected PcmElement(final T value, final boolean isPlaceholder) { super(value, isPlaceholder); } public String getIdentifier() { - return getValue().getId(); + return this.getValue() + .getId(); } @Override public int hashCode() { - String wrappedIdentifier = getValue().getId(); + final String wrappedIdentifier = this.getValue() + .getId(); return Objects.hash(this.isPlaceholder(), wrappedIdentifier); } @Override - public boolean equals(Object object) { + public boolean equals(final Object object) { if (this == object) { return true; } if (object == null || this.getClass() != object.getClass()) { return false; } - PcmElement element = (PcmElement) object; + final PcmElement element = (PcmElement) object; return Objects.equals(this.getIdentifier(), element.getIdentifier()) && (this.isPlaceholder() == element.isPlaceholder()); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecification.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecification.java index 78be9ca7..90d60d4a 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecification.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecification.java @@ -4,12 +4,12 @@ import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; public class ServiceEffectSpecification extends PcmElement { - public ServiceEffectSpecification(ResourceDemandingSEFF value, boolean isPlaceholder) { + public ServiceEffectSpecification(final ResourceDemandingSEFF value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static ServiceEffectSpecification getUniquePlaceholder() { - ResourceDemandingSEFF value = new FluentRepositoryFactory().newSeff() + final ResourceDemandingSEFF value = new FluentRepositoryFactory().newSeff() .withSeffBehaviour() .withStartAction() .followedBy() diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Signature.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Signature.java index 239cdd8c..30a8cba2 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Signature.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Signature.java @@ -4,13 +4,13 @@ import org.palladiosimulator.pcm.repository.RepositoryFactory; public class Signature extends PcmElement { - public Signature(OperationSignature value, boolean isPlaceholder) { + public Signature(final OperationSignature value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static Signature getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); + final String identifier = "Placeholder_" + getUniqueValue(); + final OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); value.setEntityName(identifier); return new Signature(value, true); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelation.java index 517bb17a..504e3395 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelation.java @@ -7,12 +7,13 @@ import tools.mdsd.mocore.framework.surrogate.Replaceable; public class ComponentAllocationRelation extends Relation, Deployment> { - public ComponentAllocationRelation(Component source, Deployment destination, boolean isPlaceholder) { + public ComponentAllocationRelation(final Component source, final Deployment destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public ComponentAllocationRelation replace(U original, U replacement) { + public ComponentAllocationRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +21,8 @@ public ComponentAllocationRelation replace(U original, U if (this.equals(original)) { return (ComponentAllocationRelation) replacement; } - Component source = getSourceReplacement(original, replacement); - Deployment destination = getDestinationReplacement(original, replacement); + final Component source = this.getSourceReplacement(original, replacement); + final Deployment destination = this.getDestinationReplacement(original, replacement); return new ComponentAllocationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelation.java index 1118b475..a40ede21 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelation.java @@ -8,8 +8,8 @@ public class ComponentAssemblyRelation extends Relation { private static final String ERROR_UNEQUAL_INTERFACE = "Interfaces of relations have to be equal."; - public ComponentAssemblyRelation(InterfaceProvisionRelation source, InterfaceRequirementRelation destination, - boolean isPlaceholder) { + public ComponentAssemblyRelation(final InterfaceProvisionRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); if (!Objects.equals(source.getDestination(), destination.getDestination())) { throw new IllegalArgumentException(ERROR_UNEQUAL_INTERFACE); @@ -17,7 +17,7 @@ public ComponentAssemblyRelation(InterfaceProvisionRelation source, InterfaceReq } @Override - public ComponentAssemblyRelation replace(U original, U replacement) { + public ComponentAssemblyRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -25,8 +25,8 @@ public ComponentAssemblyRelation replace(U original, U r if (this.equals(original)) { return (ComponentAssemblyRelation) replacement; } - InterfaceProvisionRelation source = getSourceReplacement(original, replacement); - InterfaceRequirementRelation destination = getDestinationReplacement(original, replacement); + final InterfaceProvisionRelation source = this.getSourceReplacement(original, replacement); + final InterfaceRequirementRelation destination = this.getDestinationReplacement(original, replacement); return new ComponentAssemblyRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java index c979a3ed..f6e32a8a 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java @@ -9,8 +9,8 @@ public class ComponentSignatureProvisionRelation extends Relation { private static final String ERROR_UNEQUAL_INTERFACE = "Interfaces of relations have to be equal."; - public ComponentSignatureProvisionRelation(InterfaceProvisionRelation source, - SignatureProvisionRelation destination, boolean isPlaceholder) { + public ComponentSignatureProvisionRelation(final InterfaceProvisionRelation source, + final SignatureProvisionRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); if (!Objects.equals(source.getDestination(), destination.getDestination())) { throw new IllegalArgumentException(ERROR_UNEQUAL_INTERFACE); @@ -18,7 +18,7 @@ public ComponentSignatureProvisionRelation(InterfaceProvisionRelation source, } @Override - public ComponentSignatureProvisionRelation replace(U original, U replacement) { + public ComponentSignatureProvisionRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -26,8 +26,8 @@ public ComponentSignatureProvisionRelation replace(U ori if (this.equals(original)) { return (ComponentSignatureProvisionRelation) replacement; } - InterfaceProvisionRelation source = getSourceReplacement(original, replacement); - SignatureProvisionRelation destination = getDestinationReplacement(original, replacement); + final InterfaceProvisionRelation source = this.getSourceReplacement(original, replacement); + final SignatureProvisionRelation destination = this.getDestinationReplacement(original, replacement); return new ComponentSignatureProvisionRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java index d9538a17..da5fce14 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java @@ -11,8 +11,8 @@ public class CompositeProvisionDelegationRelation private static final String ERROR_SAME_RELATION = "Delegations may not exist between equal source and destination."; private static final String ERROR_NON_EQUAL_INTERFACES = "Interfaces of the given relations must be equal."; - public CompositeProvisionDelegationRelation(InterfaceProvisionRelation source, - InterfaceProvisionRelation destination, boolean isPlaceholder) { + public CompositeProvisionDelegationRelation(final InterfaceProvisionRelation source, + final InterfaceProvisionRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); // Check whether relations are equal @@ -35,7 +35,7 @@ public CompositeProvisionDelegationRelation(InterfaceProvisionRelation source, } @Override - public CompositeProvisionDelegationRelation replace(T original, T replacement) { + public CompositeProvisionDelegationRelation replace(final T original, final T replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -43,8 +43,8 @@ public CompositeProvisionDelegationRelation replace(T or if (this.equals(original)) { return (CompositeProvisionDelegationRelation) replacement; } - InterfaceProvisionRelation source = getSourceReplacement(original, replacement); - InterfaceProvisionRelation destination = getDestinationReplacement(original, replacement); + final InterfaceProvisionRelation source = this.getSourceReplacement(original, replacement); + final InterfaceProvisionRelation destination = this.getDestinationReplacement(original, replacement); return new CompositeProvisionDelegationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java index 46839aa0..63a2d7f7 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java @@ -11,8 +11,8 @@ public class CompositeRequirementDelegationRelation private static final String ERROR_SAME_RELATION = "Delegations may not exist between equal source and destination."; private static final String ERROR_NON_EQUAL_INTERFACES = "Interfaces of the given relations must be equal."; - public CompositeRequirementDelegationRelation(InterfaceRequirementRelation source, - InterfaceRequirementRelation destination, boolean isPlaceholder) { + public CompositeRequirementDelegationRelation(final InterfaceRequirementRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); // Check whether relations are equal @@ -35,7 +35,8 @@ public CompositeRequirementDelegationRelation(InterfaceRequirementRelation sourc } @Override - public CompositeRequirementDelegationRelation replace(T original, T replacement) { + public CompositeRequirementDelegationRelation replace(final T original, + final T replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -43,8 +44,8 @@ public CompositeRequirementDelegationRelation replace(T if (this.equals(original)) { return (CompositeRequirementDelegationRelation) replacement; } - InterfaceRequirementRelation source = getSourceReplacement(original, replacement); - InterfaceRequirementRelation destination = getDestinationReplacement(original, replacement); + final InterfaceRequirementRelation source = this.getSourceReplacement(original, replacement); + final InterfaceRequirementRelation destination = this.getDestinationReplacement(original, replacement); return new CompositeRequirementDelegationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelation.java index 52e3382d..8c33e5c1 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelation.java @@ -7,12 +7,12 @@ import tools.mdsd.mocore.framework.surrogate.Replaceable; public class CompositionRelation extends Relation> { - public CompositionRelation(Composite source, Component destination, boolean isPlaceholder) { + public CompositionRelation(final Composite source, final Component destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public CompositionRelation replace(T original, T replacement) { + public CompositionRelation replace(final T original, final T replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +20,8 @@ public CompositionRelation replace(T original, T replace if (this.equals(original)) { return (CompositionRelation) replacement; } - Composite source = getSourceReplacement(original, replacement); - Component destination = getDestinationReplacement(original, replacement); + final Composite source = this.getSourceReplacement(original, replacement); + final Component destination = this.getDestinationReplacement(original, replacement); return new CompositionRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelation.java index 9d60478e..f9fba80b 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelation.java @@ -6,12 +6,13 @@ import tools.mdsd.mocore.framework.surrogate.Replaceable; public class DeploymentDeploymentRelation extends Relation { - public DeploymentDeploymentRelation(Deployment source, Deployment destination, boolean isPlaceholder) { + public DeploymentDeploymentRelation(final Deployment source, final Deployment destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public DeploymentDeploymentRelation replace(U original, U replacement) { + public DeploymentDeploymentRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -19,8 +20,8 @@ public DeploymentDeploymentRelation replace(U original, if (this.equals(original)) { return (DeploymentDeploymentRelation) replacement; } - Deployment source = getSourceReplacement(original, replacement); - Deployment destination = getDestinationReplacement(original, replacement); + final Deployment source = this.getSourceReplacement(original, replacement); + final Deployment destination = this.getDestinationReplacement(original, replacement); return new DeploymentDeploymentRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelation.java index ca75e8cd..44fc65f9 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelation.java @@ -7,12 +7,13 @@ import tools.mdsd.mocore.framework.surrogate.Replaceable; public class InterfaceProvisionRelation extends Relation, Interface> { - public InterfaceProvisionRelation(Component source, Interface destination, boolean isPlaceholder) { + public InterfaceProvisionRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public InterfaceProvisionRelation replace(U original, U replacement) { + public InterfaceProvisionRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +21,8 @@ public InterfaceProvisionRelation replace(U original, U if (this.equals(original)) { return (InterfaceProvisionRelation) replacement; } - Component source = getSourceReplacement(original, replacement); - Interface destination = getDestinationReplacement(original, replacement); + final Component source = this.getSourceReplacement(original, replacement); + final Interface destination = this.getDestinationReplacement(original, replacement); return new InterfaceProvisionRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelation.java index b53bc5f8..41ea1845 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelation.java @@ -7,12 +7,13 @@ import tools.mdsd.mocore.framework.surrogate.Replaceable; public class InterfaceRequirementRelation extends Relation, Interface> { - public InterfaceRequirementRelation(Component source, Interface destination, boolean isPlaceholder) { + public InterfaceRequirementRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public InterfaceRequirementRelation replace(U original, U replacement) { + public InterfaceRequirementRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +21,8 @@ public InterfaceRequirementRelation replace(U original, if (this.equals(original)) { return (InterfaceRequirementRelation) replacement; } - Component source = getSourceReplacement(original, replacement); - Interface destination = getDestinationReplacement(original, replacement); + final Component source = this.getSourceReplacement(original, replacement); + final Interface destination = this.getDestinationReplacement(original, replacement); return new InterfaceRequirementRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelation.java index cb428f81..7ef0d41d 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelation.java @@ -7,13 +7,13 @@ public class LinkResourceSpecificationRelation extends Relation { - public LinkResourceSpecificationRelation(LinkResourceSpecification source, DeploymentDeploymentRelation destination, - boolean isPlaceholder) { + public LinkResourceSpecificationRelation(final LinkResourceSpecification source, + final DeploymentDeploymentRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public LinkResourceSpecificationRelation replace(U original, U replacement) { + public LinkResourceSpecificationRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -21,8 +21,8 @@ public LinkResourceSpecificationRelation replace(U origi if (this.equals(original)) { return (LinkResourceSpecificationRelation) replacement; } - LinkResourceSpecification source = getSourceReplacement(original, replacement); - DeploymentDeploymentRelation destination = getDestinationReplacement(original, replacement); + final LinkResourceSpecification source = this.getSourceReplacement(original, replacement); + final DeploymentDeploymentRelation destination = this.getDestinationReplacement(original, replacement); return new LinkResourceSpecificationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java index fa97d23c..2300af9d 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java @@ -7,13 +7,13 @@ public class ServiceEffectSpecificationRelation extends Relation { - public ServiceEffectSpecificationRelation(ComponentSignatureProvisionRelation source, - ServiceEffectSpecification destination, boolean isPlaceholder) { + public ServiceEffectSpecificationRelation(final ComponentSignatureProvisionRelation source, + final ServiceEffectSpecification destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public ServiceEffectSpecificationRelation replace(U original, U replacement) { + public ServiceEffectSpecificationRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -21,8 +21,8 @@ public ServiceEffectSpecificationRelation replace(U orig if (this.equals(original)) { return (ServiceEffectSpecificationRelation) replacement; } - ComponentSignatureProvisionRelation source = getSourceReplacement(original, replacement); - ServiceEffectSpecification destination = getDestinationReplacement(original, replacement); + final ComponentSignatureProvisionRelation source = this.getSourceReplacement(original, replacement); + final ServiceEffectSpecification destination = this.getDestinationReplacement(original, replacement); return new ServiceEffectSpecificationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelation.java index 778d799d..adb8bc2a 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelation.java @@ -7,12 +7,13 @@ import tools.mdsd.mocore.framework.surrogate.Replaceable; public class SignatureProvisionRelation extends Relation { - public SignatureProvisionRelation(Signature source, Interface destination, boolean isPlaceholder) { + public SignatureProvisionRelation(final Signature source, final Interface destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public SignatureProvisionRelation replace(U original, U replacement) { + public SignatureProvisionRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +21,8 @@ public SignatureProvisionRelation replace(U original, U if (this.equals(original)) { return (SignatureProvisionRelation) replacement; } - Signature source = getSourceReplacement(original, replacement); - Interface destination = getDestinationReplacement(original, replacement); + final Signature source = this.getSourceReplacement(original, replacement); + final Interface destination = this.getDestinationReplacement(original, replacement); return new SignatureProvisionRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformer.java index c4ac17c7..908974b1 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformer.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformer.java @@ -15,36 +15,37 @@ public class AllocationTransformer implements Transformer { @Override - public Allocation transform(PcmSurrogate model) { - System system = new SystemTransformer().transform(model); - ResourceEnvironment resourceEnvironment = new ResourceEnvironmentTransformer().transform(model); + public Allocation transform(final PcmSurrogate model) { + final System system = new SystemTransformer().transform(model); + final ResourceEnvironment resourceEnvironment = new ResourceEnvironmentTransformer().transform(model); return this.transform(model, system, resourceEnvironment); } - public Allocation transform(PcmSurrogate model, System system, ResourceEnvironment resourceEnvironment) { - FluentAllocationFactory allocationFactory = new FluentAllocationFactory(); - IAllocationAddition fluentAllocation = allocationFactory.newAllocation() + public Allocation transform(final PcmSurrogate model, final System system, + final ResourceEnvironment resourceEnvironment) { + final FluentAllocationFactory allocationFactory = new FluentAllocationFactory(); + final IAllocationAddition fluentAllocation = allocationFactory.newAllocation() .withSystem(system) .withResourceEnvironment(resourceEnvironment); // Add allocation contexts to allocation - List relations = model.getByType(ComponentAllocationRelation.class); - for (ComponentAllocationRelation relation : relations) { + final List relations = model.getByType(ComponentAllocationRelation.class); + for (final ComponentAllocationRelation relation : relations) { // Get and add context (creator) for specific allocation relation - AllocationContextCreator contextCreator = getCreator(allocationFactory, relation); + final AllocationContextCreator contextCreator = this.getCreator(allocationFactory, relation); fluentAllocation.addToAllocation(contextCreator); } return fluentAllocation.createAllocationNow(); } - private AllocationContextCreator getCreator(FluentAllocationFactory fluentFactory, - ComponentAllocationRelation relation) { - AllocationContextCreator contextCreator = fluentFactory.newAllocationContext(); + private AllocationContextCreator getCreator(final FluentAllocationFactory fluentFactory, + final ComponentAllocationRelation relation) { + final AllocationContextCreator contextCreator = fluentFactory.newAllocationContext(); // Use name of entities to fetch up-to-date entities from system and resource environment - String assemblyContextName = SystemTransformer.getAssemblyContextName(relation.getSource()); - String deploymentEntityName = relation.getDestination() + final String assemblyContextName = SystemTransformer.getAssemblyContextName(relation.getSource()); + final String deploymentEntityName = relation.getDestination() .getValue() .getEntityName(); contextCreator.withAssemblyContext(assemblyContextName) diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformer.java index 6a81168b..7fde0d43 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformer.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformer.java @@ -60,33 +60,34 @@ public class RepositoryTransformer implements Transformer seffRelations = model + final List seffRelations = model .getByType(ServiceEffectSpecificationRelation.class); List provisionRelations = model.getByType(InterfaceProvisionRelation.class); - List requirementRelations = model.getByType(InterfaceRequirementRelation.class); - List signatureRelations = model.getByType(SignatureProvisionRelation.class); - List interfaces = model.getByType(Interface.class); + final List requirementRelations = model + .getByType(InterfaceRequirementRelation.class); + final List signatureRelations = model.getByType(SignatureProvisionRelation.class); + final List interfaces = model.getByType(Interface.class); // Add interfaces to fluent repository - for (Interface interfaceInstance : interfaces) { - OperationInterfaceCreator interfaceCreator = getCreator(repositoryFactory, interfaceInstance); + for (final Interface interfaceInstance : interfaces) { + final OperationInterfaceCreator interfaceCreator = this.getCreator(repositoryFactory, interfaceInstance); // Add interface to repository and fetch built interface fluentRepository.addToRepository(interfaceCreator); - OperationInterface repositoryInterface = repositoryFactory + final OperationInterface repositoryInterface = repositoryFactory .fetchOfOperationInterface(interfaceInstance.getValue() .getEntityName()); // Add signatures to the added interface directly // Avoids the creation of signature creator and tight coupling to fluentApi - for (SignatureProvisionRelation relation : signatureRelations) { + for (final SignatureProvisionRelation relation : signatureRelations) { if (relation.getDestination() .equals(interfaceInstance)) { - Signature signature = relation.getSource(); + final Signature signature = relation.getSource(); signature.getValue() .setInterface__OperationSignature(repositoryInterface); } @@ -94,49 +95,51 @@ public Repository transform(PcmSurrogate model) { } // Add basic components with their roles and seff to fluent repository - for (AtomicComponent component : model.getByType(AtomicComponent.class)) { - BasicComponentCreator componentCreator = getCreator(repositoryFactory, component); + for (final AtomicComponent component : model.getByType(AtomicComponent.class)) { + final BasicComponentCreator componentCreator = this.getCreator(repositoryFactory, component); // Add provided interfaces - for (InterfaceProvisionRelation relation : provisionRelations) { - Interface interfaceInstance = relation.getDestination(); + for (final InterfaceProvisionRelation relation : provisionRelations) { + final Interface interfaceInstance = relation.getDestination(); if (relation.getSource() .equals(component)) { - String interfaceName = interfaceInstance.getValue() + final String interfaceName = interfaceInstance.getValue() .getEntityName(); - OperationInterface operationInterface = repositoryFactory.fetchOfOperationInterface(interfaceName); + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceName); componentCreator.provides(operationInterface, getProvidedRoleName(interfaceInstance)); } } // Add required interfaces - for (InterfaceRequirementRelation relation : requirementRelations) { - Interface interfaceInstance = relation.getDestination(); + for (final InterfaceRequirementRelation relation : requirementRelations) { + final Interface interfaceInstance = relation.getDestination(); if (relation.getSource() .equals(component)) { - String interfaceName = interfaceInstance.getValue() + final String interfaceName = interfaceInstance.getValue() .getEntityName(); - OperationInterface operationInterface = repositoryFactory.fetchOfOperationInterface(interfaceName); + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceName); componentCreator.requires(operationInterface, getRequiredRoleName(interfaceInstance)); } } // Build component to make changes that are unsupported by fluent api - BasicComponent repositoryComponent = componentCreator.build(); + final BasicComponent repositoryComponent = componentCreator.build(); // Add service effect specifications to component // For each provided interface, iterate over each signature of interface and add seff if // it exists - for (InterfaceProvisionRelation interfaceProvision : provisionRelations) { + for (final InterfaceProvisionRelation interfaceProvision : provisionRelations) { if (interfaceProvision.getSource() .equals(component)) { - OperationInterface operationInterface = repositoryFactory + final OperationInterface operationInterface = repositoryFactory .fetchOfOperationInterface(interfaceProvision.getDestination() .getValue() .getEntityName()); - for (OperationSignature signature : operationInterface.getSignatures__OperationInterface()) { + for (final OperationSignature signature : operationInterface.getSignatures__OperationInterface()) { // Get seff entity for specific signature in interface - Predicate filter = relation -> { + final Predicate filter = relation -> { final Signature wrappedSignature = relation.getSource() .getDestination() .getSource(); @@ -146,7 +149,7 @@ public Repository transform(PcmSurrogate model) { return representSameSignature(signature, wrappedSignature.getValue()) && representSameInterface(operationInterface, wrappedInterface.getValue()); }; - ServiceEffectSpecification seff = seffRelations.stream() + final ServiceEffectSpecification seff = seffRelations.stream() .filter(relation -> relation.getSource() .getSource() .getSource() @@ -165,20 +168,20 @@ public Repository transform(PcmSurrogate model) { // Fix changed identifier of required roles in external call actions if (seff instanceof ResourceDemandingSEFF) { - ResourceDemandingSEFF rdSeff = (ResourceDemandingSEFF) seff; - EList behavior = rdSeff.getSteps_Behaviour(); - List externalCallActions = behavior.stream() + final ResourceDemandingSEFF rdSeff = (ResourceDemandingSEFF) seff; + final EList behavior = rdSeff.getSteps_Behaviour(); + final List externalCallActions = behavior.stream() .filter(action -> action instanceof ExternalCallAction) .map(action -> (ExternalCallAction) action) .collect(Collectors.toList()); - for (ExternalCallAction externalCallAction : externalCallActions) { - OperationSignature externalSignature = externalCallAction + for (final ExternalCallAction externalCallAction : externalCallActions) { + final OperationSignature externalSignature = externalCallAction .getCalledService_ExternalService(); // Get required role containing called signature of // externalCallAction from component - Optional requiredRoleOption = repositoryComponent + final Optional requiredRoleOption = repositoryComponent .getRequiredRoles_InterfaceRequiringEntity() .stream() .filter(role -> role instanceof OperationRequiredRole) @@ -195,7 +198,7 @@ public Repository transform(PcmSurrogate model) { + "#" + externalSignature.getEntityName() + "!"); continue; } - OperationRequiredRole requiredRole = requiredRoleOption.get(); + final OperationRequiredRole requiredRole = requiredRoleOption.get(); // Set role in external call action to fetched required role externalCallAction.setRole_ExternalService(requiredRole); @@ -214,11 +217,11 @@ public Repository transform(PcmSurrogate model) { // Problem: This has to happen from innermost to outermost component. -> Sorted by // dependency. // First step: Get children of each composite - List compositionRelations = model.getByType(CompositionRelation.class); - List composites = model.getByType(Composite.class); - Multimap> compositesChildren = HashMultimap.create(); - for (Composite composite : composites) { - List> children = compositionRelations.stream() + final List compositionRelations = model.getByType(CompositionRelation.class); + final List composites = model.getByType(Composite.class); + final Multimap> compositesChildren = HashMultimap.create(); + for (final Composite composite : composites) { + final List> children = compositionRelations.stream() .filter(relation -> relation.getSource() .equals(composite)) .map(relation -> relation.getDestination()) @@ -226,27 +229,27 @@ public Repository transform(PcmSurrogate model) { compositesChildren.putAll(composite, children); } // Second step: Sort composites - List sortedComposites = new LinkedList<>(composites); - sortedComposites.sort((a, b) -> compareComposites(a, b, compositesChildren)); + final List sortedComposites = new LinkedList<>(composites); + sortedComposites.sort((a, b) -> this.compareComposites(a, b, compositesChildren)); // Third step: Get non-required interfaces & their providers - List nonRequiredProvisionRelations = new LinkedList<>(provisionRelations); + final List nonRequiredProvisionRelations = new LinkedList<>(provisionRelations); nonRequiredProvisionRelations.removeIf(provisionRelation -> requirementRelations.stream() .anyMatch(requirementRelation -> requirementRelation.getDestination() .equals(provisionRelation.getDestination()))); // Fourth step: Provide non-required interface of children & add delegation - for (Composite composite : sortedComposites) { + for (final Composite composite : sortedComposites) { for (int i = 0; i < nonRequiredProvisionRelations.size(); i++) { // Access via index due to concurrent modification -> New last element might be // added to list - InterfaceProvisionRelation nonRequiredProvision = nonRequiredProvisionRelations.get(i); - Component provider = nonRequiredProvision.getSource(); - Interface providedInterface = nonRequiredProvision.getDestination(); + final InterfaceProvisionRelation nonRequiredProvision = nonRequiredProvisionRelations.get(i); + final Component provider = nonRequiredProvision.getSource(); + final Interface providedInterface = nonRequiredProvision.getDestination(); // Only add if provider is direct child of composite - if (isDirectChild(provider, composite, compositesChildren)) { + if (this.isDirectChild(provider, composite, compositesChildren)) { // Check whether delegation already exists in model boolean existsDelegation = false; - for (CompositeProvisionDelegationRelation delegationRelation : model + for (final CompositeProvisionDelegationRelation delegationRelation : model .getByType(CompositeProvisionDelegationRelation.class)) { if (delegationRelation.getDestination() .equals(nonRequiredProvision) @@ -259,12 +262,12 @@ public Repository transform(PcmSurrogate model) { } // Check whether interface should be excluded from recursive delegation - boolean excludeDelegation = isExcludedFromDelegation(provider, providedInterface); + final boolean excludeDelegation = isExcludedFromDelegation(provider, providedInterface); if (!existsDelegation && !excludeDelegation) { // Check whether interface provision already exists InterfaceProvisionRelation provisionRelation = null; - for (InterfaceProvisionRelation provision : provisionRelations) { + for (final InterfaceProvisionRelation provision : provisionRelations) { if (provision.getSource() .equals(composite) && provision.getDestination() @@ -283,7 +286,7 @@ public Repository transform(PcmSurrogate model) { } // Add provided delegation connector - CompositeProvisionDelegationRelation provisionDelegation = new CompositeProvisionDelegationRelation( + final CompositeProvisionDelegationRelation provisionDelegation = new CompositeProvisionDelegationRelation( provisionRelation, nonRequiredProvision, true); model.add(provisionDelegation); } @@ -292,29 +295,31 @@ public Repository transform(PcmSurrogate model) { } // Add composite components with their roles to fluent repository - for (Composite composite : composites) { - CompositeComponentCreator compositeCreator = getCreator(repositoryFactory, composite); + for (final Composite composite : composites) { + final CompositeComponentCreator compositeCreator = this.getCreator(repositoryFactory, composite); // Add explicitly provided interfaces - for (InterfaceProvisionRelation relation : provisionRelations) { - Interface interfaceInstance = relation.getDestination(); + for (final InterfaceProvisionRelation relation : provisionRelations) { + final Interface interfaceInstance = relation.getDestination(); if (relation.getSource() .equals(composite)) { - String interfaceName = interfaceInstance.getValue() + final String interfaceName = interfaceInstance.getValue() .getEntityName(); - OperationInterface operationInterface = repositoryFactory.fetchOfOperationInterface(interfaceName); + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceName); compositeCreator.provides(operationInterface, getProvidedRoleName(interfaceInstance)); } } // Add required interfaces - for (InterfaceRequirementRelation relation : requirementRelations) { - Interface interfaceInstance = relation.getDestination(); + for (final InterfaceRequirementRelation relation : requirementRelations) { + final Interface interfaceInstance = relation.getDestination(); if (relation.getSource() .equals(composite)) { - String interfaceName = interfaceInstance.getValue() + final String interfaceName = interfaceInstance.getValue() .getEntityName(); - OperationInterface operationInterface = repositoryFactory.fetchOfOperationInterface(interfaceName); + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceName); compositeCreator.requires(operationInterface, getRequiredRoleName(interfaceInstance)); } } @@ -324,18 +329,18 @@ public Repository transform(PcmSurrogate model) { } // Add compositions to repository -> All composites & composites have to be added beforehand - for (CompositionRelation relation : compositionRelations) { - Composite composite = relation.getSource(); - Component destination = relation.getDestination(); + for (final CompositionRelation relation : compositionRelations) { + final Composite composite = relation.getSource(); + final Component destination = relation.getDestination(); // Fetch composite from repository - CompositeComponent persistedCompositeComponent = repositoryFactory + final CompositeComponent persistedCompositeComponent = repositoryFactory .fetchOfCompositeComponent(composite.getValue() .getEntityName()); persistedCompositeComponent.getAssemblyContexts__ComposedStructure(); // Fetch composite child from repository & create temporary fluent creator - CompositeComponentCreator temporaryCreator = repositoryFactory.newCompositeComponent(); + final CompositeComponentCreator temporaryCreator = repositoryFactory.newCompositeComponent(); if (destination instanceof AtomicComponent) { temporaryCreator.withAssemblyContext(repositoryFactory.fetchOfBasicComponent(destination.getValue() .getEntityName())); @@ -345,41 +350,41 @@ public Repository transform(PcmSurrogate model) { } // Copy assembly contexts from temporary to persisted composite - CompositeComponent temporaryComposite = (CompositeComponent) temporaryCreator.build(); + final CompositeComponent temporaryComposite = (CompositeComponent) temporaryCreator.build(); persistedCompositeComponent.getAssemblyContexts__ComposedStructure() .addAll(temporaryComposite.getAssemblyContexts__ComposedStructure()); } - Repository repository = fluentRepository.createRepositoryNow(); + final Repository repository = fluentRepository.createRepositoryNow(); // Add assembly connectors for assembly relations of components within same composite - for (ComponentAssemblyRelation assemblyRelation : model.getByType(ComponentAssemblyRelation.class)) { - Component provider = assemblyRelation.getSource() + for (final ComponentAssemblyRelation assemblyRelation : model.getByType(ComponentAssemblyRelation.class)) { + final Component provider = assemblyRelation.getSource() .getSource(); - Component consumer = assemblyRelation.getDestination() + final Component consumer = assemblyRelation.getDestination() .getSource(); - Interface interFace = assemblyRelation.getSource() + final Interface interFace = assemblyRelation.getSource() .getDestination(); // Get common composites of provider and consumer - List providerComposites = compositionRelations.stream() + final List providerComposites = compositionRelations.stream() .filter(relation -> relation.getDestination() .equals(provider)) .map(CompositionRelation::getSource) .collect(Collectors.toList()); - List consumerComposites = compositionRelations.stream() + final List consumerComposites = compositionRelations.stream() .filter(relation -> relation.getDestination() .equals(consumer)) .map(CompositionRelation::getSource) .collect(Collectors.toList()); - List commonComposites = providerComposites.stream() + final List commonComposites = providerComposites.stream() .filter(composite -> consumerComposites.contains(composite)) .collect(Collectors.toList()); // Get real composites of wrappers from repository - List commonRepositoryComposites = new ArrayList<>(); - for (RepositoryComponent repositoryComponent : repository.getComponents__Repository()) { - for (Composite commonComposite : commonComposites) { + final List commonRepositoryComposites = new ArrayList<>(); + for (final RepositoryComponent repositoryComponent : repository.getComponents__Repository()) { + for (final Composite commonComposite : commonComposites) { if (repositoryComponent.getEntityName() .equals(commonComposite.getValue() .getEntityName())) { @@ -389,9 +394,9 @@ public Repository transform(PcmSurrogate model) { } // Add assembly connector to each common composite - for (CompositeComponent repositoryComposite : commonRepositoryComposites) { + for (final CompositeComponent repositoryComposite : commonRepositoryComposites) { // Fetch assembly contexts from composite - AssemblyContext providerContext = repositoryComposite.getAssemblyContexts__ComposedStructure() + final AssemblyContext providerContext = repositoryComposite.getAssemblyContexts__ComposedStructure() .stream() .filter(context -> context.getEncapsulatedComponent__AssemblyContext() .getEntityName() @@ -399,7 +404,7 @@ public Repository transform(PcmSurrogate model) { .getEntityName())) .findFirst() .orElseThrow(); - AssemblyContext consumerContext = repositoryComposite.getAssemblyContexts__ComposedStructure() + final AssemblyContext consumerContext = repositoryComposite.getAssemblyContexts__ComposedStructure() .stream() .filter(context -> context.getEncapsulatedComponent__AssemblyContext() .getEntityName() @@ -409,7 +414,7 @@ public Repository transform(PcmSurrogate model) { .orElseThrow(); // Fetch roles from contexts - OperationProvidedRole providerRole = (OperationProvidedRole) providerContext + final OperationProvidedRole providerRole = (OperationProvidedRole) providerContext .getEncapsulatedComponent__AssemblyContext() .getProvidedRoles_InterfaceProvidingEntity() .stream() @@ -420,7 +425,7 @@ public Repository transform(PcmSurrogate model) { .getEntityName())) .findFirst() .orElseThrow(); - OperationRequiredRole consumerRole = (OperationRequiredRole) consumerContext + final OperationRequiredRole consumerRole = (OperationRequiredRole) consumerContext .getEncapsulatedComponent__AssemblyContext() .getRequiredRoles_InterfaceRequiringEntity() .stream() @@ -433,7 +438,7 @@ public Repository transform(PcmSurrogate model) { .orElseThrow(); // Construct assembly connector - AssemblyConnector assemblyConnector = CompositionFactory.eINSTANCE.createAssemblyConnector(); + final AssemblyConnector assemblyConnector = CompositionFactory.eINSTANCE.createAssemblyConnector(); assemblyConnector.setProvidedRole_AssemblyConnector(providerRole); assemblyConnector.setProvidingAssemblyContext_AssemblyConnector(providerContext); assemblyConnector.setRequiredRole_AssemblyConnector(consumerRole); @@ -446,20 +451,20 @@ public Repository transform(PcmSurrogate model) { } // Add provided delegation connectors to composite - for (CompositeProvisionDelegationRelation delegationRelation : model + for (final CompositeProvisionDelegationRelation delegationRelation : model .getByType(CompositeProvisionDelegationRelation.class)) { // Decompose delegation relation into components & interfaces - Composite compositeWrapper = (Composite) delegationRelation.getSource() + final Composite compositeWrapper = (Composite) delegationRelation.getSource() .getSource(); - Component childWrapper = delegationRelation.getDestination() + final Component childWrapper = delegationRelation.getDestination() .getSource(); - Interface outerInterfaceWrapper = delegationRelation.getSource() + final Interface outerInterfaceWrapper = delegationRelation.getSource() .getDestination(); - Interface innerInterfaceWrapper = delegationRelation.getDestination() + final Interface innerInterfaceWrapper = delegationRelation.getDestination() .getDestination(); // Fetch composite, assembly context, & roles from repository - CompositeComponent repositoryComposite = (CompositeComponent) repository.getComponents__Repository() + final CompositeComponent repositoryComposite = (CompositeComponent) repository.getComponents__Repository() .stream() .filter(CompositeComponent.class::isInstance) .filter(component -> component.getEntityName() @@ -467,7 +472,7 @@ public Repository transform(PcmSurrogate model) { .getEntityName())) .findFirst() .orElseThrow(); - AssemblyContext childContext = repositoryComposite.getAssemblyContexts__ComposedStructure() + final AssemblyContext childContext = repositoryComposite.getAssemblyContexts__ComposedStructure() .stream() .filter(context -> context.getEncapsulatedComponent__AssemblyContext() .getEntityName() @@ -475,7 +480,7 @@ public Repository transform(PcmSurrogate model) { .getEntityName())) .findFirst() .orElseThrow(); - OperationProvidedRole innerRole = (OperationProvidedRole) childContext + final OperationProvidedRole innerRole = (OperationProvidedRole) childContext .getEncapsulatedComponent__AssemblyContext() .getProvidedRoles_InterfaceProvidingEntity() .stream() @@ -486,7 +491,7 @@ public Repository transform(PcmSurrogate model) { .getEntityName())) .findFirst() .orElseThrow(); - OperationProvidedRole outerRole = (OperationProvidedRole) repositoryComposite + final OperationProvidedRole outerRole = (OperationProvidedRole) repositoryComposite .getProvidedRoles_InterfaceProvidingEntity() .stream() .filter(role -> role instanceof OperationProvidedRole @@ -498,7 +503,7 @@ public Repository transform(PcmSurrogate model) { .orElseThrow(); // Create delegation connector - ProvidedDelegationConnector delegationConnector = CompositionFactory.eINSTANCE + final ProvidedDelegationConnector delegationConnector = CompositionFactory.eINSTANCE .createProvidedDelegationConnector(); delegationConnector.setAssemblyContext_ProvidedDelegationConnector(childContext); delegationConnector.setInnerProvidedRole_ProvidedDelegationConnector(innerRole); @@ -510,27 +515,27 @@ public Repository transform(PcmSurrogate model) { } // Add required delegation connectors to composite - for (CompositeRequirementDelegationRelation delegationRelation : model + for (final CompositeRequirementDelegationRelation delegationRelation : model .getByType(CompositeRequirementDelegationRelation.class)) { // Decompose delegation relation into components & interfaces - Composite compositeWrapper = (Composite) delegationRelation.getSource() + final Composite compositeWrapper = (Composite) delegationRelation.getSource() .getSource(); - Component childWrapper = delegationRelation.getDestination() + final Component childWrapper = delegationRelation.getDestination() .getSource(); - Interface outerInterfaceWrapper = delegationRelation.getSource() + final Interface outerInterfaceWrapper = delegationRelation.getSource() .getDestination(); - Interface innerInterfaceWrapper = delegationRelation.getDestination() + final Interface innerInterfaceWrapper = delegationRelation.getDestination() .getDestination(); // Fetch composite, assembly context, & roles from repository - CompositeComponent repositoryComposite = (CompositeComponent) repository.getComponents__Repository() + final CompositeComponent repositoryComposite = (CompositeComponent) repository.getComponents__Repository() .stream() .filter(component -> component.getEntityName() .equals(compositeWrapper.getValue() .getEntityName())) .findFirst() .orElseThrow(); - AssemblyContext childContext = repositoryComposite.getAssemblyContexts__ComposedStructure() + final AssemblyContext childContext = repositoryComposite.getAssemblyContexts__ComposedStructure() .stream() .filter(context -> context.getEncapsulatedComponent__AssemblyContext() .getEntityName() @@ -538,7 +543,7 @@ public Repository transform(PcmSurrogate model) { .getEntityName())) .findFirst() .orElseThrow(); - OperationRequiredRole innerRole = (OperationRequiredRole) childContext + final OperationRequiredRole innerRole = (OperationRequiredRole) childContext .getEncapsulatedComponent__AssemblyContext() .getRequiredRoles_InterfaceRequiringEntity() .stream() @@ -549,7 +554,7 @@ public Repository transform(PcmSurrogate model) { .getEntityName())) .findFirst() .orElseThrow(); - OperationRequiredRole outerRole = (OperationRequiredRole) repositoryComposite + final OperationRequiredRole outerRole = (OperationRequiredRole) repositoryComposite .getRequiredRoles_InterfaceRequiringEntity() .stream() .filter(role -> role instanceof OperationRequiredRole @@ -561,7 +566,7 @@ public Repository transform(PcmSurrogate model) { .orElseThrow(); // Create delegation connector - RequiredDelegationConnector delegationConnector = CompositionFactory.eINSTANCE + final RequiredDelegationConnector delegationConnector = CompositionFactory.eINSTANCE .createRequiredDelegationConnector(); delegationConnector.setAssemblyContext_RequiredDelegationConnector(childContext); delegationConnector.setInnerRequiredRole_RequiredDelegationConnector(innerRole); @@ -576,23 +581,23 @@ public Repository transform(PcmSurrogate model) { } - private boolean isDirectChild(Component child, Composite parent, - Multimap> compositesChildren) { + private boolean isDirectChild(final Component child, final Composite parent, + final Multimap> compositesChildren) { return compositesChildren.get(parent) .contains(child); } - private boolean isRecursiveChild(Component child, Composite parent, - Multimap> compositesChildren) { + private boolean isRecursiveChild(final Component child, final Composite parent, + final Multimap> compositesChildren) { // Case 1: Direct child - if (isDirectChild(child, parent, compositesChildren)) { + if (this.isDirectChild(child, parent, compositesChildren)) { return true; } // Case 2: Indirect child - for (Component childOfParent : compositesChildren.get(parent)) { + for (final Component childOfParent : compositesChildren.get(parent)) { if (childOfParent instanceof Composite) { - return isRecursiveChild(child, (Composite) childOfParent, compositesChildren); + return this.isRecursiveChild(child, (Composite) childOfParent, compositesChildren); } } @@ -600,74 +605,79 @@ private boolean isRecursiveChild(Component child, Composite parent, return false; } - protected static boolean isExcludedFromDelegation(Component provider, Interface providedInterface) { - String providerName = provider.getValue() + protected static boolean isExcludedFromDelegation(final Component provider, final Interface providedInterface) { + final String providerName = provider.getValue() .getEntityName(); - String providedInterfaceName = providedInterface.getValue() + final String providedInterfaceName = providedInterface.getValue() .getEntityName(); return providedInterfaceName.equals(String.format(DELEGATION_EXCLUSION_NAME_PATTERN, providerName)); } - private int compareComposites(Composite a, Composite b, Multimap> compositesChildren) { - if (isRecursiveChild(a, b, compositesChildren)) { + private int compareComposites(final Composite a, final Composite b, + final Multimap> compositesChildren) { + if (this.isRecursiveChild(a, b, compositesChildren)) { return -1; - } else if (isRecursiveChild(b, a, compositesChildren)) { + } else if (this.isRecursiveChild(b, a, compositesChildren)) { return 1; } return 0; } - private BasicComponentCreator getCreator(FluentRepositoryFactory fluentFactory, AtomicComponent component) { - BasicComponentCreator componentCreator = fluentFactory.newBasicComponent(); + private BasicComponentCreator getCreator(final FluentRepositoryFactory fluentFactory, + final AtomicComponent component) { + final BasicComponentCreator componentCreator = fluentFactory.newBasicComponent(); // TODO Identify important information within wrapped component // Copy information from wrapped component, dismiss deprecated information. - BasicComponent wrappedComponent = component.getValue(); + final BasicComponent wrappedComponent = component.getValue(); componentCreator.withName(wrappedComponent.getEntityName()); return componentCreator; } - private CompositeComponentCreator getCreator(FluentRepositoryFactory fluentFactory, Composite component) { - CompositeComponentCreator compositeCreator = fluentFactory.newCompositeComponent(); + private CompositeComponentCreator getCreator(final FluentRepositoryFactory fluentFactory, + final Composite component) { + final CompositeComponentCreator compositeCreator = fluentFactory.newCompositeComponent(); // TODO Identify important information within wrapped component // Copy information from wrapped component, dismiss deprecated information. - RepositoryComponent wrappedComponent = component.getValue(); + final RepositoryComponent wrappedComponent = component.getValue(); compositeCreator.withName(wrappedComponent.getEntityName()); return compositeCreator; } - private OperationInterfaceCreator getCreator(FluentRepositoryFactory fluentFactory, Interface interfaceInstance) { - OperationInterfaceCreator interfaceCreator = fluentFactory.newOperationInterface(); + private OperationInterfaceCreator getCreator(final FluentRepositoryFactory fluentFactory, + final Interface interfaceInstance) { + final OperationInterfaceCreator interfaceCreator = fluentFactory.newOperationInterface(); // TODO Identify important information within wrapped interface // Copy information from wrapped interface, dismiss deprecated information. - OperationInterface wrappedInterface = interfaceInstance.getValue(); + final OperationInterface wrappedInterface = interfaceInstance.getValue(); interfaceCreator.withName(wrappedInterface.getEntityName()); return interfaceCreator; } - protected static String getProvidedRoleName(Interface interfaceInstance) { - String interfaceEntityName = interfaceInstance.getValue() + protected static String getProvidedRoleName(final Interface interfaceInstance) { + final String interfaceEntityName = interfaceInstance.getValue() .getEntityName(); return String.format(ROLE_PROVIDES_NAME_PATTERN, interfaceEntityName); } - protected static String getRequiredRoleName(Interface interfaceInstance) { - String interfaceEntityName = interfaceInstance.getValue() + protected static String getRequiredRoleName(final Interface interfaceInstance) { + final String interfaceEntityName = interfaceInstance.getValue() .getEntityName(); return String.format(ROLE_REQUIRES_NAME_PATTERN, interfaceEntityName); } // TODO Test and move to evaluation helper - private static boolean representSameSignature(OperationSignature signature, OperationSignature otherSignature) { - boolean equalName = Objects.equals(signature.getEntityName(), otherSignature.getEntityName()); - boolean equalReturn = Objects.equals(signature.getReturnType__OperationSignature(), + private static boolean representSameSignature(final OperationSignature signature, + final OperationSignature otherSignature) { + final boolean equalName = Objects.equals(signature.getEntityName(), otherSignature.getEntityName()); + final boolean equalReturn = Objects.equals(signature.getReturnType__OperationSignature(), otherSignature.getReturnType__OperationSignature()); - boolean equalParameters = signature.getParameters__OperationSignature() + final boolean equalParameters = signature.getParameters__OperationSignature() .containsAll(otherSignature.getParameters__OperationSignature()) && otherSignature.getParameters__OperationSignature() .containsAll(signature.getParameters__OperationSignature()); @@ -675,8 +685,9 @@ private static boolean representSameSignature(OperationSignature signature, Oper } // TODO Test and move to evaluation helper - private static boolean representSameInterface(OperationInterface interFace, OperationInterface otherInterFace) { - boolean equalName = Objects.equals(interFace.getEntityName(), otherInterFace.getEntityName()); + private static boolean representSameInterface(final OperationInterface interFace, + final OperationInterface otherInterFace) { + final boolean equalName = Objects.equals(interFace.getEntityName(), otherInterFace.getEntityName()); // TODO Check if signatures are equal via representSameSignature return equalName; } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformer.java index 5ba9e554..e56b89d0 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformer.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformer.java @@ -22,24 +22,25 @@ public class ResourceEnvironmentTransformer implements Transformer { @Override - public ResourceEnvironment transform(PcmSurrogate model) { - FluentResourceEnvironmentFactory resourceEnvironmentFactory = new FluentResourceEnvironmentFactory(); - IResourceEnvironment fluentResourceEnvironment = resourceEnvironmentFactory.newResourceEnvironment(); + public ResourceEnvironment transform(final PcmSurrogate model) { + final FluentResourceEnvironmentFactory resourceEnvironmentFactory = new FluentResourceEnvironmentFactory(); + final IResourceEnvironment fluentResourceEnvironment = resourceEnvironmentFactory.newResourceEnvironment(); // Add resource containers to resource environment - for (Deployment deployment : model.getByType(Deployment.class)) { - ResourceContainerCreator containerCreator = getContainerCreator(resourceEnvironmentFactory, deployment); + for (final Deployment deployment : model.getByType(Deployment.class)) { + final ResourceContainerCreator containerCreator = this.getContainerCreator(resourceEnvironmentFactory, + deployment); fluentResourceEnvironment.addToResourceEnvironment(containerCreator); } - HashMultimap linkSpecificationMap = HashMultimap.create(); - for (LinkResourceSpecificationRelation linkingRelation : model + final HashMultimap linkSpecificationMap = HashMultimap.create(); + for (final LinkResourceSpecificationRelation linkingRelation : model .getByType(LinkResourceSpecificationRelation.class)) { - Deployment source = linkingRelation.getDestination() + final Deployment source = linkingRelation.getDestination() .getSource(); - Deployment destination = linkingRelation.getDestination() + final Deployment destination = linkingRelation.getDestination() .getDestination(); - LinkResourceSpecification specification = linkingRelation.getSource(); + final LinkResourceSpecification specification = linkingRelation.getSource(); // The if clause filters non-wrong but trivial A->A container links if (!source.equals(destination)) { @@ -50,20 +51,20 @@ public ResourceEnvironment transform(PcmSurrogate model) { // Add linking resources (specification <-> [deployment <-> deployment]) to resource // environment - for (LinkResourceSpecification key : linkSpecificationMap.keySet()) { - LinkingResourceCreator linkingResourceCreator = getLinkingResourceCreator(resourceEnvironmentFactory, - linkSpecificationMap.get(key)); + for (final LinkResourceSpecification key : linkSpecificationMap.keySet()) { + final LinkingResourceCreator linkingResourceCreator = this + .getLinkingResourceCreator(resourceEnvironmentFactory, linkSpecificationMap.get(key)); fluentResourceEnvironment.addToResourceEnvironment(linkingResourceCreator); } // Create PCM resource environment - ResourceEnvironment resourceEnvironment = fluentResourceEnvironment.createResourceEnvironmentNow(); + final ResourceEnvironment resourceEnvironment = fluentResourceEnvironment.createResourceEnvironmentNow(); // Copy resource specifications from old to new containers - for (ResourceContainer container : resourceEnvironment.getResourceContainer_ResourceEnvironment()) { - for (Deployment deployment : model.getByType(Deployment.class)) { + for (final ResourceContainer container : resourceEnvironment.getResourceContainer_ResourceEnvironment()) { + for (final Deployment deployment : model.getByType(Deployment.class)) { // TODO Use container wrapper.equals - ResourceContainer wrappedContainer = deployment.getValue(); + final ResourceContainer wrappedContainer = deployment.getValue(); if (container.getEntityName() .equals(wrappedContainer.getEntityName())) { container.getActiveResourceSpecifications_ResourceContainer() @@ -75,9 +76,10 @@ public ResourceEnvironment transform(PcmSurrogate model) { } // Add linking resource specifications to PCM linking resources - for (LinkResourceSpecification specification : linkSpecificationMap.keySet()) { - Set deployments = linkSpecificationMap.get(specification); - for (LinkingResource linkingResource : resourceEnvironment.getLinkingResources__ResourceEnvironment()) { + for (final LinkResourceSpecification specification : linkSpecificationMap.keySet()) { + final Set deployments = linkSpecificationMap.get(specification); + for (final LinkingResource linkingResource : resourceEnvironment + .getLinkingResources__ResourceEnvironment()) { if (Objects.equals(getLinkingResourceName(deployments), linkingResource.getEntityName())) { linkingResource .setCommunicationLinkResourceSpecifications_LinkingResource(specification.getValue()); @@ -88,9 +90,9 @@ public ResourceEnvironment transform(PcmSurrogate model) { return resourceEnvironment; } - protected static String getLinkingResourceName(Collection deployments) { - StringBuilder stringBuilder = new StringBuilder(); - for (Deployment deployment : deployments) { + protected static String getLinkingResourceName(final Collection deployments) { + final StringBuilder stringBuilder = new StringBuilder(); + for (final Deployment deployment : deployments) { stringBuilder.append(" " + deployment.getValue() .getEntityName()); } @@ -98,26 +100,26 @@ protected static String getLinkingResourceName(Collection deployment return stringBuilder.toString(); } - private ResourceContainerCreator getContainerCreator(FluentResourceEnvironmentFactory fluentFactory, - Deployment deployment) { - ResourceContainer wrappedContainer = deployment.getValue(); + private ResourceContainerCreator getContainerCreator(final FluentResourceEnvironmentFactory fluentFactory, + final Deployment deployment) { + final ResourceContainer wrappedContainer = deployment.getValue(); // Create a container creator instance w/o processing specifications due to missing // fluentApi copy support - ResourceContainerCreator containerCreator = fluentFactory.newResourceContainer() + final ResourceContainerCreator containerCreator = fluentFactory.newResourceContainer() .withName(wrappedContainer.getEntityName()); return containerCreator; } - private LinkingResourceCreator getLinkingResourceCreator(FluentResourceEnvironmentFactory fluentFactory, - Collection deployments) { + private LinkingResourceCreator getLinkingResourceCreator(final FluentResourceEnvironmentFactory fluentFactory, + final Collection deployments) { // Create a linking resource creator w/o specifications due to missing fluentApi copy // support - String entityName = getLinkingResourceName(deployments); - LinkingResourceCreator creator = fluentFactory.newLinkingResource() + final String entityName = getLinkingResourceName(deployments); + final LinkingResourceCreator creator = fluentFactory.newLinkingResource() .withName(entityName); - for (Deployment deployment : deployments) { - String containerName = deployment.getValue() + for (final Deployment deployment : deployments) { + final String containerName = deployment.getValue() .getEntityName(); creator.addLinkedResourceContainer(containerName); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformer.java index e09448ee..8af0e7c5 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformer.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformer.java @@ -25,44 +25,45 @@ public class SystemTransformer implements Transformer component : model.getByType(Component.class)) { - AssemblyContextCreator contextCreator = getAssemblyContextCreator(systemFactory, component); + for (final Component component : model.getByType(Component.class)) { + final AssemblyContextCreator contextCreator = this.getAssemblyContextCreator(systemFactory, component); fluentSystem.addToSystem(contextCreator); } // Add assembly connectors (component assembly relations) - for (ComponentAssemblyRelation relation : model.getByType(ComponentAssemblyRelation.class)) { - AssemblyConnectorCreator connectorCreator = getAssemblyConnectorCreator(systemFactory, relation); + for (final ComponentAssemblyRelation relation : model.getByType(ComponentAssemblyRelation.class)) { + final AssemblyConnectorCreator connectorCreator = this.getAssemblyConnectorCreator(systemFactory, relation); fluentSystem.addToSystem(connectorCreator); } // Add provided delegation connectors for provided non-required interfaces - for (InterfaceProvisionRelation relation : model.getByType(InterfaceProvisionRelation.class)) { - Interface providedInteface = relation.getDestination(); - String providedIntefaceName = providedInteface.getValue() + for (final InterfaceProvisionRelation relation : model.getByType(InterfaceProvisionRelation.class)) { + final Interface providedInteface = relation.getDestination(); + final String providedIntefaceName = providedInteface.getValue() .getEntityName(); - Component provider = relation.getSource(); - boolean existsRequirement = model.getByType(InterfaceRequirementRelation.class) + final Component provider = relation.getSource(); + final boolean existsRequirement = model.getByType(InterfaceRequirementRelation.class) .stream() .anyMatch(requirementRelation -> requirementRelation.getDestination() .equals(providedInteface)); - boolean isCompositeChild = model.getByType(CompositionRelation.class) + final boolean isCompositeChild = model.getByType(CompositionRelation.class) .stream() .anyMatch(composition -> composition.getDestination() .equals(provider)); // Check whether interface should be excluded from delegation - boolean excludeDelegation = RepositoryTransformer.isExcludedFromDelegation(provider, providedInteface); + final boolean excludeDelegation = RepositoryTransformer.isExcludedFromDelegation(provider, + providedInteface); // Only add delegation if no other component requires interface and only add for most // outer provider in case @@ -73,15 +74,16 @@ public System transform(PcmSurrogate model, Repository repository) { // component in case of a composite structure. If not, no delegation to system is added. if (!existsRequirement && !isCompositeChild && !excludeDelegation) { // Create & add provided role to fluent system - String delegationRoleName = String.format(DELEGATION_ROLE_NAME_PATTERN, providedIntefaceName); - OperationProvidedRoleCreator systemProvidedRole = systemFactory.newOperationProvidedRole() + final String delegationRoleName = String.format(DELEGATION_ROLE_NAME_PATTERN, providedIntefaceName); + final OperationProvidedRoleCreator systemProvidedRole = systemFactory.newOperationProvidedRole() .withName(delegationRoleName) .withProvidedInterface(providedIntefaceName); fluentSystem.addToSystem(systemProvidedRole); // Create & add delegation between context provided role & system provided role - String delegationConnectorName = String.format(DELEGATION_CONNECTOR_NAME_PATTERN, providedIntefaceName); - ProvidedDelegationConnectorCreator systemDelegation = systemFactory + final String delegationConnectorName = String.format(DELEGATION_CONNECTOR_NAME_PATTERN, + providedIntefaceName); + final ProvidedDelegationConnectorCreator systemDelegation = systemFactory .newProvidedDelegationConnectorCreator() .withName(delegationConnectorName) .withOuterProvidedRole(delegationRoleName) @@ -94,47 +96,47 @@ public System transform(PcmSurrogate model, Repository repository) { return fluentSystem.createSystemNow(); } - protected static String getAssemblyContextName(Component component) { - String componentEntityName = component.getValue() + protected static String getAssemblyContextName(final Component component) { + final String componentEntityName = component.getValue() .getEntityName(); return String.format(ASSEMBLY_CONTEXT_NAME_PATTERN, componentEntityName); } - protected static String getAssemblyConnectorName(Interface interfaceInstance) { - String interfaceEntityName = interfaceInstance.getValue() + protected static String getAssemblyConnectorName(final Interface interfaceInstance) { + final String interfaceEntityName = interfaceInstance.getValue() .getEntityName(); return String.format(ASSEMBLY_CONNECTOR_NAME_PATTERN, interfaceEntityName); } - private AssemblyContextCreator getAssemblyContextCreator(FluentSystemFactory fluentFactory, - Component component) { - String componentEntityName = component.getValue() + private AssemblyContextCreator getAssemblyContextCreator(final FluentSystemFactory fluentFactory, + final Component component) { + final String componentEntityName = component.getValue() .getEntityName(); - String assemblyContextName = getAssemblyContextName(component); - AssemblyContextCreator contextCreator = fluentFactory.newAssemblyContext() + final String assemblyContextName = getAssemblyContextName(component); + final AssemblyContextCreator contextCreator = fluentFactory.newAssemblyContext() .withName(assemblyContextName) .withEncapsulatedComponent(componentEntityName); return contextCreator; } - private AssemblyConnectorCreator getAssemblyConnectorCreator(FluentSystemFactory fluentFactory, - ComponentAssemblyRelation assemblyRelation) { + private AssemblyConnectorCreator getAssemblyConnectorCreator(final FluentSystemFactory fluentFactory, + final ComponentAssemblyRelation assemblyRelation) { // Get wrapper from relation - Component provider = assemblyRelation.getSource() + final Component provider = assemblyRelation.getSource() .getSource(); - Component consumer = assemblyRelation.getDestination() + final Component consumer = assemblyRelation.getDestination() .getSource(); - Interface interfaceInstance = assemblyRelation.getSource() + final Interface interfaceInstance = assemblyRelation.getSource() .getDestination(); // Get entity names of roles, components and connector - String connectorName = getAssemblyConnectorName(interfaceInstance); - String providerName = getAssemblyContextName(provider); - String consumerName = getAssemblyContextName(consumer); - String providedRoleName = RepositoryTransformer.getProvidedRoleName(interfaceInstance); - String requiredRoleName = RepositoryTransformer.getRequiredRoleName(interfaceInstance); + final String connectorName = getAssemblyConnectorName(interfaceInstance); + final String providerName = getAssemblyContextName(provider); + final String consumerName = getAssemblyContextName(consumer); + final String providedRoleName = RepositoryTransformer.getProvidedRoleName(interfaceInstance); + final String requiredRoleName = RepositoryTransformer.getRequiredRoleName(interfaceInstance); - AssemblyConnectorCreator connectorCreator = fluentFactory.newAssemblyConnector() + final AssemblyConnectorCreator connectorCreator = fluentFactory.newAssemblyConnector() .withName(connectorName) .withProvidingAssemblyContext(providerName) .withOperationProvidedRole(providedRoleName) diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJob.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJob.java index 23774e47..f41b4075 100644 --- a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJob.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJob.java @@ -33,8 +33,9 @@ public class MoCoReJob implements IBlackboardInteractingJob> private final String allocationOutputKey; private final String resourceEnvironmentOutputKey; - public MoCoReJob(Blackboard blackboard, String repositoryInputKey, String repositoryOutputKey, - String systemOutputKey, String allocationOutputKey, String resourceEnvironmentOutputKey) { + public MoCoReJob(final Blackboard blackboard, final String repositoryInputKey, + final String repositoryOutputKey, final String systemOutputKey, final String allocationOutputKey, + final String resourceEnvironmentOutputKey) { this.blackboard = Objects.requireNonNull(blackboard); this.repositoryInputKey = Objects.requireNonNull(repositoryInputKey); this.repositoryOutputKey = Objects.requireNonNull(repositoryOutputKey); @@ -44,40 +45,40 @@ public MoCoReJob(Blackboard blackboard, String repositoryInputKey, Strin } @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { // Fetch input from blackboard monitor.subTask("Retrieving job input from blackboard"); - Repository inputRepository = (Repository) this.blackboard.getPartition(repositoryInputKey); + final Repository inputRepository = (Repository) this.blackboard.getPartition(this.repositoryInputKey); // Convert input into processable discoverers monitor.subTask("Converting input into processable discoveries"); - RepositoryDecompositor repositoryDecompositor = new RepositoryDecompositor(); - Collection> discoverers = repositoryDecompositor.decompose(inputRepository); + final RepositoryDecompositor repositoryDecompositor = new RepositoryDecompositor(); + final Collection> discoverers = repositoryDecompositor.decompose(inputRepository); // Composite & refine discoveries via PCM orchestrator monitor.subTask("Processing discoveries"); - PcmOrchestrator orchestrator = new PcmOrchestrator(); + final PcmOrchestrator orchestrator = new PcmOrchestrator(); discoverers.forEach(orchestrator::processDiscoverer); // Transform surrogate model into PCM models monitor.subTask("Transforming surrogate model into output models"); - PcmSurrogate surrogate = orchestrator.getModel(); - Repository repository = new RepositoryTransformer().transform(surrogate); - System system = new SystemTransformer().transform(surrogate, repository); - ResourceEnvironment resourceEnvironment = new ResourceEnvironmentTransformer().transform(surrogate); - Allocation allocation = new AllocationTransformer().transform(surrogate, system, resourceEnvironment); + final PcmSurrogate surrogate = orchestrator.getModel(); + final Repository repository = new RepositoryTransformer().transform(surrogate); + final System system = new SystemTransformer().transform(surrogate, repository); + final ResourceEnvironment resourceEnvironment = new ResourceEnvironmentTransformer().transform(surrogate); + final Allocation allocation = new AllocationTransformer().transform(surrogate, system, resourceEnvironment); // Add transformed models to blackboard monitor.subTask("Adding output models to blackboard"); - this.blackboard.addPartition(repositoryOutputKey, repository); - this.blackboard.addPartition(systemOutputKey, system); - this.blackboard.addPartition(allocationOutputKey, allocation); - this.blackboard.addPartition(resourceEnvironmentOutputKey, resourceEnvironment); + this.blackboard.addPartition(this.repositoryOutputKey, repository); + this.blackboard.addPartition(this.systemOutputKey, system); + this.blackboard.addPartition(this.allocationOutputKey, allocation); + this.blackboard.addPartition(this.resourceEnvironmentOutputKey, resourceEnvironment); monitor.done(); } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { // No cleanup required for the job } @@ -87,7 +88,7 @@ public String getName() { } @Override - public void setBlackboard(Blackboard blackboard) { + public void setBlackboard(final Blackboard blackboard) { this.blackboard = Objects.requireNonNull(blackboard); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/DecompositorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/DecompositorTest.java index e37eb489..85201fe0 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/DecompositorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/DecompositorTest.java @@ -13,17 +13,17 @@ public abstract class DecompositorTest, T> { @Test public void testDecomposeWithValidSource() { - D decompositor = this.createDecompositor(); - T source = this.createValidSource(); - Collection> discoverers = decompositor.decompose(source); + final D decompositor = this.createDecompositor(); + final T source = this.createValidSource(); + final Collection> discoverers = decompositor.decompose(source); assertNotNull(discoverers); assertTrue(discoverers.size() >= 0); } @Test public void testDecomposeWithNullSource() { - D decompositor = this.createDecompositor(); - T source = null; + final D decompositor = this.createDecompositor(); + final T source = null; assertThrows(NullPointerException.class, () -> decompositor.decompose(source)); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositorTest.java index 19345b84..f08e3059 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositorTest.java @@ -19,10 +19,10 @@ public class RepositoryDecompositorTest extends DecompositorTest { @Test public void testDecomposeEmptyRepository() { - RepositoryDecompositor decompositor = createDecompositor(); - Repository repository = createEmptyRepository(); + final RepositoryDecompositor decompositor = this.createDecompositor(); + final Repository repository = this.createEmptyRepository(); - Collection> discoverers = decompositor.decompose(repository); + final Collection> discoverers = decompositor.decompose(repository); assertEquals(10, discoverers.size()); discoverers.forEach((discoverer) -> assertTrue(discoverer.getDiscoveries() .isEmpty())); @@ -30,9 +30,9 @@ public void testDecomposeEmptyRepository() { @Test public void testDecomposeUncoupledComponents() { - RepositoryDecompositor decompositor = createDecompositor(); - FluentRepositoryFactory factory = new FluentRepositoryFactory(); - Repository repository = factory.newRepository() + final RepositoryDecompositor decompositor = this.createDecompositor(); + final FluentRepositoryFactory factory = new FluentRepositoryFactory(); + final Repository repository = factory.newRepository() .addToRepository(factory.newBasicComponent() .withName("Component_1")) .addToRepository(factory.newBasicComponent() @@ -45,16 +45,17 @@ public void testDecomposeUncoupledComponents() { .withName("Component_5")) .createRepositoryNow(); - Collection> discoverers = decompositor.decompose(repository); + final Collection> discoverers = decompositor.decompose(repository); assertFalse(discoverers.isEmpty()); // Remove all discoverers except component discoverer - List> modifiableDiscoverers = new ArrayList<>(discoverers); + final List> modifiableDiscoverers = new ArrayList<>(discoverers); modifiableDiscoverers.removeIf((discoverer) -> discoverer.getDiscoveryType() != AtomicComponent.class); assertEquals(1, modifiableDiscoverers.size()); // Get and check component discoverer - Discoverer componentDiscoverer = (Discoverer) modifiableDiscoverers.iterator() + final Discoverer componentDiscoverer = (Discoverer) modifiableDiscoverers + .iterator() .next(); assertEquals(5, componentDiscoverer.getDiscoveries() .size()); @@ -62,7 +63,7 @@ public void testDecomposeUncoupledComponents() { final int j = i; assertTrue(componentDiscoverer.getDiscoveries() .stream() - .anyMatch((AtomicComponent component) -> component.getValue() + .anyMatch((final AtomicComponent component) -> component.getValue() .getEntityName() .equals("Component_" + j))); } @@ -78,7 +79,7 @@ protected RepositoryDecompositor createDecompositor() { @Override protected Repository createValidSource() { - return createEmptyRepository(); + return this.createEmptyRepository(); } private Repository createEmptyRepository() { diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestratorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestratorTest.java index 4c2aef82..aec4d083 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestratorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestratorTest.java @@ -26,8 +26,8 @@ public class PcmOrchestratorTest { @Test public void testExistsComponentAfterProcess() { - PcmOrchestrator orchestrator = new PcmOrchestrator(); - Component component = ElementFactory.createUniqueComponent(false); + final PcmOrchestrator orchestrator = new PcmOrchestrator(); + final Component component = ElementFactory.createUniqueComponent(false); orchestrator.processDiscovery(component); assertTrue(orchestrator.getModel() .contains(component)); @@ -35,13 +35,13 @@ public void testExistsComponentAfterProcess() { @Test public void testExistImplicitReplaceablesAfterProcess() { - PcmOrchestrator orchestrator = new PcmOrchestrator(); - Component component = ElementFactory.createUniqueComponent(false); + final PcmOrchestrator orchestrator = new PcmOrchestrator(); + final Component component = ElementFactory.createUniqueComponent(false); orchestrator.processDiscovery(component); - PcmSurrogate model = orchestrator.getModel(); - List deployments = model.getByType(Deployment.class); - Stream componentDeploymentRelations = model + final PcmSurrogate model = orchestrator.getModel(); + final List deployments = model.getByType(Deployment.class); + final Stream componentDeploymentRelations = model .getByType(ComponentAllocationRelation.class) .stream(); @@ -54,8 +54,8 @@ public void testExistImplicitReplaceablesAfterProcess() { @Test public void testExistsDeploymentAfterProcess() { - PcmOrchestrator orchestrator = new PcmOrchestrator(); - Deployment deployment = ElementFactory.createUniqueDeployment(false); + final PcmOrchestrator orchestrator = new PcmOrchestrator(); + final Deployment deployment = ElementFactory.createUniqueDeployment(false); orchestrator.processDiscovery(deployment); assertTrue(orchestrator.getModel() .contains(deployment)); @@ -64,35 +64,35 @@ public void testExistsDeploymentAfterProcess() { @Test public void testChainReplacementOfPlaceholders() { // Test data - PcmOrchestrator orchestrator = new PcmOrchestrator(); + final PcmOrchestrator orchestrator = new PcmOrchestrator(); //// Create concrete & placeholder elements - Signature concreteSignature = ElementFactory.createUniqueSignature(false); - Interface concreteInterface = ElementFactory.createUniqueInterface(false); - Component concreteComponent = ElementFactory.createUniqueComponent(false); - Deployment concreteDeployment = ElementFactory.createUniqueDeployment(false); - Interface placeholderInterface = Interface.getUniquePlaceholder(); - Component placeholderComponent = Component.getUniquePlaceholder(); - Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); + final Signature concreteSignature = ElementFactory.createUniqueSignature(false); + final Interface concreteInterface = ElementFactory.createUniqueInterface(false); + final Component concreteComponent = ElementFactory.createUniqueComponent(false); + final Deployment concreteDeployment = ElementFactory.createUniqueDeployment(false); + final Interface placeholderInterface = Interface.getUniquePlaceholder(); + final Component placeholderComponent = Component.getUniquePlaceholder(); + final Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); //// Create non-conflicting relations between elements - SignatureProvisionRelation placeholderSignatureProvision = new SignatureProvisionRelation(concreteSignature, - placeholderInterface, true); - InterfaceProvisionRelation placeholderInterfaceProvision = new InterfaceProvisionRelation(placeholderComponent, - placeholderInterface, true); - ComponentAllocationRelation placeholderAllocation = new ComponentAllocationRelation(placeholderComponent, + final SignatureProvisionRelation placeholderSignatureProvision = new SignatureProvisionRelation( + concreteSignature, placeholderInterface, true); + final InterfaceProvisionRelation placeholderInterfaceProvision = new InterfaceProvisionRelation( + placeholderComponent, placeholderInterface, true); + final ComponentAllocationRelation placeholderAllocation = new ComponentAllocationRelation(placeholderComponent, placeholderDeployment, true); - InterfaceProvisionRelation concreteInterfaceProvision = new InterfaceProvisionRelation(concreteComponent, + final InterfaceProvisionRelation concreteInterfaceProvision = new InterfaceProvisionRelation(concreteComponent, concreteInterface, false); - ComponentAllocationRelation concreteAllocation = new ComponentAllocationRelation(concreteComponent, + final ComponentAllocationRelation concreteAllocation = new ComponentAllocationRelation(concreteComponent, concreteDeployment, false); //// Create relation leading to chain replacement - SignatureProvisionRelation signatureProvisionRelation = new SignatureProvisionRelation(concreteSignature, + final SignatureProvisionRelation signatureProvisionRelation = new SignatureProvisionRelation(concreteSignature, concreteInterface, false); //// Add entities to model - PcmSurrogate model = orchestrator.getModel(); + final PcmSurrogate model = orchestrator.getModel(); model.add(concreteSignature); model.add(concreteInterface); model.add(concreteComponent); diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessorTest.java index 3c7c29ba..b7cf171d 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessorTest.java @@ -5,7 +5,7 @@ public class AtomicComponentProcessorTest extends ComponentProcessorTest { @Override - protected AtomicComponentProcessor createProcessor(PcmSurrogate model) { + protected AtomicComponentProcessor createProcessor(final PcmSurrogate model) { return new AtomicComponentProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessorTest.java index 541c2a64..28bf25c6 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessorTest.java @@ -20,9 +20,9 @@ public abstract class ComponentProcessorTest> @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidElementAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - ComponentProcessor processor = createProcessor(model); - T element = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final ComponentProcessor processor = this.createProcessor(model); + final T element = this.createUniqueReplaceable(); // Assertions: Pre-execution assertTrue(processor.getImplications() @@ -30,15 +30,15 @@ public void testRefineWithValidElementAddsCorrectImplications() { // Execution processor.refine(element); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions: Post-execution assertEquals(1, implications.size()); - Replaceable implication = implications.stream() + final Replaceable implication = implications.stream() .findFirst() .orElseThrow(); assertEquals(ComponentAllocationRelation.class, implication.getClass()); - ComponentAllocationRelation relation = (ComponentAllocationRelation) implication; + final ComponentAllocationRelation relation = (ComponentAllocationRelation) implication; assertEquals(element, relation.getSource()); assertTrue(relation.isPlaceholder()); assertTrue(relation.getDestination() diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessorTest.java index b99dc474..fc21ab38 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessorTest.java @@ -5,7 +5,7 @@ public class CompositeProcessorTest extends ComponentProcessorTest { @Override - protected CompositeProcessor createProcessor(PcmSurrogate model) { + protected CompositeProcessor createProcessor(final PcmSurrogate model) { return new CompositeProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessorTest.java index d0d44ba2..4b3a778c 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessorTest.java @@ -14,9 +14,9 @@ public class DeploymentProcessorTest extends ProcessorTest implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions: Post-execution assertEquals(1, implications.size()); - Replaceable implication = implications.stream() + final Replaceable implication = implications.stream() .findFirst() .orElseThrow(); assertEquals(InterfaceProvisionRelation.class, implication.getClass()); - InterfaceProvisionRelation relation = (InterfaceProvisionRelation) implication; + final InterfaceProvisionRelation relation = (InterfaceProvisionRelation) implication; assertEquals(element, relation.getDestination()); assertTrue(relation.isPlaceholder()); assertTrue(relation.getSource() @@ -49,7 +49,7 @@ public void testRefineWithValidElementAddsCorrectImplications() { } @Override - protected InterfaceProcessor createProcessor(PcmSurrogate model) { + protected InterfaceProcessor createProcessor(final PcmSurrogate model) { return new InterfaceProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessorTest.java index 4c6ba1c4..5fcdfe6a 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessorTest.java @@ -20,9 +20,9 @@ public class LinkResourceSpecificationProcessorTest @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidElementAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - LinkResourceSpecificationProcessor processor = createProcessor(model); - LinkResourceSpecification element = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final LinkResourceSpecificationProcessor processor = this.createProcessor(model); + final LinkResourceSpecification element = this.createUniqueReplaceable(); // Assertions: Pre-execution assertTrue(processor.getImplications() @@ -30,15 +30,15 @@ public void testRefineWithValidElementAddsCorrectImplications() { // Execution processor.refine(element); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions: Post-execution assertEquals(1, implications.size()); - Replaceable implication = implications.stream() + final Replaceable implication = implications.stream() .findFirst() .orElseThrow(); assertEquals(LinkResourceSpecificationRelation.class, implication.getClass()); - LinkResourceSpecificationRelation relation = (LinkResourceSpecificationRelation) implication; + final LinkResourceSpecificationRelation relation = (LinkResourceSpecificationRelation) implication; assertEquals(element, relation.getSource()); assertTrue(relation.isPlaceholder()); assertTrue(relation.getDestination() @@ -52,7 +52,7 @@ public void testRefineWithValidElementAddsCorrectImplications() { } @Override - protected LinkResourceSpecificationProcessor createProcessor(PcmSurrogate model) { + protected LinkResourceSpecificationProcessor createProcessor(final PcmSurrogate model) { return new LinkResourceSpecificationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java index 42036ef0..029c3263 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java @@ -19,9 +19,9 @@ public class ServiceEffectSpecificationProcessorTest @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidElementAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - ServiceEffectSpecificationProcessor processor = createProcessor(model); - ServiceEffectSpecification element = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final ServiceEffectSpecificationProcessor processor = this.createProcessor(model); + final ServiceEffectSpecification element = this.createUniqueReplaceable(); // Assertions: Pre-execution assertTrue(processor.getImplications() @@ -29,14 +29,14 @@ public void testRefineWithValidElementAddsCorrectImplications() { // Execution processor.refine(element); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions: Post-execution assertEquals(0, implications.size()); } @Override - protected ServiceEffectSpecificationProcessor createProcessor(PcmSurrogate model) { + protected ServiceEffectSpecificationProcessor createProcessor(final PcmSurrogate model) { return new ServiceEffectSpecificationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessorTest.java index 1dec73bb..f82f01bc 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessorTest.java @@ -20,9 +20,9 @@ public class SignatureProcessorTest extends ProcessorTest implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution //// Implicit providing interface assertEquals(1, implications.size()); - Replaceable implication = implications.stream() + final Replaceable implication = implications.stream() .findFirst() .orElseThrow(); assertEquals(SignatureProvisionRelation.class, implication.getClass()); - SignatureProvisionRelation relation = (SignatureProvisionRelation) implication; + final SignatureProvisionRelation relation = (SignatureProvisionRelation) implication; assertEquals(element, relation.getSource()); assertTrue(relation.isPlaceholder()); assertTrue(relation.getDestination() @@ -47,7 +47,7 @@ public void testRefineWithValidElementAddsCorrectImplications() { } @Override - protected SignatureProcessor createProcessor(PcmSurrogate model) { + protected SignatureProcessor createProcessor(final PcmSurrogate model) { return new SignatureProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java index 6edafc65..9b414dd1 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java @@ -11,8 +11,8 @@ public class ComponentAllocationRelationProcessorTest extends RelationProcessorTest, Deployment> { @Override - protected ComponentAllocationRelation createRelation(Component source, Deployment destination, - boolean isPlaceholder) { + protected ComponentAllocationRelation createRelation(final Component source, final Deployment destination, + final boolean isPlaceholder) { return new ComponentAllocationRelation(source, destination, isPlaceholder); } @@ -22,7 +22,7 @@ protected Component getUniqueNonPlaceholderSourceEntity() { } @Override - protected Component getPlaceholderOfSourceEntity(Component source) { + protected Component getPlaceholderOfSourceEntity(final Component source) { return new Component<>(source.getValue(), true); } @@ -32,12 +32,12 @@ protected Deployment getUniqueNonPlaceholderDestinationEntity() { } @Override - protected Deployment getPlaceholderOfDestinationEntity(Deployment destination) { + protected Deployment getPlaceholderOfDestinationEntity(final Deployment destination) { return new Deployment(destination.getValue(), true); } @Override - protected ComponentAllocationRelationProcessor createProcessor(PcmSurrogate model) { + protected ComponentAllocationRelationProcessor createProcessor(final PcmSurrogate model) { return new ComponentAllocationRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java index c41fab35..f60288b6 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java @@ -30,30 +30,30 @@ public class ComponentAssemblyRelationProcessorTest extends @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefinementRemovesParallelAssemblyPlaceholder() { // Test data - PcmSurrogate model = createEmptyModel(); - ComponentAssemblyRelationProcessor processor = createProcessor(model); + final PcmSurrogate model = this.createEmptyModel(); + final ComponentAssemblyRelationProcessor processor = this.createProcessor(model); - InterfaceProvisionRelation interfaceProvision = getUniqueNonPlaceholderSourceEntity(); - InterfaceRequirementRelation interfaceRequirement = getUniqueNonPlaceholderDestinationEntity(); - ComponentAssemblyRelation relation = createRelation(interfaceProvision, interfaceRequirement, false); + final InterfaceProvisionRelation interfaceProvision = this.getUniqueNonPlaceholderSourceEntity(); + final InterfaceRequirementRelation interfaceRequirement = this.getUniqueNonPlaceholderDestinationEntity(); + final ComponentAssemblyRelation relation = this.createRelation(interfaceProvision, interfaceRequirement, false); - Deployment providingContainer = Deployment.getUniquePlaceholder(); - Deployment requiringContainer = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation providingAllocation = new ComponentAllocationRelation( + final Deployment providingContainer = Deployment.getUniquePlaceholder(); + final Deployment requiringContainer = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation providingAllocation = new ComponentAllocationRelation( interfaceProvision.getSource(), providingContainer, false); - ComponentAllocationRelation requiringAllocation = new ComponentAllocationRelation( + final ComponentAllocationRelation requiringAllocation = new ComponentAllocationRelation( interfaceRequirement.getSource(), requiringContainer, false); - InterfaceProvisionRelation placeholderProvision = getPlaceholderOfSourceEntity( - getUniqueNonPlaceholderSourceEntity()); - InterfaceRequirementRelation placeholderRequirement = getPlaceholderOfDestinationEntity( - getUniqueNonPlaceholderDestinationEntity()); - ComponentAllocationRelation placeholderProvidingAllocation = new ComponentAllocationRelation( + final InterfaceProvisionRelation placeholderProvision = this + .getPlaceholderOfSourceEntity(this.getUniqueNonPlaceholderSourceEntity()); + final InterfaceRequirementRelation placeholderRequirement = this + .getPlaceholderOfDestinationEntity(this.getUniqueNonPlaceholderDestinationEntity()); + final ComponentAllocationRelation placeholderProvidingAllocation = new ComponentAllocationRelation( placeholderProvision.getSource(), providingContainer, false); - ComponentAllocationRelation placeholderRequiringAllocation = new ComponentAllocationRelation( + final ComponentAllocationRelation placeholderRequiringAllocation = new ComponentAllocationRelation( placeholderRequirement.getSource(), requiringContainer, false); - ComponentAssemblyRelation placeholderRelation = createRelation(placeholderProvision, placeholderRequirement, - true); + final ComponentAssemblyRelation placeholderRelation = this.createRelation(placeholderProvision, + placeholderRequirement, true); // Add containers, placeholder assembly & allocations to model model.add(providingContainer); @@ -84,7 +84,7 @@ public void testRefinementRemovesParallelAssemblyPlaceholder() { // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertFalse(model.contains(placeholderProvision.getSource())); @@ -106,18 +106,18 @@ public void testRefinementRemovesParallelAssemblyPlaceholder() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefinementAddsImplicitDeploymentRelation() { // Test data - PcmSurrogate model = createEmptyModel(); - ComponentAssemblyRelationProcessor processor = createProcessor(model); + final PcmSurrogate model = this.createEmptyModel(); + final ComponentAssemblyRelationProcessor processor = this.createProcessor(model); - InterfaceProvisionRelation interfaceProvision = getUniqueNonPlaceholderSourceEntity(); - InterfaceRequirementRelation interfaceRequirement = getUniqueNonPlaceholderDestinationEntity(); - ComponentAssemblyRelation relation = createRelation(interfaceProvision, interfaceRequirement, false); + final InterfaceProvisionRelation interfaceProvision = this.getUniqueNonPlaceholderSourceEntity(); + final InterfaceRequirementRelation interfaceRequirement = this.getUniqueNonPlaceholderDestinationEntity(); + final ComponentAssemblyRelation relation = this.createRelation(interfaceProvision, interfaceRequirement, false); - Deployment providingContainer = Deployment.getUniquePlaceholder(); - Deployment requiringContainer = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation providingAllocation = new ComponentAllocationRelation( + final Deployment providingContainer = Deployment.getUniquePlaceholder(); + final Deployment requiringContainer = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation providingAllocation = new ComponentAllocationRelation( interfaceProvision.getSource(), providingContainer, false); - ComponentAllocationRelation requiringAllocation = new ComponentAllocationRelation( + final ComponentAllocationRelation requiringAllocation = new ComponentAllocationRelation( interfaceRequirement.getSource(), requiringContainer, false); // Add containers & allocations to model @@ -132,52 +132,53 @@ public void testRefinementAddsImplicitDeploymentRelation() { // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); assertTrue(implications.remove(relation.getDestination())); assertEquals(1, implications.size()); - Replaceable implication = implications.stream() + final Replaceable implication = implications.stream() .findFirst() .orElseThrow(); assertEquals(DeploymentDeploymentRelation.class, implication.getClass()); - DeploymentDeploymentRelation implicitDeploymentLink = (DeploymentDeploymentRelation) implication; + final DeploymentDeploymentRelation implicitDeploymentLink = (DeploymentDeploymentRelation) implication; assertEquals(providingContainer, implicitDeploymentLink.getSource()); assertEquals(requiringContainer, implicitDeploymentLink.getDestination()); assertTrue(implicitDeploymentLink.isPlaceholder()); } @Override - protected ComponentAssemblyRelation createRelation(InterfaceProvisionRelation source, - InterfaceRequirementRelation destination, boolean isPlaceholder) { + protected ComponentAssemblyRelation createRelation(final InterfaceProvisionRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { return new ComponentAssemblyRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueNonPlaceholderSourceEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_DESTINATION, false); } @Override - protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(InterfaceProvisionRelation source) { + protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(final InterfaceProvisionRelation source) { return new InterfaceProvisionRelation(source.getSource(), source.getDestination(), true); } @Override protected InterfaceRequirementRelation getUniqueNonPlaceholderDestinationEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_DESTINATION, false); } @Override - protected InterfaceRequirementRelation getPlaceholderOfDestinationEntity(InterfaceRequirementRelation destination) { + protected InterfaceRequirementRelation getPlaceholderOfDestinationEntity( + final InterfaceRequirementRelation destination) { return new InterfaceRequirementRelation(destination.getSource(), destination.getDestination(), true); } @Override - protected ComponentAssemblyRelationProcessor createProcessor(PcmSurrogate model) { + protected ComponentAssemblyRelationProcessor createProcessor(final PcmSurrogate model) { return new ComponentAssemblyRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java index a917889d..59d2c4c0 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java @@ -15,35 +15,36 @@ public class ComponentSignatureProvisionRelationProcessorTest extends private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); @Override - protected ComponentSignatureProvisionRelation createRelation(InterfaceProvisionRelation source, - SignatureProvisionRelation destination, boolean isPlaceholder) { + protected ComponentSignatureProvisionRelation createRelation(final InterfaceProvisionRelation source, + final SignatureProvisionRelation destination, final boolean isPlaceholder) { return new ComponentSignatureProvisionRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueNonPlaceholderSourceEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(InterfaceProvisionRelation source) { + protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(final InterfaceProvisionRelation source) { return new InterfaceProvisionRelation(source.getSource(), source.getDestination(), true); } @Override protected SignatureProvisionRelation getUniqueNonPlaceholderDestinationEntity() { - Signature signature = Signature.getUniquePlaceholder(); + final Signature signature = Signature.getUniquePlaceholder(); return new SignatureProvisionRelation(signature, RELATION_INTERFACE, false); } @Override - protected SignatureProvisionRelation getPlaceholderOfDestinationEntity(SignatureProvisionRelation destination) { + protected SignatureProvisionRelation getPlaceholderOfDestinationEntity( + final SignatureProvisionRelation destination) { return new SignatureProvisionRelation(destination.getSource(), destination.getDestination(), true); } @Override - protected ComponentSignatureProvisionRelationProcessor createProcessor(PcmSurrogate model) { + protected ComponentSignatureProvisionRelationProcessor createProcessor(final PcmSurrogate model) { return new ComponentSignatureProvisionRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java index 3f61522a..a0718f8f 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java @@ -27,9 +27,9 @@ public class CompositeProvisionDelegationRelationProcessorTest extends @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidRelationAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - CompositeProvisionDelegationRelationProcessor processor = createProcessor(model); - CompositeProvisionDelegationRelation relation = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final CompositeProvisionDelegationRelationProcessor processor = this.createProcessor(model); + final CompositeProvisionDelegationRelation relation = this.createUniqueReplaceable(); // Assertions: Pre-execution assertTrue(processor.getImplications() @@ -37,7 +37,7 @@ public void testRefineWithValidRelationAddsCorrectImplications() { // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -45,12 +45,12 @@ public void testRefineWithValidRelationAddsCorrectImplications() { // Implicit CompositionRelation between source & destination component assertEquals(1, implications.size()); - Replaceable implication = implications.stream() + final Replaceable implication = implications.stream() .findFirst() .orElseThrow(); assertEquals(CompositionRelation.class, implication.getClass()); - CompositionRelation implicitComposition = (CompositionRelation) implication; + final CompositionRelation implicitComposition = (CompositionRelation) implication; assertTrue(implicitComposition.isPlaceholder()); assertTrue(implicitComposition.getSource() .equals(relation.getSource() @@ -61,35 +61,36 @@ public void testRefineWithValidRelationAddsCorrectImplications() { } @Override - protected CompositeProvisionDelegationRelation createRelation(InterfaceProvisionRelation source, - InterfaceProvisionRelation destination, boolean isPlaceholder) { + protected CompositeProvisionDelegationRelation createRelation(final InterfaceProvisionRelation source, + final InterfaceProvisionRelation destination, final boolean isPlaceholder) { return new CompositeProvisionDelegationRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueNonPlaceholderSourceEntity() { - Composite source = Composite.getUniquePlaceholder(); + final Composite source = Composite.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(InterfaceProvisionRelation source) { + protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(final InterfaceProvisionRelation source) { return new InterfaceProvisionRelation(source.getSource(), source.getDestination(), true); } @Override protected InterfaceProvisionRelation getUniqueNonPlaceholderDestinationEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceProvisionRelation getPlaceholderOfDestinationEntity(InterfaceProvisionRelation destination) { + protected InterfaceProvisionRelation getPlaceholderOfDestinationEntity( + final InterfaceProvisionRelation destination) { return new InterfaceProvisionRelation(destination.getSource(), destination.getDestination(), true); } @Override - protected CompositeProvisionDelegationRelationProcessor createProcessor(PcmSurrogate model) { + protected CompositeProvisionDelegationRelationProcessor createProcessor(final PcmSurrogate model) { return new CompositeProvisionDelegationRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java index d8874749..1b94f8c2 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java @@ -27,9 +27,9 @@ public class CompositeRequirementDelegationRelationProcessorTest extends @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidRelationAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - CompositeRequirementDelegationRelationProcessor processor = createProcessor(model); - CompositeRequirementDelegationRelation relation = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final CompositeRequirementDelegationRelationProcessor processor = this.createProcessor(model); + final CompositeRequirementDelegationRelation relation = this.createUniqueReplaceable(); // Assertions: Pre-execution assertTrue(processor.getImplications() @@ -37,7 +37,7 @@ public void testRefineWithValidRelationAddsCorrectImplications() { // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -45,12 +45,12 @@ public void testRefineWithValidRelationAddsCorrectImplications() { // Implicit CompositionRelation between source & destination component assertEquals(1, implications.size()); - Replaceable implication = implications.stream() + final Replaceable implication = implications.stream() .findFirst() .orElseThrow(); assertEquals(CompositionRelation.class, implication.getClass()); - CompositionRelation implicitComposition = (CompositionRelation) implication; + final CompositionRelation implicitComposition = (CompositionRelation) implication; assertTrue(implicitComposition.isPlaceholder()); assertTrue(implicitComposition.getSource() .equals(relation.getSource() @@ -61,35 +61,36 @@ public void testRefineWithValidRelationAddsCorrectImplications() { } @Override - protected CompositeRequirementDelegationRelation createRelation(InterfaceRequirementRelation source, - InterfaceRequirementRelation destination, boolean isPlaceholder) { + protected CompositeRequirementDelegationRelation createRelation(final InterfaceRequirementRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { return new CompositeRequirementDelegationRelation(source, destination, isPlaceholder); } @Override protected InterfaceRequirementRelation getUniqueNonPlaceholderSourceEntity() { - Composite source = Composite.getUniquePlaceholder(); + final Composite source = Composite.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceRequirementRelation getPlaceholderOfSourceEntity(InterfaceRequirementRelation source) { + protected InterfaceRequirementRelation getPlaceholderOfSourceEntity(final InterfaceRequirementRelation source) { return new InterfaceRequirementRelation(source.getSource(), source.getDestination(), true); } @Override protected InterfaceRequirementRelation getUniqueNonPlaceholderDestinationEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceRequirementRelation getPlaceholderOfDestinationEntity(InterfaceRequirementRelation destination) { + protected InterfaceRequirementRelation getPlaceholderOfDestinationEntity( + final InterfaceRequirementRelation destination) { return new InterfaceRequirementRelation(destination.getSource(), destination.getDestination(), true); } @Override - protected CompositeRequirementDelegationRelationProcessor createProcessor(PcmSurrogate model) { + protected CompositeRequirementDelegationRelationProcessor createProcessor(final PcmSurrogate model) { return new CompositeRequirementDelegationRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessorTest.java index 389cec25..f980eb03 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessorTest.java @@ -11,7 +11,8 @@ public class CompositionRelationProcessorTest extends RelationProcessorTest> { @Override - protected CompositionRelation createRelation(Composite source, Component destination, boolean isPlaceholder) { + protected CompositionRelation createRelation(final Composite source, final Component destination, + final boolean isPlaceholder) { return new CompositionRelation(source, destination, isPlaceholder); } @@ -21,7 +22,7 @@ protected Composite getUniqueNonPlaceholderSourceEntity() { } @Override - protected Composite getPlaceholderOfSourceEntity(Composite source) { + protected Composite getPlaceholderOfSourceEntity(final Composite source) { return new Composite(source.getValue(), true); } @@ -31,12 +32,12 @@ protected Component getUniqueNonPlaceholderDestinationEntity() { } @Override - protected Component getPlaceholderOfDestinationEntity(Component destination) { + protected Component getPlaceholderOfDestinationEntity(final Component destination) { return new Component<>(destination.getValue(), true); } @Override - protected CompositionRelationProcessor createProcessor(PcmSurrogate model) { + protected CompositionRelationProcessor createProcessor(final PcmSurrogate model) { return new CompositionRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java index cd65ed57..49f05c82 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java @@ -30,9 +30,9 @@ public class DeploymentDeploymentRelationProcessorTest extends @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidElementAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - DeploymentDeploymentRelation relation = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final DeploymentDeploymentRelation relation = this.createUniqueReplaceable(); // Assertions: Pre-execution assertTrue(processor.getImplications() @@ -40,7 +40,7 @@ public void testRefineWithValidElementAddsCorrectImplications() { // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -49,11 +49,11 @@ public void testRefineWithValidElementAddsCorrectImplications() { //// Implicit LinkResourceSpecificationRelation assertEquals(1, implications.size()); - Replaceable implication = implications.stream() + final Replaceable implication = implications.stream() .findFirst() .orElseThrow(); assertEquals(LinkResourceSpecificationRelation.class, implication.getClass()); - LinkResourceSpecificationRelation implicitSpecification = (LinkResourceSpecificationRelation) implication; + final LinkResourceSpecificationRelation implicitSpecification = (LinkResourceSpecificationRelation) implication; assertEquals(relation, implicitSpecification.getDestination()); assertTrue(implicitSpecification.isPlaceholder()); assertTrue(implicitSpecification.getSource() @@ -64,21 +64,22 @@ public void testRefineWithValidElementAddsCorrectImplications() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineDoesNotAddAssemblyIfParallelExists() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - DeploymentDeploymentRelation relation = createUniqueReplaceable(); - - Component provider = Component.getUniquePlaceholder(); - Component consumer = Component.getUniquePlaceholder(); - Interface interfc = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, interfc, false); - InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, interfc, false); - ComponentAssemblyRelation assembly = new ComponentAssemblyRelation(interfaceProvision, interfaceRequirement, + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final DeploymentDeploymentRelation relation = this.createUniqueReplaceable(); + + final Component provider = Component.getUniquePlaceholder(); + final Component consumer = Component.getUniquePlaceholder(); + final Interface interfc = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, interfc, false); + final InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, interfc, false); + final ComponentAssemblyRelation assembly = new ComponentAssemblyRelation(interfaceProvision, + interfaceRequirement, false); - ComponentAllocationRelation providerAllocation = new ComponentAllocationRelation(provider, relation.getSource(), - false); - ComponentAllocationRelation consumerAllocation = new ComponentAllocationRelation(consumer, + final ComponentAllocationRelation providerAllocation = new ComponentAllocationRelation(provider, + relation.getSource(), false); + final ComponentAllocationRelation consumerAllocation = new ComponentAllocationRelation(consumer, relation.getDestination(), false); model.add(assembly); @@ -91,7 +92,7 @@ public void testRefineDoesNotAddAssemblyIfParallelExists() { // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -109,21 +110,22 @@ public void testRefineDoesNotAddAssemblyIfParallelExists() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineDoesNotAddAssemblyIfInverseExists() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - DeploymentDeploymentRelation relation = createUniqueReplaceable(); - - Component provider = Component.getUniquePlaceholder(); - Component consumer = Component.getUniquePlaceholder(); - Interface interfc = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, interfc, false); - InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, interfc, false); - ComponentAssemblyRelation assembly = new ComponentAssemblyRelation(interfaceProvision, interfaceRequirement, + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final DeploymentDeploymentRelation relation = this.createUniqueReplaceable(); + + final Component provider = Component.getUniquePlaceholder(); + final Component consumer = Component.getUniquePlaceholder(); + final Interface interfc = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, interfc, false); + final InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, interfc, false); + final ComponentAssemblyRelation assembly = new ComponentAssemblyRelation(interfaceProvision, + interfaceRequirement, false); - ComponentAllocationRelation providerAllocation = new ComponentAllocationRelation(consumer, relation.getSource(), - false); - ComponentAllocationRelation consumerAllocation = new ComponentAllocationRelation(provider, + final ComponentAllocationRelation providerAllocation = new ComponentAllocationRelation(consumer, + relation.getSource(), false); + final ComponentAllocationRelation consumerAllocation = new ComponentAllocationRelation(provider, relation.getDestination(), false); model.add(assembly); @@ -136,7 +138,7 @@ public void testRefineDoesNotAddAssemblyIfInverseExists() { // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -154,13 +156,13 @@ public void testRefineDoesNotAddAssemblyIfInverseExists() { @Test public void testProcessReplacesIndirectPlaceholder() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - Deployment source = getUniqueNonPlaceholderSourceEntity(); - Deployment destination = getUniqueNonPlaceholderDestinationEntity(); - Deployment destinationPlaceholder = getPlaceholderOfDestinationEntity(destination); - DeploymentDeploymentRelation relation = createRelation(source, destination, true); - DeploymentDeploymentRelation placeholder = createRelation(source, destinationPlaceholder, true); + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final Deployment source = this.getUniqueNonPlaceholderSourceEntity(); + final Deployment destination = this.getUniqueNonPlaceholderDestinationEntity(); + final Deployment destinationPlaceholder = this.getPlaceholderOfDestinationEntity(destination); + final DeploymentDeploymentRelation relation = this.createRelation(source, destination, true); + final DeploymentDeploymentRelation placeholder = this.createRelation(source, destinationPlaceholder, true); // Execution & Assertions to add placeholder model.add(placeholder); @@ -176,7 +178,7 @@ public void testProcessReplacesIndirectPlaceholder() { // Execution to replace placeholder processor.process(relation); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions - Model State assertTrue(model.contains(placeholder)); @@ -198,13 +200,13 @@ public void testProcessReplacesIndirectPlaceholder() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testReplaceIndirectPlaceholdersSameSource() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - Deployment source = getUniqueNonPlaceholderSourceEntity(); - Deployment destination = getUniqueNonPlaceholderDestinationEntity(); - Deployment destinationPlaceholder = getPlaceholderOfDestinationEntity(destination); - DeploymentDeploymentRelation relation = createRelation(source, destination, true); - DeploymentDeploymentRelation placeholder = createRelation(source, destinationPlaceholder, true); + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final Deployment source = this.getUniqueNonPlaceholderSourceEntity(); + final Deployment destination = this.getUniqueNonPlaceholderDestinationEntity(); + final Deployment destinationPlaceholder = this.getPlaceholderOfDestinationEntity(destination); + final DeploymentDeploymentRelation relation = this.createRelation(source, destination, true); + final DeploymentDeploymentRelation placeholder = this.createRelation(source, destinationPlaceholder, true); // Execution & Assertions to add placeholder model.add(placeholder); @@ -220,7 +222,7 @@ public void testReplaceIndirectPlaceholdersSameSource() { // Execution to replace placeholder processor.replaceIndirectPlaceholders(relation); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions - Model State assertTrue(model.contains(placeholder)); @@ -242,13 +244,13 @@ public void testReplaceIndirectPlaceholdersSameSource() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testReplaceIndirectPlaceholdersSameDestination() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - Deployment source = getUniqueNonPlaceholderSourceEntity(); - Deployment sourcePlaceholder = getPlaceholderOfSourceEntity(source); - Deployment destination = getUniqueNonPlaceholderDestinationEntity(); - DeploymentDeploymentRelation relation = createRelation(source, destination, true); - DeploymentDeploymentRelation placeholder = createRelation(sourcePlaceholder, destination, true); + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final Deployment source = this.getUniqueNonPlaceholderSourceEntity(); + final Deployment sourcePlaceholder = this.getPlaceholderOfSourceEntity(source); + final Deployment destination = this.getUniqueNonPlaceholderDestinationEntity(); + final DeploymentDeploymentRelation relation = this.createRelation(source, destination, true); + final DeploymentDeploymentRelation placeholder = this.createRelation(sourcePlaceholder, destination, true); // Execution & Assertions to add placeholder model.add(placeholder); @@ -264,7 +266,7 @@ public void testReplaceIndirectPlaceholdersSameDestination() { // Execution to replace placeholder processor.replaceIndirectPlaceholders(relation); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions - Model State assertTrue(model.contains(placeholder)); @@ -282,8 +284,8 @@ public void testReplaceIndirectPlaceholdersSameDestination() { } @Override - protected DeploymentDeploymentRelation createRelation(Deployment source, Deployment destination, - boolean isPlaceholder) { + protected DeploymentDeploymentRelation createRelation(final Deployment source, final Deployment destination, + final boolean isPlaceholder) { return new DeploymentDeploymentRelation(source, destination, isPlaceholder); } @@ -293,22 +295,22 @@ protected Deployment getUniqueNonPlaceholderSourceEntity() { } @Override - protected Deployment getPlaceholderOfSourceEntity(Deployment source) { + protected Deployment getPlaceholderOfSourceEntity(final Deployment source) { return new Deployment(source.getValue(), true); } @Override protected Deployment getUniqueNonPlaceholderDestinationEntity() { - return getUniqueNonPlaceholderSourceEntity(); + return this.getUniqueNonPlaceholderSourceEntity(); } @Override - protected Deployment getPlaceholderOfDestinationEntity(Deployment destination) { - return getPlaceholderOfSourceEntity(destination); + protected Deployment getPlaceholderOfDestinationEntity(final Deployment destination) { + return this.getPlaceholderOfSourceEntity(destination); } @Override - protected DeploymentDeploymentRelationProcessor createProcessor(PcmSurrogate model) { + protected DeploymentDeploymentRelationProcessor createProcessor(final PcmSurrogate model) { return new DeploymentDeploymentRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java index 052b0161..bfc23b44 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java @@ -11,8 +11,8 @@ public class InterfaceProvisionRelationProcessorTest extends RelationProcessorTest, Interface> { @Override - protected InterfaceProvisionRelation createRelation(Component source, Interface destination, - boolean isPlaceholder) { + protected InterfaceProvisionRelation createRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { return new InterfaceProvisionRelation(source, destination, isPlaceholder); } @@ -22,7 +22,7 @@ protected Component getUniqueNonPlaceholderSourceEntity() { } @Override - protected Component getPlaceholderOfSourceEntity(Component source) { + protected Component getPlaceholderOfSourceEntity(final Component source) { return new Component<>(source.getValue(), true); } @@ -32,12 +32,12 @@ protected Interface getUniqueNonPlaceholderDestinationEntity() { } @Override - protected Interface getPlaceholderOfDestinationEntity(Interface destination) { + protected Interface getPlaceholderOfDestinationEntity(final Interface destination) { return new Interface(destination.getValue(), true); } @Override - protected InterfaceProvisionRelationProcessor createProcessor(PcmSurrogate model) { + protected InterfaceProvisionRelationProcessor createProcessor(final PcmSurrogate model) { return new InterfaceProvisionRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java index 0fb134d0..a17ab84e 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java @@ -11,8 +11,8 @@ public class InterfaceRequirementRelationProcessorTest extends RelationProcessorTest, Interface> { @Override - protected InterfaceRequirementRelation createRelation(Component source, Interface destination, - boolean isPlaceholder) { + protected InterfaceRequirementRelation createRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { return new InterfaceRequirementRelation(source, destination, isPlaceholder); } @@ -22,7 +22,7 @@ protected Component getUniqueNonPlaceholderSourceEntity() { } @Override - protected Component getPlaceholderOfSourceEntity(Component source) { + protected Component getPlaceholderOfSourceEntity(final Component source) { return new Component<>(source.getValue(), true); } @@ -32,12 +32,12 @@ protected Interface getUniqueNonPlaceholderDestinationEntity() { } @Override - protected Interface getPlaceholderOfDestinationEntity(Interface destination) { + protected Interface getPlaceholderOfDestinationEntity(final Interface destination) { return new Interface(destination.getValue(), true); } @Override - protected InterfaceRequirementRelationProcessor createProcessor(PcmSurrogate model) { + protected InterfaceRequirementRelationProcessor createProcessor(final PcmSurrogate model) { return new InterfaceRequirementRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java index 6600d58b..6d141091 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java @@ -12,8 +12,8 @@ public class LinkResourceSpecificationRelationProcessorTest extends RelationProcessorTest { @Override - protected LinkResourceSpecificationRelation createRelation(LinkResourceSpecification source, - DeploymentDeploymentRelation destination, boolean isPlaceholder) { + protected LinkResourceSpecificationRelation createRelation(final LinkResourceSpecification source, + final DeploymentDeploymentRelation destination, final boolean isPlaceholder) { return new LinkResourceSpecificationRelation(source, destination, isPlaceholder); } @@ -23,7 +23,7 @@ protected LinkResourceSpecification getUniqueNonPlaceholderSourceEntity() { } @Override - protected LinkResourceSpecification getPlaceholderOfSourceEntity(LinkResourceSpecification source) { + protected LinkResourceSpecification getPlaceholderOfSourceEntity(final LinkResourceSpecification source) { return new LinkResourceSpecification(source.getValue(), true); } @@ -34,12 +34,13 @@ protected DeploymentDeploymentRelation getUniqueNonPlaceholderDestinationEntity( } @Override - protected DeploymentDeploymentRelation getPlaceholderOfDestinationEntity(DeploymentDeploymentRelation destination) { + protected DeploymentDeploymentRelation getPlaceholderOfDestinationEntity( + final DeploymentDeploymentRelation destination) { return new DeploymentDeploymentRelation(destination.getSource(), destination.getDestination(), true); } @Override - protected LinkResourceSpecificationRelationProcessor createProcessor(PcmSurrogate model) { + protected LinkResourceSpecificationRelationProcessor createProcessor(final PcmSurrogate model) { return new LinkResourceSpecificationRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java index 626ab095..651e2920 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java @@ -16,25 +16,25 @@ public class ServiceEffectSpecificationRelationProcessorTest extends RelationProcessorTest { @Override - protected ServiceEffectSpecificationRelation createRelation(ComponentSignatureProvisionRelation source, - ServiceEffectSpecification destination, boolean isPlaceholder) { + protected ServiceEffectSpecificationRelation createRelation(final ComponentSignatureProvisionRelation source, + final ServiceEffectSpecification destination, final boolean isPlaceholder) { return new ServiceEffectSpecificationRelation(source, destination, isPlaceholder); } @Override protected ComponentSignatureProvisionRelation getUniqueNonPlaceholderSourceEntity() { - Component component = Component.getUniquePlaceholder(); - Interface interfsc = Interface.getUniquePlaceholder(); - Signature signature = Signature.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, interfsc, true); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, interfsc, true); + final Component component = Component.getUniquePlaceholder(); + final Interface interfsc = Interface.getUniquePlaceholder(); + final Signature signature = Signature.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, interfsc, true); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, interfsc, true); return new ComponentSignatureProvisionRelation(interfaceProvision, signatureProvision, false); } @Override protected ComponentSignatureProvisionRelation getPlaceholderOfSourceEntity( - ComponentSignatureProvisionRelation source) { + final ComponentSignatureProvisionRelation source) { return new ComponentSignatureProvisionRelation(source.getSource(), source.getDestination(), true); } @@ -44,12 +44,13 @@ protected ServiceEffectSpecification getUniqueNonPlaceholderDestinationEntity() } @Override - protected ServiceEffectSpecification getPlaceholderOfDestinationEntity(ServiceEffectSpecification destination) { + protected ServiceEffectSpecification getPlaceholderOfDestinationEntity( + final ServiceEffectSpecification destination) { return new ServiceEffectSpecification(destination.getValue(), true); } @Override - protected ServiceEffectSpecificationRelationProcessor createProcessor(PcmSurrogate model) { + protected ServiceEffectSpecificationRelationProcessor createProcessor(final PcmSurrogate model) { return new ServiceEffectSpecificationRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java index d5026d78..cde992df 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java @@ -11,8 +11,8 @@ public class SignatureProvisionRelationProcessorTest extends RelationProcessorTest { @Override - protected SignatureProvisionRelation createRelation(Signature source, Interface destination, - boolean isPlaceholder) { + protected SignatureProvisionRelation createRelation(final Signature source, final Interface destination, + final boolean isPlaceholder) { return new SignatureProvisionRelation(source, destination, isPlaceholder); } @@ -22,7 +22,7 @@ protected Signature getUniqueNonPlaceholderSourceEntity() { } @Override - protected Signature getPlaceholderOfSourceEntity(Signature source) { + protected Signature getPlaceholderOfSourceEntity(final Signature source) { return new Signature(source.getValue(), true); } @@ -32,12 +32,12 @@ protected Interface getUniqueNonPlaceholderDestinationEntity() { } @Override - protected Interface getPlaceholderOfDestinationEntity(Interface destination) { + protected Interface getPlaceholderOfDestinationEntity(final Interface destination) { return new Interface(destination.getValue(), true); } @Override - protected SignatureProvisionRelationProcessor createProcessor(PcmSurrogate model) { + protected SignatureProvisionRelationProcessor createProcessor(final PcmSurrogate model) { return new SignatureProvisionRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogateTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogateTest.java index 763ad045..ffa25658 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogateTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogateTest.java @@ -17,8 +17,8 @@ protected SimpleElement createUniqueReplaceable() { } @Override - protected Relation createRelation(SimpleElement source, SimpleElement destination, - boolean isPlaceholder) { + protected Relation createRelation(final SimpleElement source, + final SimpleElement destination, final boolean isPlaceholder) { return new SimpleRelation(source, destination, isPlaceholder); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponentTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponentTest.java index 6d22fb51..59762aab 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponentTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponentTest.java @@ -8,14 +8,14 @@ public class AtomicComponentTest extends ElementTest { @Override - protected AtomicComponent createElement(BasicComponent value, boolean isPlaceholder) { + protected AtomicComponent createElement(final BasicComponent value, final boolean isPlaceholder) { return new AtomicComponent(value, isPlaceholder); } @Override protected BasicComponent getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - BasicComponent value = new FluentRepositoryFactory().newBasicComponent() + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final BasicComponent value = new FluentRepositoryFactory().newBasicComponent() .withName(identifier) .build(); return value; @@ -23,11 +23,11 @@ protected BasicComponent getUniqueValue() { @Override protected AtomicComponent getUniqueNonPlaceholder() { - return new AtomicComponent(getUniqueValue(), false); + return new AtomicComponent(this.getUniqueValue(), false); } @Override - protected AtomicComponent getPlaceholderOf(AtomicComponent replaceable) { + protected AtomicComponent getPlaceholderOf(final AtomicComponent replaceable) { return new AtomicComponent(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ComponentTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ComponentTest.java index 0bb0a8dc..55aad3c6 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ComponentTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ComponentTest.java @@ -9,14 +9,15 @@ public class ComponentTest extends ElementTest, RepositoryComponent> { @Override - protected Component createElement(RepositoryComponent value, boolean isPlaceholder) { + protected Component createElement(final RepositoryComponent value, + final boolean isPlaceholder) { return new Component<>(value, isPlaceholder); } @Override protected RepositoryComponent getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - BasicComponent value = new FluentRepositoryFactory().newBasicComponent() + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final BasicComponent value = new FluentRepositoryFactory().newBasicComponent() .withName(identifier) .build(); return value; @@ -24,11 +25,11 @@ protected RepositoryComponent getUniqueValue() { @Override protected Component getUniqueNonPlaceholder() { - return new Component<>(getUniqueValue(), false); + return new Component<>(this.getUniqueValue(), false); } @Override - protected Component getPlaceholderOf(Component replaceable) { + protected Component getPlaceholderOf(final Component replaceable) { return new Component<>(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/CompositeTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/CompositeTest.java index 4e1bc42a..b3a41d0a 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/CompositeTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/CompositeTest.java @@ -9,14 +9,14 @@ public class CompositeTest extends ElementTest { @Override - protected Composite createElement(CompositeComponent value, boolean isPlaceholder) { + protected Composite createElement(final CompositeComponent value, final boolean isPlaceholder) { return new Composite(value, isPlaceholder); } @Override protected CompositeComponent getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() .withName(identifier) .build(); return (CompositeComponent) value; @@ -24,11 +24,11 @@ protected CompositeComponent getUniqueValue() { @Override protected Composite getUniqueNonPlaceholder() { - return new Composite(getUniqueValue(), false); + return new Composite(this.getUniqueValue(), false); } @Override - protected Composite getPlaceholderOf(Composite replaceable) { + protected Composite getPlaceholderOf(final Composite replaceable) { return new Composite(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/DeploymentTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/DeploymentTest.java index 2fbbe7fa..fdb61ebd 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/DeploymentTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/DeploymentTest.java @@ -8,25 +8,25 @@ public class DeploymentTest extends ElementTest { @Override - protected Deployment createElement(ResourceContainer value, boolean isPlaceholder) { + protected Deployment createElement(final ResourceContainer value, final boolean isPlaceholder) { return new Deployment(value, isPlaceholder); } @Override protected ResourceContainer getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); value.setEntityName(identifier); return value; } @Override protected Deployment getUniqueNonPlaceholder() { - return new Deployment(getUniqueValue(), false); + return new Deployment(this.getUniqueValue(), false); } @Override - protected Deployment getPlaceholderOf(Deployment replaceable) { + protected Deployment getPlaceholderOf(final Deployment replaceable) { return new Deployment(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/InterfaceTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/InterfaceTest.java index 03a56b82..6d3d155a 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/InterfaceTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/InterfaceTest.java @@ -8,14 +8,14 @@ public class InterfaceTest extends ElementTest { @Override - protected Interface createElement(OperationInterface value, boolean isPlaceholder) { + protected Interface createElement(final OperationInterface value, final boolean isPlaceholder) { return new Interface(value, isPlaceholder); } @Override protected OperationInterface getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - OperationInterface value = new FluentRepositoryFactory().newOperationInterface() + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final OperationInterface value = new FluentRepositoryFactory().newOperationInterface() .withName(identifier) .build(); return value; @@ -23,11 +23,11 @@ protected OperationInterface getUniqueValue() { @Override protected Interface getUniqueNonPlaceholder() { - return new Interface(getUniqueValue(), false); + return new Interface(this.getUniqueValue(), false); } @Override - protected Interface getPlaceholderOf(Interface replaceable) { + protected Interface getPlaceholderOf(final Interface replaceable) { return new Interface(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecificationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecificationTest.java index f3b6b655..198ee4f3 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecificationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecificationTest.java @@ -7,8 +7,8 @@ public class LinkResourceSpecificationTest extends ElementTest { @Override - protected LinkResourceSpecification createElement(CommunicationLinkResourceSpecification value, - boolean isPlaceholder) { + protected LinkResourceSpecification createElement(final CommunicationLinkResourceSpecification value, + final boolean isPlaceholder) { return new LinkResourceSpecification(value, isPlaceholder); } @@ -20,11 +20,11 @@ protected CommunicationLinkResourceSpecification getUniqueValue() { @Override protected LinkResourceSpecification getUniqueNonPlaceholder() { - return new LinkResourceSpecification(getUniqueValue(), false); + return new LinkResourceSpecification(this.getUniqueValue(), false); } @Override - protected LinkResourceSpecification getPlaceholderOf(LinkResourceSpecification replaceable) { + protected LinkResourceSpecification getPlaceholderOf(final LinkResourceSpecification replaceable) { return new LinkResourceSpecification(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecificationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecificationTest.java index 8b975b15..c8c77119 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecificationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecificationTest.java @@ -7,7 +7,7 @@ public class ServiceEffectSpecificationTest extends ElementTest { @Override - protected ServiceEffectSpecification createElement(ResourceDemandingSEFF value, boolean isPlaceholder) { + protected ServiceEffectSpecification createElement(final ResourceDemandingSEFF value, final boolean isPlaceholder) { return new ServiceEffectSpecification(value, isPlaceholder); } @@ -19,11 +19,11 @@ protected ResourceDemandingSEFF getUniqueValue() { @Override protected ServiceEffectSpecification getUniqueNonPlaceholder() { - return new ServiceEffectSpecification(getUniqueValue(), false); + return new ServiceEffectSpecification(this.getUniqueValue(), false); } @Override - protected ServiceEffectSpecification getPlaceholderOf(ServiceEffectSpecification replaceable) { + protected ServiceEffectSpecification getPlaceholderOf(final ServiceEffectSpecification replaceable) { return new ServiceEffectSpecification(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/SignatureTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/SignatureTest.java index 69ad3d14..8f0b27f4 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/SignatureTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/SignatureTest.java @@ -8,25 +8,25 @@ public class SignatureTest extends ElementTest { @Override - protected Signature createElement(OperationSignature value, boolean isPlaceholder) { + protected Signature createElement(final OperationSignature value, final boolean isPlaceholder) { return new Signature(value, isPlaceholder); } @Override protected OperationSignature getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); value.setEntityName(identifier); return value; } @Override protected Signature getUniqueNonPlaceholder() { - return new Signature(getUniqueValue(), false); + return new Signature(this.getUniqueValue(), false); } @Override - protected Signature getPlaceholderOf(Signature replaceable) { + protected Signature getPlaceholderOf(final Signature replaceable) { return new Signature(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelationTest.java index 48842cd9..56df20cc 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelationTest.java @@ -8,8 +8,8 @@ public class ComponentAllocationRelationTest extends RelationTest, Deployment> { @Override - protected ComponentAllocationRelation createRelation(Component source, Deployment destination, - boolean isPlaceholder) { + protected ComponentAllocationRelation createRelation(final Component source, final Deployment destination, + final boolean isPlaceholder) { return new ComponentAllocationRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelationTest.java index 8215b09a..0f632341 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelationTest.java @@ -10,20 +10,20 @@ public class ComponentAssemblyRelationTest private static final Interface RELATION_DESTINATION = Interface.getUniquePlaceholder(); @Override - protected ComponentAssemblyRelation createRelation(InterfaceProvisionRelation source, - InterfaceRequirementRelation destination, boolean isPlaceholder) { + protected ComponentAssemblyRelation createRelation(final InterfaceProvisionRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { return new ComponentAssemblyRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueSourceEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_DESTINATION, true); } @Override protected InterfaceRequirementRelation getUniqueDestinationEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_DESTINATION, true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java index bcf7275e..f3e5de6c 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java @@ -11,20 +11,20 @@ public class ComponentSignatureProvisionRelationTest extends private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); @Override - protected ComponentSignatureProvisionRelation createRelation(InterfaceProvisionRelation source, - SignatureProvisionRelation destination, boolean isPlaceholder) { + protected ComponentSignatureProvisionRelation createRelation(final InterfaceProvisionRelation source, + final SignatureProvisionRelation destination, final boolean isPlaceholder) { return new ComponentSignatureProvisionRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueSourceEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, true); } @Override protected SignatureProvisionRelation getUniqueDestinationEntity() { - Signature signature = Signature.getUniquePlaceholder(); + final Signature signature = Signature.getUniquePlaceholder(); return new SignatureProvisionRelation(signature, RELATION_INTERFACE, true); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java index d6ed1559..9053ae64 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java @@ -16,7 +16,7 @@ public class CompositeProvisionDelegationRelationTest extends @Test public void testConstructorWithEqualSourceAndDestinationRelation() { - InterfaceProvisionRelation entity = getUniqueSourceEntity(); + final InterfaceProvisionRelation entity = this.getUniqueSourceEntity(); assertThrows(IllegalArgumentException.class, () -> new CompositeProvisionDelegationRelation(entity, entity, false)); @@ -24,10 +24,11 @@ public void testConstructorWithEqualSourceAndDestinationRelation() { @Test public void testConstructorWithoutSourceCompositeComponent() { - AtomicComponent sourceComponent = AtomicComponent.getUniquePlaceholder(); - Composite destinationComponent = Composite.getUniquePlaceholder(); - InterfaceProvisionRelation source = new InterfaceProvisionRelation(sourceComponent, RELATION_INTERFACE, true); - InterfaceProvisionRelation destination = new InterfaceProvisionRelation(destinationComponent, + final AtomicComponent sourceComponent = AtomicComponent.getUniquePlaceholder(); + final Composite destinationComponent = Composite.getUniquePlaceholder(); + final InterfaceProvisionRelation source = new InterfaceProvisionRelation(sourceComponent, RELATION_INTERFACE, + true); + final InterfaceProvisionRelation destination = new InterfaceProvisionRelation(destinationComponent, RELATION_INTERFACE, true); assertThrows(IllegalArgumentException.class, @@ -36,10 +37,10 @@ public void testConstructorWithoutSourceCompositeComponent() { @Test public void testConstructorWithDifferentRequirementInterfaces() { - InterfaceProvisionRelation source = getUniqueSourceEntity(); - Component destinationComponent = AtomicComponent.getUniquePlaceholder(); - Interface destinationInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation destination = new InterfaceProvisionRelation(destinationComponent, + final InterfaceProvisionRelation source = this.getUniqueSourceEntity(); + final Component destinationComponent = AtomicComponent.getUniquePlaceholder(); + final Interface destinationInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation destination = new InterfaceProvisionRelation(destinationComponent, destinationInterface, true); assertThrows(IllegalArgumentException.class, @@ -47,20 +48,20 @@ public void testConstructorWithDifferentRequirementInterfaces() { } @Override - protected CompositeProvisionDelegationRelation createRelation(InterfaceProvisionRelation source, - InterfaceProvisionRelation destination, boolean isPlaceholder) { + protected CompositeProvisionDelegationRelation createRelation(final InterfaceProvisionRelation source, + final InterfaceProvisionRelation destination, final boolean isPlaceholder) { return new CompositeProvisionDelegationRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueSourceEntity() { - Composite source = Composite.getUniquePlaceholder(); + final Composite source = Composite.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, true); } @Override protected InterfaceProvisionRelation getUniqueDestinationEntity() { - Component source = AtomicComponent.getUniquePlaceholder(); + final Component source = AtomicComponent.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java index 72cbfb2d..5c5864f4 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java @@ -16,7 +16,7 @@ public class CompositeRequirementDelegationRelationTest extends @Test public void testConstructorWithEqualSourceAndDestinationRelation() { - InterfaceRequirementRelation entity = getUniqueSourceEntity(); + final InterfaceRequirementRelation entity = this.getUniqueSourceEntity(); assertThrows(IllegalArgumentException.class, () -> new CompositeRequirementDelegationRelation(entity, entity, false)); @@ -24,11 +24,11 @@ public void testConstructorWithEqualSourceAndDestinationRelation() { @Test public void testConstructorWithoutSourceCompositeComponent() { - AtomicComponent sourceComponent = AtomicComponent.getUniquePlaceholder(); - Composite destinationComponent = Composite.getUniquePlaceholder(); - InterfaceRequirementRelation source = new InterfaceRequirementRelation(sourceComponent, RELATION_INTERFACE, - true); - InterfaceRequirementRelation destination = new InterfaceRequirementRelation(destinationComponent, + final AtomicComponent sourceComponent = AtomicComponent.getUniquePlaceholder(); + final Composite destinationComponent = Composite.getUniquePlaceholder(); + final InterfaceRequirementRelation source = new InterfaceRequirementRelation(sourceComponent, + RELATION_INTERFACE, true); + final InterfaceRequirementRelation destination = new InterfaceRequirementRelation(destinationComponent, RELATION_INTERFACE, true); assertThrows(IllegalArgumentException.class, @@ -37,10 +37,10 @@ public void testConstructorWithoutSourceCompositeComponent() { @Test public void testConstructorWithDifferentRequirementInterfaces() { - InterfaceRequirementRelation source = getUniqueSourceEntity(); - Component destinationComponent = AtomicComponent.getUniquePlaceholder(); - Interface destinationInterface = Interface.getUniquePlaceholder(); - InterfaceRequirementRelation destination = new InterfaceRequirementRelation(destinationComponent, + final InterfaceRequirementRelation source = this.getUniqueSourceEntity(); + final Component destinationComponent = AtomicComponent.getUniquePlaceholder(); + final Interface destinationInterface = Interface.getUniquePlaceholder(); + final InterfaceRequirementRelation destination = new InterfaceRequirementRelation(destinationComponent, destinationInterface, true); assertThrows(IllegalArgumentException.class, @@ -48,20 +48,20 @@ public void testConstructorWithDifferentRequirementInterfaces() { } @Override - protected CompositeRequirementDelegationRelation createRelation(InterfaceRequirementRelation source, - InterfaceRequirementRelation destination, boolean isPlaceholder) { + protected CompositeRequirementDelegationRelation createRelation(final InterfaceRequirementRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { return new CompositeRequirementDelegationRelation(source, destination, isPlaceholder); } @Override protected InterfaceRequirementRelation getUniqueSourceEntity() { - Composite source = Composite.getUniquePlaceholder(); + final Composite source = Composite.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_INTERFACE, true); } @Override protected InterfaceRequirementRelation getUniqueDestinationEntity() { - Component source = AtomicComponent.getUniquePlaceholder(); + final Component source = AtomicComponent.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_INTERFACE, true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelationTest.java index 7b6980d2..26e7c76e 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelationTest.java @@ -7,7 +7,8 @@ public class CompositionRelationTest extends RelationTest> { @Override - protected CompositionRelation createRelation(Composite source, Component destination, boolean isPlaceholder) { + protected CompositionRelation createRelation(final Composite source, final Component destination, + final boolean isPlaceholder) { return new CompositionRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java index 64ce3645..e54a6fda 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java @@ -7,8 +7,8 @@ public class DeploymentDeploymentRelationTest extends RelationTest { @Override - protected DeploymentDeploymentRelation createRelation(Deployment source, Deployment destination, - boolean isPlaceholder) { + protected DeploymentDeploymentRelation createRelation(final Deployment source, final Deployment destination, + final boolean isPlaceholder) { return new DeploymentDeploymentRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelationTest.java index df05576e..e42ce3ad 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelationTest.java @@ -7,8 +7,8 @@ public class InterfaceProvisionRelationTest extends RelationTest, Interface> { @Override - protected InterfaceProvisionRelation createRelation(Component source, Interface destination, - boolean isPlaceholder) { + protected InterfaceProvisionRelation createRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { return new InterfaceProvisionRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelationTest.java index d53c8c96..3b265ed5 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelationTest.java @@ -8,8 +8,8 @@ public class InterfaceRequirementRelationTest extends RelationTest, Interface> { @Override - protected InterfaceRequirementRelation createRelation(Component source, Interface destination, - boolean isPlaceholder) { + protected InterfaceRequirementRelation createRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { return new InterfaceRequirementRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java index 99458d86..63e644d5 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java @@ -8,8 +8,8 @@ public class LinkResourceSpecificationRelationTest extends RelationTest { @Override - protected LinkResourceSpecificationRelation createRelation(LinkResourceSpecification source, - DeploymentDeploymentRelation destination, boolean isPlaceholder) { + protected LinkResourceSpecificationRelation createRelation(final LinkResourceSpecification source, + final DeploymentDeploymentRelation destination, final boolean isPlaceholder) { return new LinkResourceSpecificationRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java index 0bf71100..15b56cd6 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java @@ -10,18 +10,18 @@ public class ServiceEffectSpecificationRelationTest extends RelationTest { @Override - protected ServiceEffectSpecificationRelation createRelation(ComponentSignatureProvisionRelation source, - ServiceEffectSpecification destination, boolean isPlaceholder) { + protected ServiceEffectSpecificationRelation createRelation(final ComponentSignatureProvisionRelation source, + final ServiceEffectSpecification destination, final boolean isPlaceholder) { return new ServiceEffectSpecificationRelation(source, destination, isPlaceholder); } @Override protected ComponentSignatureProvisionRelation getUniqueSourceEntity() { - Component component = Component.getUniquePlaceholder(); - Interface interfsc = Interface.getUniquePlaceholder(); - Signature signature = Signature.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, interfsc, true); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, interfsc, true); + final Component component = Component.getUniquePlaceholder(); + final Interface interfsc = Interface.getUniquePlaceholder(); + final Signature signature = Signature.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, interfsc, true); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, interfsc, true); return new ComponentSignatureProvisionRelation(interfaceProvision, signatureProvision, false); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelationTest.java index 00a2cf60..f632a28c 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelationTest.java @@ -7,8 +7,8 @@ public class SignatureProvisionRelationTest extends RelationTest { @Override - protected SignatureProvisionRelation createRelation(Signature source, Interface destination, - boolean isPlaceholder) { + protected SignatureProvisionRelation createRelation(final Signature source, final Interface destination, + final boolean isPlaceholder) { return new SignatureProvisionRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformerTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformerTest.java index 8be9a173..055e6d30 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformerTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformerTest.java @@ -17,13 +17,13 @@ public class AllocationTransformerTest extends TransformerTest { @ParameterizedTest @ValueSource(booleans = { true, false }) - public void testTransformSingleAllocation(boolean isPlaceholderAllocation) { + public void testTransformSingleAllocation(final boolean isPlaceholderAllocation) { // Test data - AllocationTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component component = Component.getUniquePlaceholder(); - Deployment deployment = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation allocationRelation = new ComponentAllocationRelation(component, deployment, + final AllocationTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component component = Component.getUniquePlaceholder(); + final Deployment deployment = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation allocationRelation = new ComponentAllocationRelation(component, deployment, isPlaceholderAllocation); model.add(component); @@ -31,7 +31,7 @@ public void testTransformSingleAllocation(boolean isPlaceholderAllocation) { model.add(allocationRelation); // Execution - Allocation allocation = transformer.transform(model); + final Allocation allocation = transformer.transform(model); // Assertion assertNotNull(allocation); diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformerTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformerTest.java index 9c7852df..2801c6d0 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformerTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformerTest.java @@ -28,14 +28,14 @@ public class RepositoryTransformerTest extends TransformerTest provider = Component.getUniquePlaceholder(); - Interface providerInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, providerInterface, - isPlaceholderRelation); + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component provider = Component.getUniquePlaceholder(); + final Interface providerInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, + providerInterface, isPlaceholderRelation); model.add(provider); model.add(providerInterface); model.add(interfaceProvision); // Execution - Repository repository = transformer.transform(model); + final Repository repository = transformer.transform(model); // Assertion assertNotNull(repository); @@ -179,13 +179,13 @@ public void testTransformInterfaceProvision(boolean isPlaceholderRelation) { @ParameterizedTest @ValueSource(booleans = { true, false }) - public void testTransformInterfaceRequirement(boolean isPlaceholderRelation) { + public void testTransformInterfaceRequirement(final boolean isPlaceholderRelation) { // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component consumer = Component.getUniquePlaceholder(); - Interface consumerInterface = Interface.getUniquePlaceholder(); - InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component consumer = Component.getUniquePlaceholder(); + final Interface consumerInterface = Interface.getUniquePlaceholder(); + final InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, consumerInterface, isPlaceholderRelation); model.add(consumer); @@ -193,7 +193,7 @@ public void testTransformInterfaceRequirement(boolean isPlaceholderRelation) { model.add(interfaceRequirement); // Execution - Repository repository = transformer.transform(model); + final Repository repository = transformer.transform(model); // Assertion assertNotNull(repository); @@ -204,17 +204,17 @@ public void testTransformInterfaceRequirement(boolean isPlaceholderRelation) { @ParameterizedTest @ValueSource(booleans = { true, false }) - public void testTransformSignatureProvision(boolean isPlaceholderRelation) { + public void testTransformSignatureProvision(final boolean isPlaceholderRelation) { // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component provider = Component.getUniquePlaceholder(); - Interface providerInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, providerInterface, - false); - Signature signature = Signature.getUniquePlaceholder(); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, providerInterface, - isPlaceholderRelation); + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component provider = Component.getUniquePlaceholder(); + final Interface providerInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, + providerInterface, false); + final Signature signature = Signature.getUniquePlaceholder(); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, + providerInterface, isPlaceholderRelation); model.add(provider); model.add(providerInterface); @@ -223,7 +223,7 @@ public void testTransformSignatureProvision(boolean isPlaceholderRelation) { model.add(signatureProvision); // Execution - Repository repository = transformer.transform(model); + final Repository repository = transformer.transform(model); // Assertion assertNotNull(repository); @@ -235,21 +235,21 @@ public void testTransformSignatureProvision(boolean isPlaceholderRelation) { @ParameterizedTest @ValueSource(booleans = { true, false }) - public void testTransformComponentSignatureProvisionWithSeff(boolean isPlaceholderRelation) { + public void testTransformComponentSignatureProvisionWithSeff(final boolean isPlaceholderRelation) { // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component provider = Component.getUniquePlaceholder(); - Interface providerInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, providerInterface, - false); - Signature signature = Signature.getUniquePlaceholder(); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, providerInterface, - false); - ComponentSignatureProvisionRelation componentSignatureProvisionRelation = new ComponentSignatureProvisionRelation( + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component provider = Component.getUniquePlaceholder(); + final Interface providerInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, + providerInterface, false); + final Signature signature = Signature.getUniquePlaceholder(); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, + providerInterface, false); + final ComponentSignatureProvisionRelation componentSignatureProvisionRelation = new ComponentSignatureProvisionRelation( interfaceProvision, signatureProvision, false); - ServiceEffectSpecification seff = ServiceEffectSpecification.getUniquePlaceholder(); - ServiceEffectSpecificationRelation seffRelation = new ServiceEffectSpecificationRelation( + final ServiceEffectSpecification seff = ServiceEffectSpecification.getUniquePlaceholder(); + final ServiceEffectSpecificationRelation seffRelation = new ServiceEffectSpecificationRelation( componentSignatureProvisionRelation, seff, isPlaceholderRelation); model.add(provider); @@ -262,7 +262,7 @@ public void testTransformComponentSignatureProvisionWithSeff(boolean isPlacehold model.add(seffRelation); // Execution - Repository repository = transformer.transform(model); + final Repository repository = transformer.transform(model); // Assertion assertNotNull(repository); diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformerTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformerTest.java index 86506a06..a9c77f10 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformerTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformerTest.java @@ -21,12 +21,12 @@ public class ResourceEnvironmentTransformerTest @Test public void testTransformIndependentPlaceholderContainers() { // Test data - ResourceEnvironmentTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Deployment fstDeployment = Deployment.getUniquePlaceholder(); - Deployment sndDeployment = Deployment.getUniquePlaceholder(); - Deployment trdDeployment = Deployment.getUniquePlaceholder(); - Deployment fthDeployment = Deployment.getUniquePlaceholder(); + final ResourceEnvironmentTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Deployment fstDeployment = Deployment.getUniquePlaceholder(); + final Deployment sndDeployment = Deployment.getUniquePlaceholder(); + final Deployment trdDeployment = Deployment.getUniquePlaceholder(); + final Deployment fthDeployment = Deployment.getUniquePlaceholder(); model.add(fstDeployment); model.add(sndDeployment); @@ -34,7 +34,7 @@ public void testTransformIndependentPlaceholderContainers() { model.add(fthDeployment); // Execution - ResourceEnvironment environment = transformer.transform(model); + final ResourceEnvironment environment = transformer.transform(model); // Assertion assertNotNull(environment); @@ -47,23 +47,23 @@ public void testTransformIndependentPlaceholderContainers() { @Test public void testTransformConnectedPlaceholderContainers() { // Test data - ResourceEnvironmentTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Deployment fstDeployment = Deployment.getUniquePlaceholder(); - Deployment sndDeployment = Deployment.getUniquePlaceholder(); - Deployment trdDeployment = Deployment.getUniquePlaceholder(); - - DeploymentDeploymentRelation fstLinkRelation = new DeploymentDeploymentRelation(fstDeployment, sndDeployment, - false); - DeploymentDeploymentRelation sndLinkRelation = new DeploymentDeploymentRelation(sndDeployment, trdDeployment, - true); - - LinkResourceSpecification fstLinkSpecification = LinkResourceSpecification.getUniquePlaceholder(); - LinkResourceSpecificationRelation fstLinkSpecificationRelation = new LinkResourceSpecificationRelation( + final ResourceEnvironmentTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Deployment fstDeployment = Deployment.getUniquePlaceholder(); + final Deployment sndDeployment = Deployment.getUniquePlaceholder(); + final Deployment trdDeployment = Deployment.getUniquePlaceholder(); + + final DeploymentDeploymentRelation fstLinkRelation = new DeploymentDeploymentRelation(fstDeployment, + sndDeployment, false); + final DeploymentDeploymentRelation sndLinkRelation = new DeploymentDeploymentRelation(sndDeployment, + trdDeployment, true); + + final LinkResourceSpecification fstLinkSpecification = LinkResourceSpecification.getUniquePlaceholder(); + final LinkResourceSpecificationRelation fstLinkSpecificationRelation = new LinkResourceSpecificationRelation( fstLinkSpecification, fstLinkRelation, false); - LinkResourceSpecification sndLinkSpecification = LinkResourceSpecification.getUniquePlaceholder(); - LinkResourceSpecificationRelation sndLinkSpecificationRelation = new LinkResourceSpecificationRelation( + final LinkResourceSpecification sndLinkSpecification = LinkResourceSpecification.getUniquePlaceholder(); + final LinkResourceSpecificationRelation sndLinkSpecificationRelation = new LinkResourceSpecificationRelation( sndLinkSpecification, sndLinkRelation, true); model.add(fstDeployment); @@ -75,7 +75,7 @@ public void testTransformConnectedPlaceholderContainers() { model.add(sndLinkSpecificationRelation); // Execution - ResourceEnvironment environment = transformer.transform(model); + final ResourceEnvironment environment = transformer.transform(model); // Assertion assertNotNull(environment); diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformerTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformerTest.java index 636c7918..ff85f57e 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformerTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformerTest.java @@ -21,14 +21,14 @@ public class SystemTransformerTest extends TransformerTest component = Component.getUniquePlaceholder(); + final SystemTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component component = Component.getUniquePlaceholder(); model.add(component); // Execution - System system = transformer.transform(model); + final System system = transformer.transform(model); // Assertion assertNotNull(system); @@ -37,19 +37,19 @@ public void testTransformSingleComponent() { @ParameterizedTest @ValueSource(booleans = { true, false }) - public void testTransformSingleAssemblyRelation(boolean isPlaceholderAssembly) { + public void testTransformSingleAssemblyRelation(final boolean isPlaceholderAssembly) { // Test data - SystemTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); + final SystemTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); - Component provider = Component.getUniquePlaceholder(); - Component consumer = Component.getUniquePlaceholder(); - Interface providerConsumerInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation provisionRelation = new InterfaceProvisionRelation(provider, + final Component provider = Component.getUniquePlaceholder(); + final Component consumer = Component.getUniquePlaceholder(); + final Interface providerConsumerInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation provisionRelation = new InterfaceProvisionRelation(provider, providerConsumerInterface, false); - InterfaceRequirementRelation requirementRelation = new InterfaceRequirementRelation(consumer, + final InterfaceRequirementRelation requirementRelation = new InterfaceRequirementRelation(consumer, providerConsumerInterface, false); - ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, + final ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, requirementRelation, isPlaceholderAssembly); model.add(provider); @@ -60,7 +60,7 @@ public void testTransformSingleAssemblyRelation(boolean isPlaceholderAssembly) { model.add(assemblyRelation); // Execution - System system = transformer.transform(model); + final System system = transformer.transform(model); // Assertion assertNotNull(system); diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/ElementFactory.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/ElementFactory.java index ff4551ec..17dead4f 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/ElementFactory.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/ElementFactory.java @@ -26,54 +26,54 @@ private ElementFactory() { throw new IllegalStateException("Cannot instantiate utility class."); } - public static Signature createUniqueSignature(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); + public static Signature createUniqueSignature(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); value.setEntityName(identifier); return new Signature(value, isPlaceholder); } - public static Interface createUniqueInterface(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - OperationInterface value = new FluentRepositoryFactory().newOperationInterface() + public static Interface createUniqueInterface(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final OperationInterface value = new FluentRepositoryFactory().newOperationInterface() .withName(identifier) .build(); return new Interface(value, isPlaceholder); } - public static Component createUniqueComponent(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - BasicComponent value = new FluentRepositoryFactory().newBasicComponent() + public static Component createUniqueComponent(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final BasicComponent value = new FluentRepositoryFactory().newBasicComponent() .withName(identifier) .build(); return new AtomicComponent(value, isPlaceholder); } - public static Composite createUniqueComposite(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() + public static Composite createUniqueComposite(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() .withName(identifier) .build(); return new Composite((CompositeComponent) value, isPlaceholder); } - public static Deployment createUniqueDeployment(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); + public static Deployment createUniqueDeployment(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); value.setEntityName(identifier); return new Deployment(value, isPlaceholder); } - public static LinkResourceSpecification createUniqueLinkResourceSpecification(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - CommunicationLinkResourceSpecification value = ResourceenvironmentFactory.eINSTANCE + public static LinkResourceSpecification createUniqueLinkResourceSpecification(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final CommunicationLinkResourceSpecification value = ResourceenvironmentFactory.eINSTANCE .createCommunicationLinkResourceSpecification(); value.setId(identifier); return new LinkResourceSpecification(value, isPlaceholder); } - public static ServiceEffectSpecification createUniqueServiceEffectSpecification(boolean isPlaceholder) { - ServiceEffectSpecification placeholderSpecification = ServiceEffectSpecification.getUniquePlaceholder(); + public static ServiceEffectSpecification createUniqueServiceEffectSpecification(final boolean isPlaceholder) { + final ServiceEffectSpecification placeholderSpecification = ServiceEffectSpecification.getUniquePlaceholder(); return new ServiceEffectSpecification(placeholderSpecification.getValue(), isPlaceholder); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/PcmEvaluationUtility.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/PcmEvaluationUtility.java index 2cf1f3b3..ab0c0350 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/PcmEvaluationUtility.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/PcmEvaluationUtility.java @@ -52,7 +52,7 @@ private PcmEvaluationUtility() { throw new IllegalStateException("Utility class cannot be instantiated."); } - public static boolean representSame(DataType type, DataType otherType) { + public static boolean representSame(final DataType type, final DataType otherType) { boolean equalType; if (type instanceof Identifier && otherType instanceof Identifier) { equalType = Objects.equals(((Identifier) type).getId(), ((Identifier) otherType).getId()); @@ -62,43 +62,44 @@ public static boolean representSame(DataType type, DataType otherType) { return equalType; } - public static boolean representSame(Parameter parameter, Parameter otherParameter) { - boolean equalName = Objects.equals(parameter.getParameterName(), otherParameter.getParameterName()); - boolean equalType = representSame(parameter.getDataType__Parameter(), otherParameter.getDataType__Parameter()); + public static boolean representSame(final Parameter parameter, final Parameter otherParameter) { + final boolean equalName = Objects.equals(parameter.getParameterName(), otherParameter.getParameterName()); + final boolean equalType = representSame(parameter.getDataType__Parameter(), + otherParameter.getDataType__Parameter()); return equalName && equalType; } - public static boolean representSame(OperationSignature signature, - org.palladiosimulator.pcm.repository.Signature otherSignature) { + public static boolean representSame(final OperationSignature signature, + final org.palladiosimulator.pcm.repository.Signature otherSignature) { if (otherSignature instanceof OperationSignature) { return representSame(signature, (OperationSignature) otherSignature); } return false; } - public static boolean representSame(OperationSignature signature, OperationSignature otherSignature) { - boolean equalName = Objects.equals(signature.getEntityName(), otherSignature.getEntityName()); - boolean equalReturn = representSame(signature.getReturnType__OperationSignature(), + public static boolean representSame(final OperationSignature signature, final OperationSignature otherSignature) { + final boolean equalName = Objects.equals(signature.getEntityName(), otherSignature.getEntityName()); + final boolean equalReturn = representSame(signature.getReturnType__OperationSignature(), otherSignature.getReturnType__OperationSignature()); - boolean equalParameters = areCollectionsEqual(signature.getParameters__OperationSignature(), + final boolean equalParameters = areCollectionsEqual(signature.getParameters__OperationSignature(), otherSignature.getParameters__OperationSignature(), PcmEvaluationUtility::representSame); return equalName && equalReturn && equalParameters; } - public static boolean representSame(OperationInterface interFace, Interface otherInterFace) { + public static boolean representSame(final OperationInterface interFace, final Interface otherInterFace) { if (otherInterFace instanceof OperationInterface) { return representSame(interFace, (OperationInterface) otherInterFace); } return false; } - public static boolean representSame(OperationInterface interFace, OperationInterface otherInterFace) { - boolean equalName = Objects.equals(interFace.getEntityName(), otherInterFace.getEntityName()); + public static boolean representSame(final OperationInterface interFace, final OperationInterface otherInterFace) { + final boolean equalName = Objects.equals(interFace.getEntityName(), otherInterFace.getEntityName()); // TODO Check characterization & protocol => Is there a palladio equal check? return equalName; } - public static boolean representSame(RepositoryComponent component, RepositoryComponent otherComponent) { + public static boolean representSame(final RepositoryComponent component, final RepositoryComponent otherComponent) { if (otherComponent instanceof BasicComponent && component instanceof BasicComponent) { return representSame((BasicComponent) component, (BasicComponent) otherComponent); } else if (otherComponent instanceof CompositeComponent && component instanceof CompositeComponent) { @@ -107,58 +108,58 @@ public static boolean representSame(RepositoryComponent component, RepositoryCom return false; } - public static boolean representSame(BasicComponent component, BasicComponent otherComponent) { - boolean equalName = Objects.equals(component.getEntityName(), otherComponent.getEntityName()); - boolean equalType = Objects.equals(component.getComponentType(), otherComponent.getComponentType()); + public static boolean representSame(final BasicComponent component, final BasicComponent otherComponent) { + final boolean equalName = Objects.equals(component.getEntityName(), otherComponent.getEntityName()); + final boolean equalType = Objects.equals(component.getComponentType(), otherComponent.getComponentType()); // TODO Check parameter usage => Is there a palladio equal check? return equalName && equalType; } - public static boolean representSame(CompositeComponent component, CompositeComponent otherComponent) { - boolean equalName = Objects.equals(component.getEntityName(), otherComponent.getEntityName()); - boolean equalType = Objects.equals(component.getComponentType(), otherComponent.getComponentType()); + public static boolean representSame(final CompositeComponent component, final CompositeComponent otherComponent) { + final boolean equalName = Objects.equals(component.getEntityName(), otherComponent.getEntityName()); + final boolean equalType = Objects.equals(component.getComponentType(), otherComponent.getComponentType()); // TODO Check parameter usage => Is there a palladio equal check? return equalName && equalType; } - public static boolean representSame(ResourceContainer container, ResourceContainer otherContainer) { - boolean equalName = Objects.equals(container.getEntityName(), otherContainer.getEntityName()); + public static boolean representSame(final ResourceContainer container, final ResourceContainer otherContainer) { + final boolean equalName = Objects.equals(container.getEntityName(), otherContainer.getEntityName()); // TODO ResourceSpecifications are removed from old container on copy. Consequently, // comparing it is not // possible. return equalName; } - public static boolean representSame(ResourceDemandingSEFF seff, - org.palladiosimulator.pcm.seff.ServiceEffectSpecification otherSeff) { + public static boolean representSame(final ResourceDemandingSEFF seff, + final org.palladiosimulator.pcm.seff.ServiceEffectSpecification otherSeff) { if (otherSeff instanceof ResourceDemandingSEFF) { return representSame(seff, (ResourceDemandingSEFF) otherSeff); } return false; } - public static boolean representSame(ResourceDemandingSEFF seff, ResourceDemandingSEFF otherSeff) { - boolean equalIdentifier = Objects.equals(seff.getId(), otherSeff.getId()); - boolean equalTypeIdentifier = Objects.equals(seff.getSeffTypeID(), otherSeff.getSeffTypeID()); - boolean equalSteps = areCollectionsEqualIgnoringOrder(mapToIdentifier(seff.getSteps_Behaviour()), + public static boolean representSame(final ResourceDemandingSEFF seff, final ResourceDemandingSEFF otherSeff) { + final boolean equalIdentifier = Objects.equals(seff.getId(), otherSeff.getId()); + final boolean equalTypeIdentifier = Objects.equals(seff.getSeffTypeID(), otherSeff.getSeffTypeID()); + final boolean equalSteps = areCollectionsEqualIgnoringOrder(mapToIdentifier(seff.getSteps_Behaviour()), mapToIdentifier(otherSeff.getSteps_Behaviour())); - boolean equalInternalBehaviors = areCollectionsEqualIgnoringOrder( + final boolean equalInternalBehaviors = areCollectionsEqualIgnoringOrder( mapToIdentifier(seff.getResourceDemandingInternalBehaviours()), mapToIdentifier(otherSeff.getResourceDemandingInternalBehaviours())); - boolean equalLoopAction = Objects.equals( + final boolean equalLoopAction = Objects.equals( mapToIdentifier(seff.getAbstractLoopAction_ResourceDemandingBehaviour()), mapToIdentifier(otherSeff.getAbstractLoopAction_ResourceDemandingBehaviour())); - boolean equalBranchTransition = Objects.equals( + final boolean equalBranchTransition = Objects.equals( mapToIdentifier(seff.getAbstractBranchTransition_ResourceDemandingBehaviour()), mapToIdentifier(otherSeff.getAbstractBranchTransition_ResourceDemandingBehaviour())); return equalIdentifier && equalTypeIdentifier && equalSteps && equalInternalBehaviors && equalLoopAction && equalBranchTransition; } - public static Optional getRepresentative(ResourceEnvironment resourceEnvironment, - Deployment container) { - List containers = resourceEnvironment.getResourceContainer_ResourceEnvironment(); - for (ResourceContainer environmentContainer : containers) { + public static Optional getRepresentative(final ResourceEnvironment resourceEnvironment, + final Deployment container) { + final List containers = resourceEnvironment.getResourceContainer_ResourceEnvironment(); + for (final ResourceContainer environmentContainer : containers) { if (representSame(container.getValue(), environmentContainer)) { return Optional.of(environmentContainer); } @@ -166,9 +167,10 @@ public static Optional getRepresentative(ResourceEnvironment return Optional.empty(); } - public static Optional getRepresentative(Repository repository, Component component) { - List components = repository.getComponents__Repository(); - for (RepositoryComponent repositoryComponent : components) { + public static Optional getRepresentative(final Repository repository, + final Component component) { + final List components = repository.getComponents__Repository(); + for (final RepositoryComponent repositoryComponent : components) { if (representSame(component.getValue(), repositoryComponent)) { return Optional.of(repositoryComponent); } @@ -176,10 +178,10 @@ public static Optional getRepresentative(Repository reposit return Optional.empty(); } - public static Optional getRepresentative(Repository repository, - org.palladiosimulator.retriever.mocore.surrogate.element.Interface interFace) { - List interfaces = repository.getInterfaces__Repository(); - for (Interface repositoryInterface : interfaces) { + public static Optional getRepresentative(final Repository repository, + final org.palladiosimulator.retriever.mocore.surrogate.element.Interface interFace) { + final List interfaces = repository.getInterfaces__Repository(); + for (final Interface repositoryInterface : interfaces) { if (representSame(interFace.getValue(), repositoryInterface)) { return Optional.of((OperationInterface) repositoryInterface); } @@ -187,14 +189,14 @@ public static Optional getRepresentative(Repository reposito return Optional.empty(); } - public static boolean containsRepresentative(Repository repository, Component component) { + public static boolean containsRepresentative(final Repository repository, final Component component) { return getRepresentative(repository, component).isPresent(); } - public static boolean containsRepresentative(Repository repository, CompositionRelation composition) { - CompositeComponent wrappedComposite = composition.getSource() + public static boolean containsRepresentative(final Repository repository, final CompositionRelation composition) { + final CompositeComponent wrappedComposite = composition.getSource() .getValue(); - RepositoryComponent wrappedChild = composition.getDestination() + final RepositoryComponent wrappedChild = composition.getDestination() .getValue(); return repository.getComponents__Repository() .stream() @@ -209,17 +211,19 @@ public static boolean containsRepresentative(Repository repository, CompositionR .equals(wrappedChild.getEntityName())); } - public static boolean containsRepresentative(Repository repository, - org.palladiosimulator.retriever.mocore.surrogate.element.Interface interFace) { + public static boolean containsRepresentative(final Repository repository, + final org.palladiosimulator.retriever.mocore.surrogate.element.Interface interFace) { return getRepresentative(repository, interFace).isPresent(); } - public static boolean containsRepresentative(Repository repository, InterfaceProvisionRelation interfaceProvision) { - OperationInterface wrappedInterface = interfaceProvision.getDestination() + public static boolean containsRepresentative(final Repository repository, + final InterfaceProvisionRelation interfaceProvision) { + final OperationInterface wrappedInterface = interfaceProvision.getDestination() .getValue(); - Optional optionalComponent = getRepresentative(repository, interfaceProvision.getSource()); + final Optional optionalComponent = getRepresentative(repository, + interfaceProvision.getSource()); if (optionalComponent.isPresent()) { - List roles = optionalComponent.get() + final List roles = optionalComponent.get() .getProvidedRoles_InterfaceProvidingEntity(); return roles.stream() .filter(role -> role instanceof OperationProvidedRole) @@ -231,14 +235,14 @@ public static boolean containsRepresentative(Repository repository, InterfacePro } } - public static boolean containsRepresentative(Repository repository, - InterfaceRequirementRelation interfaceRequirement) { - OperationInterface wrappedInterface = interfaceRequirement.getDestination() + public static boolean containsRepresentative(final Repository repository, + final InterfaceRequirementRelation interfaceRequirement) { + final OperationInterface wrappedInterface = interfaceRequirement.getDestination() .getValue(); - Optional optionalComponent = getRepresentative(repository, + final Optional optionalComponent = getRepresentative(repository, interfaceRequirement.getSource()); if (optionalComponent.isPresent()) { - List roles = optionalComponent.get() + final List roles = optionalComponent.get() .getRequiredRoles_InterfaceRequiringEntity(); return roles.stream() .filter(role -> role instanceof OperationRequiredRole) @@ -250,8 +254,9 @@ public static boolean containsRepresentative(Repository repository, } } - public static boolean containsRepresentative(Repository repository, SignatureProvisionRelation signatureProvision) { - Optional optionalOperationInterface = getRepresentative(repository, + public static boolean containsRepresentative(final Repository repository, + final SignatureProvisionRelation signatureProvision) { + final Optional optionalOperationInterface = getRepresentative(repository, signatureProvision.getDestination()); return optionalOperationInterface.isPresent() && optionalOperationInterface.get() .getSignatures__OperationInterface() @@ -260,23 +265,23 @@ public static boolean containsRepresentative(Repository repository, SignaturePro .getValue(), signature)); } - public static boolean containsRepresentative(Repository repository, - ServiceEffectSpecificationRelation seffProvision) { - Component provider = seffProvision.getSource() + public static boolean containsRepresentative(final Repository repository, + final ServiceEffectSpecificationRelation seffProvision) { + final Component provider = seffProvision.getSource() .getSource() .getSource(); - Signature signature = seffProvision.getSource() + final Signature signature = seffProvision.getSource() .getDestination() .getSource(); - ServiceEffectSpecification seff = seffProvision.getDestination(); + final ServiceEffectSpecification seff = seffProvision.getDestination(); - Optional optionalComponent = getRepresentative(repository, provider); + final Optional optionalComponent = getRepresentative(repository, provider); if (optionalComponent.isPresent() && optionalComponent.get() instanceof BasicComponent) { - BasicComponent component = (BasicComponent) optionalComponent.get(); - for (org.palladiosimulator.pcm.seff.ServiceEffectSpecification componentSeff : component + final BasicComponent component = (BasicComponent) optionalComponent.get(); + for (final org.palladiosimulator.pcm.seff.ServiceEffectSpecification componentSeff : component .getServiceEffectSpecifications__BasicComponent()) { if (representSame(seff.getValue(), componentSeff)) { - ResourceDemandingSEFF componentRdSeff = (ResourceDemandingSEFF) componentSeff; + final ResourceDemandingSEFF componentRdSeff = (ResourceDemandingSEFF) componentSeff; return representSame(provider.getValue(), componentRdSeff.getBasicComponent_ServiceEffectSpecification()) && representSame(signature.getValue(), componentRdSeff.getDescribedService__SEFF()) @@ -290,18 +295,19 @@ && containsRepresentative(repository, seffProvision.getSource() return false; } - public static boolean containsRepresentative(ResourceEnvironment resourceEnvironment, Deployment container) { + public static boolean containsRepresentative(final ResourceEnvironment resourceEnvironment, + final Deployment container) { return getRepresentative(resourceEnvironment, container).isPresent(); } - public static boolean containsRepresentative(ResourceEnvironment resourceEnvironment, - DeploymentDeploymentRelation link) { - List linkingResources = resourceEnvironment.getLinkingResources__ResourceEnvironment(); - for (LinkingResource linkingResource : linkingResources) { - List linkedContainers = new LinkedList<>( + public static boolean containsRepresentative(final ResourceEnvironment resourceEnvironment, + final DeploymentDeploymentRelation link) { + final List linkingResources = resourceEnvironment.getLinkingResources__ResourceEnvironment(); + for (final LinkingResource linkingResource : linkingResources) { + final List linkedContainers = new LinkedList<>( linkingResource.getConnectedResourceContainers_LinkingResource()); boolean containsContainers = true; - for (Deployment deployment : List.of(link.getSource(), link.getDestination())) { + for (final Deployment deployment : List.of(link.getSource(), link.getDestination())) { containsContainers = containsContainers && linkedContainers.removeIf(element -> representSame(deployment.getValue(), element)); } @@ -312,17 +318,17 @@ public static boolean containsRepresentative(ResourceEnvironment resourceEnviron return false; } - public static boolean containsRepresentative(ResourceEnvironment resourceEnvironment, - LinkResourceSpecification relationSpecification, Collection deployments) { - CommunicationLinkResourceSpecification specification = relationSpecification.getValue(); - List linkingResources = resourceEnvironment.getLinkingResources__ResourceEnvironment(); - for (LinkingResource linkingResource : linkingResources) { - List linkedContainers = new LinkedList<>( + public static boolean containsRepresentative(final ResourceEnvironment resourceEnvironment, + final LinkResourceSpecification relationSpecification, final Collection deployments) { + final CommunicationLinkResourceSpecification specification = relationSpecification.getValue(); + final List linkingResources = resourceEnvironment.getLinkingResources__ResourceEnvironment(); + for (final LinkingResource linkingResource : linkingResources) { + final List linkedContainers = new LinkedList<>( linkingResource.getConnectedResourceContainers_LinkingResource()); - CommunicationLinkResourceSpecification linkSpecification = linkingResource + final CommunicationLinkResourceSpecification linkSpecification = linkingResource .getCommunicationLinkResourceSpecifications_LinkingResource(); boolean containsContainers = true; - for (Deployment deployment : deployments) { + for (final Deployment deployment : deployments) { containsContainers = containsContainers && linkedContainers.removeIf(element -> representSame(deployment.getValue(), element)); } @@ -336,15 +342,15 @@ public static boolean containsRepresentative(ResourceEnvironment resourceEnviron return false; } - public static boolean containsRepresentative(Allocation allocation, - ComponentAllocationRelation allocationRelation) { - Component component = allocationRelation.getSource(); - Deployment deployment = allocationRelation.getDestination(); + public static boolean containsRepresentative(final Allocation allocation, + final ComponentAllocationRelation allocationRelation) { + final Component component = allocationRelation.getSource(); + final Deployment deployment = allocationRelation.getDestination(); - List allocationContexts = allocation.getAllocationContexts_Allocation(); - for (AllocationContext allocationContext : allocationContexts) { + final List allocationContexts = allocation.getAllocationContexts_Allocation(); + for (final AllocationContext allocationContext : allocationContexts) { if (representSame(deployment.getValue(), allocationContext.getResourceContainer_AllocationContext())) { - AssemblyContext assemblyContext = allocationContext.getAssemblyContext_AllocationContext(); + final AssemblyContext assemblyContext = allocationContext.getAssemblyContext_AllocationContext(); if (representSame(component.getValue(), assemblyContext.getEncapsulatedComponent__AssemblyContext())) { return true; } @@ -353,9 +359,9 @@ public static boolean containsRepresentative(Allocation allocation, return false; } - public static boolean containsRepresentative(System system, Component component) { - List assemblyContexts = system.getAssemblyContexts__ComposedStructure(); - for (AssemblyContext assemblyContext : assemblyContexts) { + public static boolean containsRepresentative(final System system, final Component component) { + final List assemblyContexts = system.getAssemblyContexts__ComposedStructure(); + for (final AssemblyContext assemblyContext : assemblyContexts) { if (representSame(component.getValue(), assemblyContext.getEncapsulatedComponent__AssemblyContext())) { return true; } @@ -363,33 +369,34 @@ public static boolean containsRepresentative(System system, Component compone return false; } - public static boolean containsRepresentative(System system, ComponentAssemblyRelation assemblyRelation) { - RepositoryComponent provider = assemblyRelation.getSource() + public static boolean containsRepresentative(final System system, + final ComponentAssemblyRelation assemblyRelation) { + final RepositoryComponent provider = assemblyRelation.getSource() .getSource() .getValue(); - RepositoryComponent consumer = assemblyRelation.getDestination() + final RepositoryComponent consumer = assemblyRelation.getDestination() .getSource() .getValue(); - OperationInterface providerConsumerInterface = assemblyRelation.getSource() + final OperationInterface providerConsumerInterface = assemblyRelation.getSource() .getDestination() .getValue(); - List assemblyConnectors = system.getConnectors__ComposedStructure() + final List assemblyConnectors = system.getConnectors__ComposedStructure() .stream() .filter(connector -> connector instanceof AssemblyConnector) .map(connector -> (AssemblyConnector) connector) .collect(Collectors.toList()); - for (AssemblyConnector connector : assemblyConnectors) { - RepositoryComponent connectorProvider = connector.getProvidingAssemblyContext_AssemblyConnector() + for (final AssemblyConnector connector : assemblyConnectors) { + final RepositoryComponent connectorProvider = connector.getProvidingAssemblyContext_AssemblyConnector() .getEncapsulatedComponent__AssemblyContext(); - RepositoryComponent connectorConsumer = connector.getRequiringAssemblyContext_AssemblyConnector() + final RepositoryComponent connectorConsumer = connector.getRequiringAssemblyContext_AssemblyConnector() .getEncapsulatedComponent__AssemblyContext(); - OperationInterface connectorProviderConsumerInterface = connector.getProvidedRole_AssemblyConnector() + final OperationInterface connectorProviderConsumerInterface = connector.getProvidedRole_AssemblyConnector() .getProvidedInterface__OperationProvidedRole(); - boolean sameProvider = representSame(provider, connectorProvider); - boolean sameConsumer = representSame(consumer, connectorConsumer); - boolean sameInterface = representSame(providerConsumerInterface, connectorProviderConsumerInterface); + final boolean sameProvider = representSame(provider, connectorProvider); + final boolean sameConsumer = representSame(consumer, connectorConsumer); + final boolean sameInterface = representSame(providerConsumerInterface, connectorProviderConsumerInterface); if (sameProvider && sameConsumer && sameInterface) { return true; } @@ -397,16 +404,16 @@ public static boolean containsRepresentative(System system, ComponentAssemblyRel return false; } - private static boolean areCollectionsEqual(Collection collection, Collection otherCollection, - BiFunction comparisonFunction) { + private static boolean areCollectionsEqual(final Collection collection, final Collection otherCollection, + final BiFunction comparisonFunction) { if (collection.isEmpty() && otherCollection.isEmpty()) { return true; } else if (collection.size() != otherCollection.size()) { return false; } - List list = new LinkedList<>(collection); - List otherList = new LinkedList<>(otherCollection); + final List list = new LinkedList<>(collection); + final List otherList = new LinkedList<>(otherCollection); for (int i = 0; i < list.size(); i++) { if (!comparisonFunction.apply(list.get(i), otherList.get(i))) { return false; @@ -415,16 +422,16 @@ private static boolean areCollectionsEqual(Collection collection, Collect return true; } - private static boolean areCollectionsEqualIgnoringOrder(Collection collection, - Collection otherCollection) { + private static boolean areCollectionsEqualIgnoringOrder(final Collection collection, + final Collection otherCollection) { return collection.containsAll(otherCollection) && otherCollection.containsAll(collection); } - private static String mapToIdentifier(T element) { + private static String mapToIdentifier(final T element) { return element != null ? element.getId() : null; } - private static List mapToIdentifier(Collection collection) { + private static List mapToIdentifier(final Collection collection) { return collection.stream() .dropWhile(element -> element == null) .map(Identifier::getId) diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJobTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJobTest.java index 328f0ec7..d8ce96a9 100644 --- a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJobTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJobTest.java @@ -33,7 +33,7 @@ public class MoCoReJobTest { @Test public void testConstructorWithValidInput() { - Blackboard blackboard = new Blackboard(); + final Blackboard blackboard = new Blackboard<>(); assertDoesNotThrow(() -> new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_OUTPUT_REPOSITORY, BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT)); } @@ -41,24 +41,24 @@ public void testConstructorWithValidInput() { @Test public void testCompositeComponentProcessing() throws Exception { // Tests constants - String componentNameOne = "Component One"; - String contextNameOne = componentNameOne + " Context"; - String componentNameTwo = "Component Two"; - String contextNameTwo = componentNameTwo + " Context"; - String interfaceNameInternal = "Internal Interface"; - String roleNameInternalRequired = "Role Requirer " + interfaceNameInternal; - String roleNameInternalProvided = "Role Provider " + interfaceNameInternal; - String interfaceNameExternalRequired = "External Interface Required"; - String roleNameExternalRequiredInner = "Inner Role " + interfaceNameExternalRequired; - String roleNameExternalRequiredOuter = "Outer Role " + interfaceNameExternalRequired; - String interfaceNameExternalProvided = "External Interface Provided"; - String roleNameExternalProvidedInner = "Inner Role " + interfaceNameExternalProvided; - String roleNameExternalProvidedOuter = "Outer Role " + interfaceNameExternalProvided; + final String componentNameOne = "Component One"; + final String contextNameOne = componentNameOne + " Context"; + final String componentNameTwo = "Component Two"; + final String contextNameTwo = componentNameTwo + " Context"; + final String interfaceNameInternal = "Internal Interface"; + final String roleNameInternalRequired = "Role Requirer " + interfaceNameInternal; + final String roleNameInternalProvided = "Role Provider " + interfaceNameInternal; + final String interfaceNameExternalRequired = "External Interface Required"; + final String roleNameExternalRequiredInner = "Inner Role " + interfaceNameExternalRequired; + final String roleNameExternalRequiredOuter = "Outer Role " + interfaceNameExternalRequired; + final String interfaceNameExternalProvided = "External Interface Provided"; + final String roleNameExternalProvidedInner = "Inner Role " + interfaceNameExternalProvided; + final String roleNameExternalProvidedOuter = "Outer Role " + interfaceNameExternalProvided; // Create blackboard and fluent repository - Blackboard blackboard = new Blackboard(); - FluentRepositoryFactory fluentFactory = new FluentRepositoryFactory(); - Repo fluentRepository = fluentFactory.newRepository(); + final Blackboard blackboard = new Blackboard<>(); + final FluentRepositoryFactory fluentFactory = new FluentRepositoryFactory(); + final Repo fluentRepository = fluentFactory.newRepository(); // Create composite component and add to fluent repository fluentRepository.addToRepository(fluentFactory.newOperationInterface() @@ -99,14 +99,14 @@ public void testCompositeComponentProcessing() throws Exception { blackboard.addPartition(BLACKBOARD_INPUT_REPOSITORY, fluentRepository.createRepositoryNow()); // Create and run job - MoCoReJob job = new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_OUTPUT_REPOSITORY, + final MoCoReJob job = new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_OUTPUT_REPOSITORY, BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT); job.execute(new NullProgressMonitor()); // Check if components exist in repository - Repository outputRepository = (Repository) blackboard.getPartition(BLACKBOARD_OUTPUT_REPOSITORY); - EList components = outputRepository.getComponents__Repository(); - CompositeComponent composite = (CompositeComponent) components.stream() + final Repository outputRepository = (Repository) blackboard.getPartition(BLACKBOARD_OUTPUT_REPOSITORY); + final EList components = outputRepository.getComponents__Repository(); + final CompositeComponent composite = (CompositeComponent) components.stream() .filter(component -> component instanceof CompositeComponent) .findFirst() .orElseThrow(); @@ -114,13 +114,13 @@ public void testCompositeComponentProcessing() throws Exception { .size()); // Check if assembly connector created correctly - List assemblyConnectors = composite.getConnectors__ComposedStructure() + final List assemblyConnectors = composite.getConnectors__ComposedStructure() .stream() .filter(genericConnector -> genericConnector instanceof AssemblyConnector) .map(genericConnector -> (AssemblyConnector) genericConnector) .collect(Collectors.toList()); assertEquals(1, assemblyConnectors.size()); - AssemblyConnector assemblyConnector = assemblyConnectors.get(0); + final AssemblyConnector assemblyConnector = assemblyConnectors.get(0); assertEquals(componentNameOne, assemblyConnector.getProvidingAssemblyContext_AssemblyConnector() .getEncapsulatedComponent__AssemblyContext() .getEntityName()); @@ -135,13 +135,13 @@ public void testCompositeComponentProcessing() throws Exception { .getEntityName()); // Check if provided delegation created correctly - List providedDelegations = composite.getConnectors__ComposedStructure() + final List providedDelegations = composite.getConnectors__ComposedStructure() .stream() .filter(genericConnector -> genericConnector instanceof ProvidedDelegationConnector) .map(genericConnector -> (ProvidedDelegationConnector) genericConnector) .collect(Collectors.toList()); assertEquals(1, providedDelegations.size()); - ProvidedDelegationConnector providedDelegationConnector = providedDelegations.get(0); + final ProvidedDelegationConnector providedDelegationConnector = providedDelegations.get(0); assertEquals(componentNameTwo, providedDelegationConnector.getAssemblyContext_ProvidedDelegationConnector() .getEncapsulatedComponent__AssemblyContext() .getEntityName()); @@ -155,13 +155,13 @@ public void testCompositeComponentProcessing() throws Exception { .getEntityName()); // Check if required delegation created correctly - List requiredDelegations = composite.getConnectors__ComposedStructure() + final List requiredDelegations = composite.getConnectors__ComposedStructure() .stream() .filter(genericConnector -> genericConnector instanceof RequiredDelegationConnector) .map(genericConnector -> (RequiredDelegationConnector) genericConnector) .collect(Collectors.toList()); assertEquals(1, requiredDelegations.size()); - RequiredDelegationConnector requiredDelegationConnector = requiredDelegations.get(0); + final RequiredDelegationConnector requiredDelegationConnector = requiredDelegations.get(0); assertEquals(componentNameOne, requiredDelegationConnector.getAssemblyContext_RequiredDelegationConnector() .getEncapsulatedComponent__AssemblyContext() .getEntityName()); @@ -178,9 +178,9 @@ public void testCompositeComponentProcessing() throws Exception { @Test public void testRecursiveProvisionLeadsToSystemDelegation() throws Exception { // Create blackboard and fluent repository - Blackboard blackboard = new Blackboard(); - FluentRepositoryFactory fluentFactory = new FluentRepositoryFactory(); - Repo fluentRepository = fluentFactory.newRepository(); + final Blackboard blackboard = new Blackboard<>(); + final FluentRepositoryFactory fluentFactory = new FluentRepositoryFactory(); + final Repo fluentRepository = fluentFactory.newRepository(); // Create composite component and add to fluent repository fluentRepository.addToRepository(fluentFactory.newOperationInterface() @@ -202,14 +202,14 @@ public void testRecursiveProvisionLeadsToSystemDelegation() throws Exception { blackboard.addPartition(BLACKBOARD_INPUT_REPOSITORY, fluentRepository.createRepositoryNow()); // Create and run job - MoCoReJob job = new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_OUTPUT_REPOSITORY, + final MoCoReJob job = new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_OUTPUT_REPOSITORY, BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT); job.execute(new NullProgressMonitor()); // Check inner provision was recursively - Repository outputRepository = (Repository) blackboard.getPartition(BLACKBOARD_OUTPUT_REPOSITORY); - EList components = outputRepository.getComponents__Repository(); - List composites = components.stream() + final Repository outputRepository = (Repository) blackboard.getPartition(BLACKBOARD_OUTPUT_REPOSITORY); + final EList components = outputRepository.getComponents__Repository(); + final List composites = components.stream() .filter(component -> component instanceof CompositeComponent) .map(component -> (CompositeComponent) component) .toList(); @@ -221,10 +221,10 @@ public void testRecursiveProvisionLeadsToSystemDelegation() throws Exception { .equals("Doable")))); // Check most outer provision was delegated by system - System outputSystem = (System) blackboard.getPartition(BLACKBOARD_OUTPUT_SYSTEM); - EList connectors = outputSystem.getConnectors__ComposedStructure(); + final System outputSystem = (System) blackboard.getPartition(BLACKBOARD_OUTPUT_SYSTEM); + final EList connectors = outputSystem.getConnectors__ComposedStructure(); assertEquals(1, connectors.size()); - ProvidedDelegationConnector delegationConnector = (ProvidedDelegationConnector) connectors.get(0); + final ProvidedDelegationConnector delegationConnector = (ProvidedDelegationConnector) connectors.get(0); assertEquals("Outer Parent", delegationConnector.getAssemblyContext_ProvidedDelegationConnector() .getEncapsulatedComponent__AssemblyContext() .getEntityName()); diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/ACMETest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/ACMETest.java index 1765078b..533afe81 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/ACMETest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/ACMETest.java @@ -10,20 +10,20 @@ protected ACMETest() { @Override void testRetrieverRepository() { - assertComponentExists("com_acmeair_wxs_service_FlightServiceImpl"); + this.assertComponentExists("com_acmeair_wxs_service_FlightServiceImpl"); - assertComponentProvidesOperation("com_acmeair_morphia_services_CustomerServiceImpl", + this.assertComponentProvidesOperation("com_acmeair_morphia_services_CustomerServiceImpl", "com_acmeair_service_CustomerService", "getCustomerByUsername"); - assertComponentProvidesOperation("com_acmeair_wxs_service_FlightServiceImpl", + this.assertComponentProvidesOperation("com_acmeair_wxs_service_FlightServiceImpl", "com_acmeair_service_FlightService", "getFlightByAirports"); - assertComponentProvidesOperation("com_acmeair_morphia_services_BookingServiceImpl", + this.assertComponentProvidesOperation("com_acmeair_morphia_services_BookingServiceImpl", "com_acmeair_service_BookingService", "bookFlight"); - assertMaxParameterCount(2, "com_acmeair_service_BookingService", "bookFlight"); + this.assertMaxParameterCount(2, "com_acmeair_service_BookingService", "bookFlight"); - assertComponentRequiresComponent("com_acmeair_web_FlightsREST", + this.assertComponentRequiresComponent("com_acmeair_web_FlightsREST", "com_acmeair_morphia_services_FlightServiceImpl"); - assertComponentRequiresComponent("com_acmeair_web_LoginREST", + this.assertComponentRequiresComponent("com_acmeair_web_LoginREST", "com_acmeair_morphia_services_CustomerServiceImpl"); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/BasicTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/BasicTest.java index 51c960df..c42db32b 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/BasicTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/BasicTest.java @@ -36,10 +36,10 @@ public class BasicTest extends CaseStudyTest { protected BasicTest() { super(PROJECT_NAME, RULES); - loadArtifacts(Artifacts.RETRIEVER); + this.loadArtifacts(Artifacts.RETRIEVER); } - private OperationInterface getConflictingMethods(List interfaces) { + private OperationInterface getConflictingMethods(final List interfaces) { OperationInterface conflictingMethods = null; for (final Interface iface : interfaces) { if ("basic_ConflictingMethods".equals(iface.getEntityName())) { @@ -57,7 +57,8 @@ private OperationInterface getConflictingMethods(List interfaces) { */ @Test void testExecutesAndProducesFile() { - assertTrue(new File(getConfig().getOutputFolder() + assertTrue(new File(this.getConfig() + .getOutputFolder() .appendSegment("pcm.repository") .devicePath()).exists()); } @@ -65,7 +66,7 @@ void testExecutesAndProducesFile() { @Disabled("FIXME: Reliance on outdated JaxRS rule") @Test void testArray() { - final OperationInterface conflictingMethods = getConflictingMethods(getInterfaces()); + final OperationInterface conflictingMethods = this.getConflictingMethods(this.getInterfaces()); for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { for (final Parameter param : sig.getParameters__OperationSignature()) { if ("intArray".equals(param.getParameterName())) { @@ -94,7 +95,7 @@ void testArray() { @Disabled("FIXME: Reliance on outdated JaxRS rule") @Test void testRepeatability() throws RetrieverException, JobFailedException, UserCanceledException { - OperationInterface conflictingMethods = getConflictingMethods(getInterfaces()); + OperationInterface conflictingMethods = this.getConflictingMethods(this.getInterfaces()); int firstIntArgCount = 0; for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { for (final Parameter param : sig.getParameters__OperationSignature()) { @@ -105,7 +106,7 @@ void testRepeatability() throws RetrieverException, JobFailedException, UserCanc } // Run Retriever again on the same project - RetrieverConfiguration retrieverConfig = getConfig(); + final RetrieverConfiguration retrieverConfig = this.getConfig(); retrieverConfig.setOutputFolder(retrieverConfig.getOutputFolder() .appendSegment("repeated")); final RetrieverJob retrieverJob = new RetrieverJob(retrieverConfig); @@ -113,7 +114,7 @@ void testRepeatability() throws RetrieverException, JobFailedException, UserCanc final Repository repo = (Repository) retrieverJob.getBlackboard() .getPartition(RetrieverBlackboard.KEY_REPOSITORY); - conflictingMethods = getConflictingMethods(repo.getInterfaces__Repository()); + conflictingMethods = this.getConflictingMethods(repo.getInterfaces__Repository()); int secondIntArgCount = 0; for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { @@ -130,7 +131,7 @@ void testRepeatability() throws RetrieverException, JobFailedException, UserCanc @Disabled("This bug is inherited from Palladio, this can only be fixed after it is fixed there.") @Test void testShort() { - final OperationInterface conflictingMethods = getConflictingMethods(getInterfaces()); + final OperationInterface conflictingMethods = this.getConflictingMethods(this.getInterfaces()); for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { for (final Parameter param : sig.getParameters__OperationSignature()) { if ("shortArg".equals(param.getParameterName())) { @@ -145,7 +146,7 @@ void testShort() { @Disabled("FIXME: Reliance on outdated JaxRS rule") @Test void testVararg() { - final OperationInterface conflictingMethods = getConflictingMethods(getInterfaces()); + final OperationInterface conflictingMethods = this.getConflictingMethods(this.getInterfaces()); for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { for (final Parameter param : sig.getParameters__OperationSignature()) { if ("longVararg".equals(param.getParameterName())) { diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/CaseStudyTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/CaseStudyTest.java index 39ed3446..cd0ba822 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/CaseStudyTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/CaseStudyTest.java @@ -54,9 +54,9 @@ abstract class CaseStudyTest { public static final URI TEST_DIR = CommonPlugin .asLocalURI(URI.createFileURI(URI.decode(new File("res").getAbsolutePath()))); - private URI outDir; + private final URI outDir; - public static void validate(EObject eObject) { + public static void validate(final EObject eObject) { EcoreUtil.resolveAll(eObject); assertEquals(Diagnostic.OK, Diagnostician.INSTANCE.validate(eObject) .getSeverity()); @@ -82,29 +82,29 @@ public static void validate(EObject eObject) { * @param rules * the rules to execute */ - protected CaseStudyTest(String projectDirectory, Rule... rules) { + protected CaseStudyTest(final String projectDirectory, final Rule... rules) { this.rules = Set.of(rules); - outDir = TEST_DIR.appendSegment("out") + this.outDir = TEST_DIR.appendSegment("out") .appendSegment(this.getClass() .getSimpleName()); - config.setInputFolder(TEST_DIR.appendSegments(projectDirectory.split("/"))); - config.setOutputFolder(outDir); + this.config.setInputFolder(TEST_DIR.appendSegments(projectDirectory.split("/"))); + this.config.setOutputFolder(this.outDir); - ServiceConfiguration ruleConfig = config.getConfig(Rule.class); - for (Rule rule : rules) { + final ServiceConfiguration ruleConfig = this.config.getConfig(Rule.class); + for (final Rule rule : rules) { ruleConfig.select(rule); } - retrieverJob = new RetrieverJob(config); + this.retrieverJob = new RetrieverJob(this.config); boolean executedSuccessfully; try { - retrieverJob.execute(new NullProgressMonitor()); + this.retrieverJob.execute(new NullProgressMonitor()); executedSuccessfully = true; } catch (JobFailedException | UserCanceledException e) { - logger.error(e); + this.logger.error(e); executedSuccessfully = false; } this.executedSuccessfully = executedSuccessfully; @@ -113,50 +113,55 @@ protected CaseStudyTest(String projectDirectory, Rule... rules) { // Assertion utilities private void assertSuccessfulExecution() { - assertTrue(executedSuccessfully, "Failed to run Retriever!"); + assertTrue(this.executedSuccessfully, "Failed to run Retriever!"); } - public void assertMaxParameterCount(int expectedMaxParameterCount, String interfaceName, String operationName) { - assertInterfaceExists(interfaceName); - assertOperationExists(interfaceName, operationName); - assertEquals(expectedMaxParameterCount, getSignatureMaxParameterCount(interfaceName, operationName)); + public void assertMaxParameterCount(final int expectedMaxParameterCount, final String interfaceName, + final String operationName) { + this.assertInterfaceExists(interfaceName); + this.assertOperationExists(interfaceName, operationName); + assertEquals(expectedMaxParameterCount, this.getSignatureMaxParameterCount(interfaceName, operationName)); } - public void assertComponentExists(String name) { - assertTrue(getComponents().stream() + public void assertComponentExists(final String name) { + assertTrue(this.getComponents() + .stream() .anyMatch(x -> x.getEntityName() .equals(name)), "component \"" + name + "\" must exist"); } - public void assertInterfaceExists(String name) { - assertTrue(getInterfaces().stream() + public void assertInterfaceExists(final String name) { + assertTrue(this.getInterfaces() + .stream() .filter(OperationInterface.class::isInstance) .anyMatch(x -> x.getEntityName() .equals(name)), "interface \"" + name + "\" must exist"); } - public void assertOperationExists(String interfaceName, String operationName) { - assertFalse(getOperationSignature(interfaceName, operationName).isEmpty(), - "interface \"" + interfaceName + "\" must contain operation \"" + operationName + "\""); + public void assertOperationExists(final String interfaceName, final String operationName) { + assertFalse(this.getOperationSignature(interfaceName, operationName) + .isEmpty(), "interface \"" + interfaceName + "\" must contain operation \"" + operationName + "\""); } - public void assertComponentRequiresComponent(String requiringName, String providingName) { - Optional requiringComponent = getComponents().stream() + public void assertComponentRequiresComponent(final String requiringName, final String providingName) { + final Optional requiringComponent = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(requiringName)) .findFirst(); assertTrue(requiringComponent.isPresent(), "\"" + requiringName + "\" must exist"); - Optional providingComponent = getComponents().stream() + final Optional providingComponent = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(providingName)) .findFirst(); assertTrue(providingComponent.isPresent(), "\"" + providingName + "\" must exist"); - List interfaces = getInterfaces(); + final List interfaces = this.getInterfaces(); assertFalse(interfaces.isEmpty(), "an interface must exist in order for a component to require another"); - Set requiredObjects = requiringComponent.get() + final Set requiredObjects = requiringComponent.get() .getRequiredRoles_InterfaceRequiringEntity() .stream() .flatMap(x -> x.eCrossReferences() @@ -164,12 +169,12 @@ public void assertComponentRequiresComponent(String requiringName, String provid .collect(Collectors.toSet()); assertFalse(requiredObjects.isEmpty(), "\"" + requiringName + "\" must require something"); - Set requiredInterfaces = interfaces.stream() + final Set requiredInterfaces = interfaces.stream() .filter(requiredObjects::contains) .collect(Collectors.toSet()); assertFalse(requiredInterfaces.isEmpty(), "\"" + requiringName + "\" must require an interface"); - Set providedObjects = providingComponent.get() + final Set providedObjects = providingComponent.get() .getProvidedRoles_InterfaceProvidingEntity() .stream() .flatMap(x -> x.eCrossReferences() @@ -177,7 +182,7 @@ public void assertComponentRequiresComponent(String requiringName, String provid .collect(Collectors.toSet()); assertFalse(providedObjects.isEmpty(), "\"" + providingName + "\" must provide something"); - Set providedInterfaces = interfaces.stream() + final Set providedInterfaces = interfaces.stream() .filter(providedObjects::contains) .collect(Collectors.toSet()); assertFalse(providedInterfaces.isEmpty(), "\"" + providingName + "\" must provide an interface"); @@ -187,26 +192,29 @@ public void assertComponentRequiresComponent(String requiringName, String provid "\"" + requiringName + "\" must require an interface that \"" + providingName + "\" provides"); } - public void assertInSameCompositeComponent(String childComponentNameA, String childComponentNameB) { - Optional childComponentA = getComponents().stream() + public void assertInSameCompositeComponent(final String childComponentNameA, final String childComponentNameB) { + final Optional childComponentA = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(childComponentNameA)) .findFirst(); assertTrue(childComponentA.isPresent(), "\"" + childComponentNameA + "\" must exist"); - Optional childComponentB = getComponents().stream() + final Optional childComponentB = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(childComponentNameB)) .findFirst(); assertTrue(childComponentB.isPresent(), "\"" + childComponentNameB + "\" must exist"); - List allCompositeComponents = getComponents().stream() + final List allCompositeComponents = this.getComponents() + .stream() .filter(CompositeComponent.class::isInstance) .map(CompositeComponent.class::cast) .collect(Collectors.toList()); assertFalse(allCompositeComponents.isEmpty(), "There must be a composite component"); - Set compositeComponentsA = allCompositeComponents.stream() + final Set compositeComponentsA = allCompositeComponents.stream() .filter(x -> x.getAssemblyContexts__ComposedStructure() .stream() .anyMatch(y -> y.getEncapsulatedComponent__AssemblyContext() @@ -214,7 +222,7 @@ public void assertInSameCompositeComponent(String childComponentNameA, String ch .collect(Collectors.toSet()); assertFalse(compositeComponentsA.isEmpty(), childComponentNameA + " must be part of a composite component"); - Set compositeComponentsB = allCompositeComponents.stream() + final Set compositeComponentsB = allCompositeComponents.stream() .filter(x -> x.getAssemblyContexts__ComposedStructure() .stream() .anyMatch(y -> y.getEncapsulatedComponent__AssemblyContext() @@ -227,17 +235,19 @@ public void assertInSameCompositeComponent(String childComponentNameA, String ch childComponentNameA + " and " + childComponentNameB + " must be part of the same composite component"); } - public void assertComponentProvidesOperation(String componentName, String interfaceName, String operationName) { - Optional component = getComponents().stream() + public void assertComponentProvidesOperation(final String componentName, final String interfaceName, + final String operationName) { + final Optional component = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(componentName)) .findFirst(); assertTrue(component.isPresent(), "Component \"" + componentName + "\" must exist"); - List interfaces = getInterfaces(); + final List interfaces = this.getInterfaces(); assertFalse(interfaces.isEmpty(), "an interface must exist in order for a component to provide an operation"); - Set providedObjects = component.get() + final Set providedObjects = component.get() .getProvidedRoles_InterfaceProvidingEntity() .stream() .flatMap(x -> x.eCrossReferences() @@ -245,74 +255,75 @@ public void assertComponentProvidesOperation(String componentName, String interf .collect(Collectors.toSet()); assertFalse(providedObjects.isEmpty(), "\"" + componentName + "\" must provide something"); - Set providedInterfaces = interfaces.stream() + final Set providedInterfaces = interfaces.stream() .filter(providedObjects::contains) .collect(Collectors.toSet()); assertFalse(providedInterfaces.isEmpty(), "\"" + componentName + "\" must provide an interface"); - Set specifiedInterfaces = providedInterfaces.stream() + final Set specifiedInterfaces = providedInterfaces.stream() .filter(x -> x.getEntityName() .equals(interfaceName)) .collect(Collectors.toSet()); assertFalse(specifiedInterfaces.isEmpty(), "\"" + componentName + "\" must provide interface \"" + interfaceName + "\""); - assertOperationExists(interfaceName, operationName); + this.assertOperationExists(interfaceName, operationName); } // Getters public RetrieverConfiguration getConfig() { - assertSuccessfulExecution(); - return config; + this.assertSuccessfulExecution(); + return this.config; } public List getComponents() { - assertSuccessfulExecution(); - return Collections.unmodifiableList(repository.getComponents__Repository()); + this.assertSuccessfulExecution(); + return Collections.unmodifiableList(this.repository.getComponents__Repository()); } public List getDatatypes() { - assertSuccessfulExecution(); - return Collections.unmodifiableList(repository.getDataTypes__Repository()); + this.assertSuccessfulExecution(); + return Collections.unmodifiableList(this.repository.getDataTypes__Repository()); } public List getFailuretypes() { - assertSuccessfulExecution(); - return Collections.unmodifiableList(repository.getFailureTypes__Repository()); + this.assertSuccessfulExecution(); + return Collections.unmodifiableList(this.repository.getFailureTypes__Repository()); } public List getInterfaces() { - assertSuccessfulExecution(); - return Collections.unmodifiableList(repository.getInterfaces__Repository()); + this.assertSuccessfulExecution(); + return Collections.unmodifiableList(this.repository.getInterfaces__Repository()); } public Repository getRepository() { - assertSuccessfulExecution(); - assertNotNull(repository); - return repository; + this.assertSuccessfulExecution(); + assertNotNull(this.repository); + return this.repository; } public System getSystem() { - assertSuccessfulExecution(); - assertNotNull(system); - return system; + this.assertSuccessfulExecution(); + assertNotNull(this.system); + return this.system; } public ResourceEnvironment getResourceEnvironment() { - assertSuccessfulExecution(); - assertNotNull(resourceEnvironment); - return resourceEnvironment; + this.assertSuccessfulExecution(); + assertNotNull(this.resourceEnvironment); + return this.resourceEnvironment; } public Allocation getAllocation() { - assertSuccessfulExecution(); - assertNotNull(allocation); - return allocation; + this.assertSuccessfulExecution(); + assertNotNull(this.allocation); + return this.allocation; } - private Set getOperationSignature(String interfaceName, String signatureName) { - return getInterfaces().stream() + private Set getOperationSignature(final String interfaceName, final String signatureName) { + return this.getInterfaces() + .stream() .filter(OperationInterface.class::isInstance) .map(OperationInterface.class::cast) .filter(x -> x.getEntityName() @@ -321,8 +332,8 @@ private Set getOperationSignature(String interfaceName, Stri .stream() .filter(y -> { // Ignore uniqueness postfix - String name = y.getEntityName(); - int postfixStart = name.indexOf('$'); + final String name = y.getEntityName(); + final int postfixStart = name.indexOf('$'); if (postfixStart > -1) { return name.substring(0, postfixStart) .equals(signatureName); @@ -334,16 +345,16 @@ private Set getOperationSignature(String interfaceName, Stri } public RetrieverBlackboard getBlackboard() { - assertSuccessfulExecution(); - return retrieverJob.getBlackboard(); + this.assertSuccessfulExecution(); + return this.retrieverJob.getBlackboard(); } public Set getRules() { - return Collections.unmodifiableSet(rules); + return Collections.unmodifiableSet(this.rules); } - public int getSignatureMaxParameterCount(String interfaceName, String signatureName) { - final Set sigs = getOperationSignature(interfaceName, signatureName); + public int getSignatureMaxParameterCount(final String interfaceName, final String signatureName) { + final Set sigs = this.getOperationSignature(interfaceName, signatureName); return sigs.stream() .map(OperationSignature::getParameters__OperationSignature) .map(List::size) @@ -356,31 +367,31 @@ protected enum Artifacts { RETRIEVER, MOCORE, } - protected void loadArtifacts(Artifacts artifacts) { - assertSuccessfulExecution(); + protected void loadArtifacts(final Artifacts artifacts) { + this.assertSuccessfulExecution(); switch (artifacts) { case RETRIEVER: - repository = ModelLoader.loadRepository(outDir.appendSegment("pcm.repository") + this.repository = ModelLoader.loadRepository(this.outDir.appendSegment("pcm.repository") .toString()); - system = null; - resourceEnvironment = null; - allocation = null; + this.system = null; + this.resourceEnvironment = null; + this.allocation = null; break; case MOCORE: - String fileName = config.getInputFolder() + String fileName = this.config.getInputFolder() .lastSegment(); if (fileName.isEmpty()) { - fileName = config.getInputFolder() + fileName = this.config.getInputFolder() .trimSegments(1) .lastSegment(); } - String mocoreBase = outDir.appendSegment(fileName) + final String mocoreBase = this.outDir.appendSegment(fileName) .toString() + "."; - repository = ModelLoader.loadRepository(mocoreBase + "repository"); - system = ModelLoader.loadSystem(mocoreBase + "system"); - resourceEnvironment = ModelLoader.loadResourceEnvironment(mocoreBase + "resourceenvironment"); - allocation = ModelLoader.loadAllocation(mocoreBase + "allocation"); + this.repository = ModelLoader.loadRepository(mocoreBase + "repository"); + this.system = ModelLoader.loadSystem(mocoreBase + "system"); + this.resourceEnvironment = ModelLoader.loadResourceEnvironment(mocoreBase + "resourceenvironment"); + this.allocation = ModelLoader.loadAllocation(mocoreBase + "allocation"); break; default: throw new IllegalArgumentException("Unhandled artifact type!"); @@ -414,48 +425,48 @@ void testMoCoReAllocation() { @Test void retrieverRepository() { - loadArtifacts(Artifacts.RETRIEVER); - testRetrieverRepository(); + this.loadArtifacts(Artifacts.RETRIEVER); + this.testRetrieverRepository(); } @Test void retrieverSeff() { - loadArtifacts(Artifacts.RETRIEVER); - testRetrieverSeff(); + this.loadArtifacts(Artifacts.RETRIEVER); + this.testRetrieverSeff(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReRepository() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReRepository(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReRepository(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReSeff() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReSeff(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReSeff(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReSystem() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReSystem(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReSystem(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReResourceEnvironment() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReResourceEnvironment(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReResourceEnvironment(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReAllocation() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReAllocation(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReAllocation(); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/JaxRsTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/JaxRsTest.java index b5266cc9..19aa288f 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/JaxRsTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/JaxRsTest.java @@ -10,6 +10,6 @@ protected JaxRsTest() { @Override void testRetrieverRepository() { - assertComponentExists("jax_rs_AWebService"); + this.assertComponentExists("jax_rs_AWebService"); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PetclinicTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PetclinicTest.java index 6c8ae47d..39499c10 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PetclinicTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PetclinicTest.java @@ -13,33 +13,34 @@ protected PetclinicTest() { @Override void testRetrieverRepository() { // TODO: Temporarily disabled due to rule changes. - if (getClass() != null) + if (this.getClass() != null) { return; + } - assertComponentExists("org_springframework_samples_petclinic_api_boundary_web_ApiGatewayController"); + this.assertComponentExists("org_springframework_samples_petclinic_api_boundary_web_ApiGatewayController"); - assertComponentProvidesOperation("org_springframework_samples_petclinic_vets_web_VetResource", + this.assertComponentProvidesOperation("org_springframework_samples_petclinic_vets_web_VetResource", "/vets-service/vets[GET]", "/vets-service/vets[GET]"); - assertComponentProvidesOperation("org_springframework_samples_petclinic_visits_web_VisitResource", + this.assertComponentProvidesOperation("org_springframework_samples_petclinic_visits_web_VisitResource", "/visits-service", "/visits-service/pets/visits[GET]"); - assertComponentProvidesOperation("org_springframework_samples_petclinic_customers_web_PetResource", + this.assertComponentProvidesOperation("org_springframework_samples_petclinic_customers_web_PetResource", "/customers-service/owners/*/pets", "/customers-service/owners/*/pets[GET]"); - assertMaxParameterCount(2, "/customers-service/owners[PUT]", "/customers-service/owners[PUT]"); - assertMaxParameterCount(1, "/api-gateway/api/gateway/owners[GET]", "/api-gateway/api/gateway/owners[GET]"); + this.assertMaxParameterCount(2, "/customers-service/owners[PUT]", "/customers-service/owners[PUT]"); + this.assertMaxParameterCount(1, "/api-gateway/api/gateway/owners[GET]", "/api-gateway/api/gateway/owners[GET]"); - assertComponentRequiresComponent("org_springframework_samples_petclinic_customers_web_PetResource", + this.assertComponentRequiresComponent("org_springframework_samples_petclinic_customers_web_PetResource", "org_springframework_samples_petclinic_customers_model_PetRepository"); - assertComponentRequiresComponent("org_springframework_samples_petclinic_customers_web_PetResource", + this.assertComponentRequiresComponent("org_springframework_samples_petclinic_customers_web_PetResource", "org_springframework_samples_petclinic_customers_model_OwnerRepository"); - assertInSameCompositeComponent("org_springframework_samples_petclinic_customers_web_PetResource", + this.assertInSameCompositeComponent("org_springframework_samples_petclinic_customers_web_PetResource", "org_springframework_samples_petclinic_customers_model_PetRepository"); - assertInSameCompositeComponent("org_springframework_samples_petclinic_customers_web_PetResource", + this.assertInSameCompositeComponent("org_springframework_samples_petclinic_customers_web_PetResource", "org_springframework_samples_petclinic_customers_web_OwnerResource"); - assertInSameCompositeComponent("org_springframework_samples_petclinic_visits_web_VisitResource", + this.assertInSameCompositeComponent("org_springframework_samples_petclinic_visits_web_VisitResource", "org_springframework_samples_petclinic_visits_model_VisitRepository"); - assertInSameCompositeComponent("org_springframework_samples_petclinic_vets_web_VetResource", + this.assertInSameCompositeComponent("org_springframework_samples_petclinic_vets_web_VetResource", "org_springframework_samples_petclinic_vets_model_VetRepository"); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PiggymetricsTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PiggymetricsTest.java index 948eb511..5c9613d6 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PiggymetricsTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PiggymetricsTest.java @@ -13,38 +13,39 @@ protected PiggymetricsTest() { @Override void testRetrieverRepository() { // TODO: Temporarily disabled due to rule changes. - if (getClass() != null) + if (this.getClass() != null) { return; + } - assertComponentExists("com_piggymetrics_account_client_AuthServiceClient"); - assertComponentExists("com_piggymetrics_notification_service_NotificationServiceImpl"); + this.assertComponentExists("com_piggymetrics_account_client_AuthServiceClient"); + this.assertComponentExists("com_piggymetrics_notification_service_NotificationServiceImpl"); - assertComponentProvidesOperation("com_piggymetrics_statistics_controller_StatisticsController", "/statistics", - "/statistics/current"); - assertComponentProvidesOperation("com_piggymetrics_account_controller_AccountController", "/accounts", + this.assertComponentProvidesOperation("com_piggymetrics_statistics_controller_StatisticsController", + "/statistics", "/statistics/current"); + this.assertComponentProvidesOperation("com_piggymetrics_account_controller_AccountController", "/accounts", "/accounts"); - assertComponentProvidesOperation("com_piggymetrics_notification_controller_RecipientController", + this.assertComponentProvidesOperation("com_piggymetrics_notification_controller_RecipientController", "/notifications/recipients", "/notifications/recipients"); - assertMaxParameterCount(2, "com_piggymetrics_notification_service_RecipientService", "markNotified"); + this.assertMaxParameterCount(2, "com_piggymetrics_notification_service_RecipientService", "markNotified"); - assertComponentRequiresComponent("com_piggymetrics_notification_client_AccountServiceClient", + this.assertComponentRequiresComponent("com_piggymetrics_notification_client_AccountServiceClient", "com_piggymetrics_account_controller_AccountController"); - assertComponentRequiresComponent("com_piggymetrics_auth_service_UserServiceImpl", + this.assertComponentRequiresComponent("com_piggymetrics_auth_service_UserServiceImpl", "com_piggymetrics_auth_repository_UserRepository"); - assertComponentRequiresComponent("com_piggymetrics_notification_controller_RecipientController", + this.assertComponentRequiresComponent("com_piggymetrics_notification_controller_RecipientController", "com_piggymetrics_notification_service_RecipientServiceImpl"); - assertInSameCompositeComponent("com_piggymetrics_notification_controller_RecipientController", + this.assertInSameCompositeComponent("com_piggymetrics_notification_controller_RecipientController", "com_piggymetrics_notification_service_NotificationServiceImpl"); - assertInSameCompositeComponent("com_piggymetrics_notification_controller_RecipientController", + this.assertInSameCompositeComponent("com_piggymetrics_notification_controller_RecipientController", "com_piggymetrics_notification_service_RecipientServiceImpl"); - assertInSameCompositeComponent("com_piggymetrics_notification_service_NotificationServiceImpl", + this.assertInSameCompositeComponent("com_piggymetrics_notification_service_NotificationServiceImpl", "com_piggymetrics_notification_client_AccountServiceClient"); - assertInSameCompositeComponent("com_piggymetrics_account_controller_AccountController", + this.assertInSameCompositeComponent("com_piggymetrics_account_controller_AccountController", "com_piggymetrics_account_client_AuthServiceClient"); - assertInSameCompositeComponent("com_piggymetrics_account_controller_AccountController", + this.assertInSameCompositeComponent("com_piggymetrics_account_controller_AccountController", "com_piggymetrics_account_client_StatisticsServiceClient"); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SeffAssociationTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SeffAssociationTest.java index 14c85d90..2e73df41 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SeffAssociationTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SeffAssociationTest.java @@ -28,11 +28,11 @@ public class SeffAssociationTest extends CaseStudyTest { */ @Test void allAssociationsReferToMethods() { - RetrieverBlackboard blackboard = getBlackboard(); - Map associations = blackboard.getSeffAssociations(); + final RetrieverBlackboard blackboard = this.getBlackboard(); + final Map associations = blackboard.getSeffAssociations(); - for (Map.Entry association : associations.entrySet()) { - ASTNode astNode = association.getKey(); + for (final Map.Entry association : associations.entrySet()) { + final ASTNode astNode = association.getKey(); assertTrue(astNode instanceof MethodDeclaration, "All ASTNodes in the SEFF/AST associations must be MethodDeclarations"); // SEFF names may have a "$N" suffix after the signature name, where N is a positive @@ -47,10 +47,10 @@ void allAssociationsReferToMethods() { @Override void testRetrieverSeff() { - RetrieverBlackboard blackboard = getBlackboard(); + final RetrieverBlackboard blackboard = this.getBlackboard(); @SuppressWarnings("unchecked") - MethodDeclaration methodDeclaration = blackboard + final MethodDeclaration methodDeclaration = blackboard .getDiscoveredFiles(JavaDiscoverer.DISCOVERER_ID, CompilationUnit.class) .values() .stream() @@ -67,7 +67,7 @@ void testRetrieverSeff() { .findAny() .orElseGet(() -> fail("AController::aMethod must be present in AST")); - Map associations = blackboard.getSeffAssociations(); + final Map associations = blackboard.getSeffAssociations(); // Assume that the SPRING rule detects constructors of components. assertTrue(associations.containsKey(methodDeclaration), diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SpringTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SpringTest.java index 01991acd..f6aaf724 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SpringTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SpringTest.java @@ -10,6 +10,6 @@ protected SpringTest() { @Override void testRetrieverRepository() { - assertComponentExists("spring_AController"); + this.assertComponentExists("spring_AController"); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/TeaStoreTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/TeaStoreTest.java index 972d6783..9195eb69 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/TeaStoreTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/TeaStoreTest.java @@ -13,15 +13,16 @@ protected TeaStoreTest() { @Override void testRetrieverRepository() { // TODO: Temporarily disabled due to rule changes. - if (getClass() != null) + if (this.getClass() != null) { return; + } - assertComponentExists("tools_descartes_teastore_auth_security_BCryptProvider"); - assertInterfaceExists("tools_descartes_teastore_kieker_probes_records_IPayloadCharacterization"); + this.assertComponentExists("tools_descartes_teastore_auth_security_BCryptProvider"); + this.assertInterfaceExists("tools_descartes_teastore_kieker_probes_records_IPayloadCharacterization"); - assertComponentProvidesOperation("tools_descartes_teastore_recommender_algorithm_AbstractRecommender", + this.assertComponentProvidesOperation("tools_descartes_teastore_recommender_algorithm_AbstractRecommender", "tools_descartes_teastore_recommender_algorithm_IRecommender", "train"); - assertComponentProvidesOperation("tools_descartes_teastore_recommender_algorithm_AbstractRecommender", + this.assertComponentProvidesOperation("tools_descartes_teastore_recommender_algorithm_AbstractRecommender", "tools_descartes_teastore_recommender_algorithm_IRecommender", "recommendProducts"); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/CompositeTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/CompositeTest.java index b7718914..003d3b83 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/CompositeTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/CompositeTest.java @@ -23,9 +23,9 @@ public class CompositeTest { @Test void emptyComposite() { - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); - Composite result = compositeBuilder.construct(List.of(), new Requirements(List.of(), List.of(), List.of()), - new Provisions(List.of(), List.of()), List.of()); + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + final Composite result = compositeBuilder.construct(List.of(), + new Requirements(List.of(), List.of(), List.of()), new Provisions(List.of(), List.of()), List.of()); assertTrue(result.parts() .isEmpty(), "empty composite should have no parts"); @@ -37,22 +37,22 @@ void emptyComposite() { @Test void singletonComposite() { - OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); - EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); + final OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); + final EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); - ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); + final ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); componentBuilder.provisions() .add(provision); componentBuilder.requirements() .add(requirement); - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); compositeBuilder.addPart(componentBuilder); - List allDependencies = List.of(provision, requirement); - List visibleProvisions = List.of(provision); + final List allDependencies = List.of(provision, requirement); + final List visibleProvisions = List.of(provision); - Composite result = compositeBuilder.construct(List.of(), + final Composite result = compositeBuilder.construct(List.of(), new Requirements(List.of(), allDependencies, visibleProvisions), new Provisions(List.of(), allDependencies), visibleProvisions); @@ -63,7 +63,7 @@ void singletonComposite() { assertTrue(result.provisions() .isEmpty(), "this composite should not have provisions"); - Component component = result.parts() + final Component component = result.parts() .stream() .findFirst() .get(); @@ -77,22 +77,22 @@ void singletonComposite() { @Test void exposingSingletonComposite() { - OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); - EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); + final OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); + final EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); - ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); + final ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); componentBuilder.provisions() .add(provision); componentBuilder.requirements() .add(requirement); - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); compositeBuilder.addPart(componentBuilder); - List allDependencies = List.of(provision, requirement); - List visibleProvisions = List.of(provision); + final List allDependencies = List.of(provision, requirement); + final List visibleProvisions = List.of(provision); - Composite result = compositeBuilder.construct(List.of(), + final Composite result = compositeBuilder.construct(List.of(), new Requirements(List.of(requirement), allDependencies, visibleProvisions), new Provisions(List.of(provision), allDependencies), visibleProvisions); @@ -106,31 +106,33 @@ void exposingSingletonComposite() { @Test void twoComponentComposite() { - OperationInterface provision1 = new Operation(null, new JavaOperationName("InterfaceA", "providedMethodA")); - OperationInterface provision2 = new Operation(null, new JavaOperationName("InterfaceB", "providedMethodB")); - EntireInterface requirement1 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceA")); - EntireInterface requirement2 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceB")); - - ComponentBuilder componentBuilder1 = new ComponentBuilder(new CompUnitOrName("Component 1")); + final OperationInterface provision1 = new Operation(null, + new JavaOperationName("InterfaceA", "providedMethodA")); + final OperationInterface provision2 = new Operation(null, + new JavaOperationName("InterfaceB", "providedMethodB")); + final EntireInterface requirement1 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceA")); + final EntireInterface requirement2 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceB")); + + final ComponentBuilder componentBuilder1 = new ComponentBuilder(new CompUnitOrName("Component 1")); componentBuilder1.provisions() .add(provision1); componentBuilder1.requirements() .add(requirement1); - ComponentBuilder componentBuilder2 = new ComponentBuilder(new CompUnitOrName("Component 2")); + final ComponentBuilder componentBuilder2 = new ComponentBuilder(new CompUnitOrName("Component 2")); componentBuilder2.provisions() .add(provision2); componentBuilder2.requirements() .add(requirement2); - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); compositeBuilder.addPart(componentBuilder1); compositeBuilder.addPart(componentBuilder2); - List allDependencies = List.of(provision1, provision2, requirement1, requirement2); - List visibleProvisions = List.of(provision1, provision2); + final List allDependencies = List.of(provision1, provision2, requirement1, requirement2); + final List visibleProvisions = List.of(provision1, provision2); - Composite result = compositeBuilder.construct(List.of(), + final Composite result = compositeBuilder.construct(List.of(), new Requirements(List.of(requirement1, requirement2), allDependencies, visibleProvisions), new Provisions(List.of(provision1, provision2), allDependencies), visibleProvisions); @@ -144,12 +146,12 @@ void twoComponentComposite() { @Test void overlappingTwoComponentComposite() { - OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); - EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); - EntireInterface additionalRequirement1 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceA")); - EntireInterface additionalRequirement2 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceB")); + final OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); + final EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); + final EntireInterface additionalRequirement1 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceA")); + final EntireInterface additionalRequirement2 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceB")); - ComponentBuilder componentBuilder1 = new ComponentBuilder(new CompUnitOrName("Component 1")); + final ComponentBuilder componentBuilder1 = new ComponentBuilder(new CompUnitOrName("Component 1")); componentBuilder1.provisions() .add(provision); componentBuilder1.requirements() @@ -157,7 +159,7 @@ void overlappingTwoComponentComposite() { componentBuilder1.requirements() .add(additionalRequirement1); - ComponentBuilder componentBuilder2 = new ComponentBuilder(new CompUnitOrName("Component 2")); + final ComponentBuilder componentBuilder2 = new ComponentBuilder(new CompUnitOrName("Component 2")); componentBuilder2.provisions() .add(provision); componentBuilder2.requirements() @@ -165,15 +167,15 @@ void overlappingTwoComponentComposite() { componentBuilder2.requirements() .add(additionalRequirement2); - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); compositeBuilder.addPart(componentBuilder1); compositeBuilder.addPart(componentBuilder2); - List allDependencies = List.of(provision, requirement, additionalRequirement1, + final List allDependencies = List.of(provision, requirement, additionalRequirement1, additionalRequirement2); - List visibleProvisions = List.of(provision); + final List visibleProvisions = List.of(provision); - Composite result = compositeBuilder.construct(List.of(), + final Composite result = compositeBuilder.construct(List.of(), new Requirements(List.of(requirement), allDependencies, visibleProvisions), new Provisions(List.of(provision), allDependencies), visibleProvisions); @@ -188,20 +190,20 @@ void overlappingTwoComponentComposite() { @Test void impreciseExposure() { // TODO: Re-think this test. - OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); - OperationInterface impreciseProvision = new EntireInterface(new JavaInterfaceName("Interface")); + final OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); + final OperationInterface impreciseProvision = new EntireInterface(new JavaInterfaceName("Interface")); - ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); + final ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); componentBuilder.provisions() .add(provision); - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); compositeBuilder.addPart(componentBuilder); - List allDependencies = List.of(provision); - List visibleProvisions = List.of(provision); + final List allDependencies = List.of(provision); + final List visibleProvisions = List.of(provision); - Composite result = compositeBuilder.construct(List.of(), + final Composite result = compositeBuilder.construct(List.of(), new Requirements(List.of(), allDependencies, visibleProvisions), new Provisions(List.of(impreciseProvision), allDependencies), visibleProvisions); diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/InterfaceTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/InterfaceTest.java index 5d6ec67d..b3794bcf 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/InterfaceTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/InterfaceTest.java @@ -24,33 +24,33 @@ public class InterfaceTest { @Test void singleJavaOperation() { - ComponentBuilder builder = new ComponentBuilder(null); - Operation expectedOperation = new Operation(null, new JavaOperationName("Interface", "method")); + final ComponentBuilder builder = new ComponentBuilder(null); + final Operation expectedOperation = new Operation(null, new JavaOperationName("Interface", "method")); builder.provisions() .add(expectedOperation); - List allDependencies = List.of(expectedOperation); - List visibleProvisions = List.of(expectedOperation); + final List allDependencies = List.of(expectedOperation); + final List visibleProvisions = List.of(expectedOperation); - Component builtComponent = builder.create(allDependencies, visibleProvisions); + final Component builtComponent = builder.create(allDependencies, visibleProvisions); assertTrue(builtComponent.provisions() .containsPartOf(expectedOperation)); - Map> simplifiedProvisions = builtComponent.provisions() + final Map> simplifiedProvisions = builtComponent.provisions() .simplified(); - Set interfaces = simplifiedProvisions.keySet(); + final Set interfaces = simplifiedProvisions.keySet(); assertFalse(interfaces.isEmpty(), "empty result"); assertEquals(1, interfaces.size(), "more than one interface"); - OperationInterface commonInterface = interfaces.stream() + final OperationInterface commonInterface = interfaces.stream() .findFirst() .get(); assertEquals(expectedOperation, commonInterface, "operation does not have the correct interface"); - List operations = simplifiedProvisions.get(expectedOperation); + final List operations = simplifiedProvisions.get(expectedOperation); assertEquals(1, operations.size(), "more than one operation in the interface"); - List firstMethodCandidates = operations.stream() + final List firstMethodCandidates = operations.stream() .filter(x -> Optional.of("method") .equals(x.getName() .forInterface("Interface"))) @@ -63,33 +63,33 @@ void singleJavaOperation() { @Test void singlePathOperation() { - ComponentBuilder builder = new ComponentBuilder(null); - Operation expectedOperation = new Operation(null, new RESTName("test-host", "/method", Optional.empty())); + final ComponentBuilder builder = new ComponentBuilder(null); + final Operation expectedOperation = new Operation(null, new RESTName("test-host", "/method", Optional.empty())); builder.provisions() .add(expectedOperation); - List allDependencies = List.of(expectedOperation); - List visibleProvisions = List.of(expectedOperation); + final List allDependencies = List.of(expectedOperation); + final List visibleProvisions = List.of(expectedOperation); - Component builtComponent = builder.create(allDependencies, visibleProvisions); + final Component builtComponent = builder.create(allDependencies, visibleProvisions); assertTrue(builtComponent.provisions() .containsPartOf(expectedOperation)); - Map> simplifiedProvisions = builtComponent.provisions() + final Map> simplifiedProvisions = builtComponent.provisions() .simplified(); - Set interfaces = simplifiedProvisions.keySet(); + final Set interfaces = simplifiedProvisions.keySet(); assertFalse(interfaces.isEmpty(), "empty result"); assertEquals(1, interfaces.size(), "more than one interface"); - OperationInterface commonInterface = interfaces.stream() + final OperationInterface commonInterface = interfaces.stream() .findFirst() .get(); assertEquals(expectedOperation, commonInterface, "operation does not have the correct interface"); - List operations = simplifiedProvisions.get(commonInterface); + final List operations = simplifiedProvisions.get(commonInterface); assertEquals(1, operations.size(), "more than one operation in the interface"); - List firstMethodCandidates = operations.stream() + final List firstMethodCandidates = operations.stream() .filter(x -> Optional.of("test-host/method") .equals(x.getName() .forInterface("test-host/method"))) @@ -102,37 +102,37 @@ void singlePathOperation() { @Test void entireJavaInterface() { - ComponentBuilder builder = new ComponentBuilder(null); - Operation firstMethod = new Operation(null, new JavaOperationName("CommonInterface", "firstMethod")); - Operation secondMethod = new Operation(null, new JavaOperationName("CommonInterface", "secondMethod")); + final ComponentBuilder builder = new ComponentBuilder(null); + final Operation firstMethod = new Operation(null, new JavaOperationName("CommonInterface", "firstMethod")); + final Operation secondMethod = new Operation(null, new JavaOperationName("CommonInterface", "secondMethod")); builder.provisions() .add(firstMethod); builder.provisions() .add(secondMethod); - List allDependencies = List.of(firstMethod, secondMethod); - List visibleProvisions = List.of(firstMethod, secondMethod); + final List allDependencies = List.of(firstMethod, secondMethod); + final List visibleProvisions = List.of(firstMethod, secondMethod); - Component builtComponent = builder.create(allDependencies, visibleProvisions); - EntireInterface expectedInterface = new EntireInterface(new JavaInterfaceName("CommonInterface")); + final Component builtComponent = builder.create(allDependencies, visibleProvisions); + final EntireInterface expectedInterface = new EntireInterface(new JavaInterfaceName("CommonInterface")); assertTrue(builtComponent.provisions() .containsPartOf(expectedInterface)); - Map> simplifiedProvisions = builtComponent.provisions() + final Map> simplifiedProvisions = builtComponent.provisions() .simplified(); - Set interfaces = simplifiedProvisions.keySet(); + final Set interfaces = simplifiedProvisions.keySet(); assertFalse(interfaces.isEmpty(), "empty result"); assertEquals(1, interfaces.size(), "more than one interface"); - OperationInterface commonInterface = interfaces.stream() + final OperationInterface commonInterface = interfaces.stream() .findFirst() .get(); assertEquals(expectedInterface, commonInterface, "common interface is not correct"); - List operations = simplifiedProvisions.get(commonInterface); + final List operations = simplifiedProvisions.get(commonInterface); assertEquals(2, operations.size(), "wrong number of operations in the interface"); - List firstMethodCandidates = operations.stream() + final List firstMethodCandidates = operations.stream() .filter(x -> Optional.of("firstMethod") .equals(x.getName() .forInterface("CommonInterface"))) @@ -141,7 +141,7 @@ void entireJavaInterface() { assertFalse(firstMethodCandidates.isEmpty(), "interface does not contain first method"); assertEquals(1, firstMethodCandidates.size(), "interface contains multiple instances of first method"); - List secondMethodCandidates = operations.stream() + final List secondMethodCandidates = operations.stream() .filter(x -> Optional.of("secondMethod") .equals(x.getName() .forInterface("CommonInterface"))) @@ -155,40 +155,40 @@ void entireJavaInterface() { @Test void entirePathInterface() { - ComponentBuilder builder = new ComponentBuilder(null); - Operation firstMethod = new Operation(null, + final ComponentBuilder builder = new ComponentBuilder(null); + final Operation firstMethod = new Operation(null, new RESTName("test-host", "/common_interface/first_method", Optional.empty())); - Operation secondMethod = new Operation(null, + final Operation secondMethod = new Operation(null, new RESTName("test-host", "/common_interface/second_method", Optional.empty())); builder.provisions() .add(firstMethod); builder.provisions() .add(secondMethod); - List allDependencies = List.of(firstMethod, secondMethod); - List visibleProvisions = List.of(firstMethod, secondMethod); + final List allDependencies = List.of(firstMethod, secondMethod); + final List visibleProvisions = List.of(firstMethod, secondMethod); - Component builtComponent = builder.create(allDependencies, visibleProvisions); - EntireInterface expectedInterface = new EntireInterface( + final Component builtComponent = builder.create(allDependencies, visibleProvisions); + final EntireInterface expectedInterface = new EntireInterface( new RESTName("test-host", "/common_interface", Optional.empty())); assertTrue(builtComponent.provisions() .containsPartOf(expectedInterface)); - Map> simplifiedProvisions = builtComponent.provisions() + final Map> simplifiedProvisions = builtComponent.provisions() .simplified(); - Set interfaces = simplifiedProvisions.keySet(); + final Set interfaces = simplifiedProvisions.keySet(); assertFalse(interfaces.isEmpty(), "empty result"); assertEquals(1, interfaces.size(), "more than one interface"); - OperationInterface commonInterface = interfaces.stream() + final OperationInterface commonInterface = interfaces.stream() .findFirst() .get(); assertEquals(expectedInterface, commonInterface, "common interface is not correct"); - List operations = simplifiedProvisions.get(commonInterface); + final List operations = simplifiedProvisions.get(commonInterface); assertEquals(2, operations.size(), "wrong number of operations in the interface"); - List firstMethodCandidates = operations.stream() + final List firstMethodCandidates = operations.stream() .filter(x -> Optional.of("test-host/common_interface/first_method") .equals(x.getName() .forInterface("test-host/common_interface"))) @@ -197,7 +197,7 @@ void entirePathInterface() { assertFalse(firstMethodCandidates.isEmpty(), "interface does not contain first method"); assertEquals(1, firstMethodCandidates.size(), "interface contains multiple instances of first method"); - List secondMethodCandidates = operations.stream() + final List secondMethodCandidates = operations.stream() .filter(x -> Optional.of("test-host/common_interface/second_method") .equals(x.getName() .forInterface("test-host/common_interface"))) diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/PathTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/PathTest.java index 20de9aa3..d589c116 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/PathTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/PathTest.java @@ -16,17 +16,17 @@ public class PathTest { @Test void pathNamesAreReflective() { - String host = "test-host"; - String path = "/some/path"; - RESTName pathName = new RESTName(host, path, Optional.empty()); + final String host = "test-host"; + final String path = "/some/path"; + final RESTName pathName = new RESTName(host, path, Optional.empty()); assertTrue(pathName.isPartOf(host + path)); } @Test void pathsArePartOfTheirPrefixes() { - String path = "/some/path"; - RESTName interfaceName = new RESTName("test-host", path, Optional.empty()); - RESTName specificName = new RESTName("test-host", path + "/that/is/more/specific", Optional.empty()); + final String path = "/some/path"; + final RESTName interfaceName = new RESTName("test-host", path, Optional.empty()); + final RESTName specificName = new RESTName("test-host", path + "/that/is/more/specific", Optional.empty()); assertTrue(specificName.isPartOf(interfaceName.getName()), "specific path is not part of its prefix"); assertFalse(interfaceName.isPartOf(specificName.getName()), "prefix is part of a longer path"); @@ -35,10 +35,12 @@ void pathsArePartOfTheirPrefixes() { @Test void prefixesAreSeparatorAware() { // This is NOT a legal prefix of "/some/path/..." - String somePath = "/some/pa"; - EntireInterface entireInterface = new EntireInterface(new RESTName("test-host", somePath, Optional.empty())); - RESTName specificPathName = new RESTName("test-host", "/some/path/that/is/more/specific", Optional.empty()); - Operation operation = new Operation(null, specificPathName); + final String somePath = "/some/pa"; + final EntireInterface entireInterface = new EntireInterface( + new RESTName("test-host", somePath, Optional.empty())); + final RESTName specificPathName = new RESTName("test-host", "/some/path/that/is/more/specific", + Optional.empty()); + final Operation operation = new Operation(null, specificPathName); assertFalse(operation.isPartOf(entireInterface), "operation is part of illegal prefix"); } @@ -46,12 +48,12 @@ void prefixesAreSeparatorAware() { @Disabled("This requirement has been temporarily softened for the Spring Gateway") @Test void httpMethodsAreSpecializations() { - String path = "/some/path"; - RESTName generalName = new RESTName("test-host", path, Optional.empty()); - RESTName specificName = new RESTName("test-host", path, Optional.of(HTTPMethod.GET)); + final String path = "/some/path"; + final RESTName generalName = new RESTName("test-host", path, Optional.empty()); + final RESTName specificName = new RESTName("test-host", path, Optional.of(HTTPMethod.GET)); - Operation generalOperation = new Operation(null, generalName); - Operation specificOperation = new Operation(null, specificName); + final Operation generalOperation = new Operation(null, generalName); + final Operation specificOperation = new Operation(null, specificName); assertTrue(specificOperation.isPartOf(generalOperation)); assertFalse(generalOperation.isPartOf(specificOperation)); diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PersistenceJobTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PersistenceJobTest.java index b994695d..95944769 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PersistenceJobTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PersistenceJobTest.java @@ -39,7 +39,7 @@ public void cleanUpDirectories() throws IOException { @Test public void testConstructorWithValidInput() { - Blackboard blackboard = new Blackboard(); + final Blackboard blackboard = new Blackboard<>(); assertDoesNotThrow( () -> new PersistenceJob(blackboard, INPUT_FOLDER, TEMPORARY_OUTPUT_FOLDER, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_INPUT_SYSTEM, BLACKBOARD_INPUT_ALLOCATION, BLACKBOARD_INPUT_RESOURCEENVIRONMENT)); @@ -47,20 +47,20 @@ public void testConstructorWithValidInput() { @Test public void testSaveEmptyModelsToCurrentDirectory() { - Blackboard blackboard = new Blackboard(); - PersistenceJob job = new PersistenceJob(blackboard, INPUT_FOLDER, TEMPORARY_OUTPUT_FOLDER, + final Blackboard blackboard = new Blackboard<>(); + final PersistenceJob job = new PersistenceJob(blackboard, INPUT_FOLDER, TEMPORARY_OUTPUT_FOLDER, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_INPUT_SYSTEM, BLACKBOARD_INPUT_ALLOCATION, BLACKBOARD_INPUT_RESOURCEENVIRONMENT); // Initialize models - Repository repository = new FluentRepositoryFactory().newRepository() + final Repository repository = new FluentRepositoryFactory().newRepository() .createRepositoryNow(); - System system = new FluentSystemFactory().newSystem() + final System system = new FluentSystemFactory().newSystem() .addRepository(repository) .createSystemNow(); - ResourceEnvironment resource = new FluentResourceEnvironmentFactory().newResourceEnvironment() + final ResourceEnvironment resource = new FluentResourceEnvironmentFactory().newResourceEnvironment() .createResourceEnvironmentNow(); - Allocation allocation = new FluentAllocationFactory().newAllocation() + final Allocation allocation = new FluentAllocationFactory().newAllocation() .createAllocationNow(); // Add models to blackboard diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PostAnalysisJobTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PostAnalysisJobTest.java index ce2b7227..dda33f56 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PostAnalysisJobTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PostAnalysisJobTest.java @@ -79,49 +79,50 @@ public class PostAnalysisJobTest { @BeforeEach public void setupEnvironment() throws IOException { - Repository repository = RepositoryFactory.eINSTANCE.createRepository(); - Map ast2seffMap = new HashMap<>(); + final Repository repository = RepositoryFactory.eINSTANCE.createRepository(); + final Map ast2seffMap = new HashMap<>(); - Path directoryPath = Path.of(DIRECTORY_CASESTUDY); - Map compilationUnits = parseCasestudyPackage(directoryPath); + final Path directoryPath = Path.of(DIRECTORY_CASESTUDY); + final Map compilationUnits = this.parseCasestudyPackage(directoryPath); // For each comp. unit fill repository & ast2seff map with correct elements - for (CompilationUnit compilationUnit : compilationUnits.values()) { - List methodDeclarations = MethodDeclarationVisitor.perform(compilationUnit); + for (final CompilationUnit compilationUnit : compilationUnits.values()) { + final List methodDeclarations = MethodDeclarationVisitor.perform(compilationUnit); // Associate method declarations with class names (-> usually single class per comp. // unit) - Multimap classDeclarations = HashMultimap.create(); - for (MethodDeclaration methodDeclaration : methodDeclarations) { - TypeDeclaration typeDeclaration = (TypeDeclaration) methodDeclaration.getParent(); - String className = typeDeclaration.getName() + final Multimap classDeclarations = HashMultimap.create(); + for (final MethodDeclaration methodDeclaration : methodDeclarations) { + final TypeDeclaration typeDeclaration = (TypeDeclaration) methodDeclaration.getParent(); + final String className = typeDeclaration.getName() .toString(); classDeclarations.put(className, methodDeclaration); } // For each class create one component, one interface, associated signatures, & seffs - for (String className : classDeclarations.keySet()) { + for (final String className : classDeclarations.keySet()) { // Create component - BasicComponent component = RepositoryFactory.eINSTANCE.createBasicComponent(); + final BasicComponent component = RepositoryFactory.eINSTANCE.createBasicComponent(); component.setEntityName(className); component.setRepository__RepositoryComponent(repository); // Create operation interface - OperationInterface operationInterface = RepositoryFactory.eINSTANCE.createOperationInterface(); + final OperationInterface operationInterface = RepositoryFactory.eINSTANCE.createOperationInterface(); operationInterface.setEntityName(className + "able"); operationInterface.setRepository__Interface(repository); // Add interface to component via provided role - OperationProvidedRole providedRole = RepositoryFactory.eINSTANCE.createOperationProvidedRole(); + final OperationProvidedRole providedRole = RepositoryFactory.eINSTANCE.createOperationProvidedRole(); providedRole.setProvidedInterface__OperationProvidedRole(operationInterface); component.getProvidedRoles_InterfaceProvidingEntity() .add(providedRole); // Create signatures & Create seffs - for (MethodDeclaration methodDeclaration : classDeclarations.get(className)) { - String methodName = methodDeclaration.getName() + for (final MethodDeclaration methodDeclaration : classDeclarations.get(className)) { + final String methodName = methodDeclaration.getName() .toString(); - OperationSignature operationSignature = RepositoryFactory.eINSTANCE.createOperationSignature(); + final OperationSignature operationSignature = RepositoryFactory.eINSTANCE + .createOperationSignature(); operationSignature.setEntityName(methodName); // Add signature to interface @@ -129,7 +130,7 @@ public void setupEnvironment() throws IOException { .add(operationSignature); // Create seff for signature & add to component - ResourceDemandingSEFF seff = SeffFactory.eINSTANCE.createResourceDemandingSEFF(); + final ResourceDemandingSEFF seff = SeffFactory.eINSTANCE.createResourceDemandingSEFF(); seff.setBasicComponent_ServiceEffectSpecification(component); seff.setDescribedService__SEFF(operationSignature); @@ -140,25 +141,25 @@ public void setupEnvironment() throws IOException { } // Add required roles manually - List> requiredRelations = List.of(Pair.create("EntityService", "EntityRepository"), + final List> requiredRelations = List.of(Pair.create("EntityService", "EntityRepository"), Pair.create("EntityService", "Entity"), Pair.create("EntityRepository", "Entity")); - for (Pair requiredRelation : requiredRelations) { - BasicComponent requirerer = (BasicComponent) repository.getComponents__Repository() + for (final Pair requiredRelation : requiredRelations) { + final BasicComponent requirerer = (BasicComponent) repository.getComponents__Repository() .stream() .filter(component -> component.getEntityName() .equals(requiredRelation.getElement1())) .findFirst() .orElseThrow(); - BasicComponent provider = (BasicComponent) repository.getComponents__Repository() + final BasicComponent provider = (BasicComponent) repository.getComponents__Repository() .stream() .filter(component -> component.getEntityName() .equals(requiredRelation.getElement2())) .findFirst() .orElseThrow(); - OperationInterface providerInterface = ((OperationProvidedRole) provider + final OperationInterface providerInterface = ((OperationProvidedRole) provider .getProvidedRoles_InterfaceProvidingEntity() .get(0)).getProvidedInterface__OperationProvidedRole(); - OperationRequiredRole requiredRole = RepositoryFactory.eINSTANCE.createOperationRequiredRole(); + final OperationRequiredRole requiredRole = RepositoryFactory.eINSTANCE.createOperationRequiredRole(); requiredRole.setRequiredInterface__OperationRequiredRole(providerInterface); requirerer.getRequiredRoles_InterfaceRequiringEntity() .add(requiredRole); @@ -191,21 +192,22 @@ public static void setupOutputDirectory() throws IOException { @Test public void processAnalysedCasestudyWithAst2SeffJob() throws Exception { // Construct & execute job - Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, KEY_AST2SEFF_REPOSITORY); + final Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, + KEY_AST2SEFF_REPOSITORY); ast2SeffJob.execute(new NullProgressMonitor()); // Get output repo from blackboard & extract all seff elements - Repository outputRepository = (Repository) this.getBlackboard() + final Repository outputRepository = (Repository) this.getBlackboard() .getPartition(KEY_AST2SEFF_REPOSITORY); - List seffs = outputRepository.getComponents__Repository() + final List seffs = outputRepository.getComponents__Repository() .stream() .flatMap(component -> ((BasicComponent) component).getServiceEffectSpecifications__BasicComponent() .stream()) .collect(Collectors.toList()); // Assert all seffs have at least start & stop action - for (ServiceEffectSpecification seff : seffs) { - EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); + for (final ServiceEffectSpecification seff : seffs) { + final EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); assertTrue(actions.size() >= 2); assertTrue(actions.stream() .anyMatch(action -> action instanceof StartAction)); @@ -217,20 +219,21 @@ public void processAnalysedCasestudyWithAst2SeffJob() throws Exception { @Test public void mergeAst2SeffOutputWithRepository() throws Exception { // Construct jobs - Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, KEY_AST2SEFF_REPOSITORY); - SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, + final Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, + KEY_AST2SEFF_REPOSITORY); + final SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, KEY_ANALYSIS_REPOSITORY); // Assert empty seffs in analysis repository - Repository analysisRepository = (Repository) this.getBlackboard() + final Repository analysisRepository = (Repository) this.getBlackboard() .getPartition(KEY_ANALYSIS_REPOSITORY); List analysisRepositorySeffs = analysisRepository.getComponents__Repository() .stream() .flatMap(component -> ((BasicComponent) component).getServiceEffectSpecifications__BasicComponent() .stream()) .collect(Collectors.toList()); - for (ServiceEffectSpecification seff : analysisRepositorySeffs) { - EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); + for (final ServiceEffectSpecification seff : analysisRepositorySeffs) { + final EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); assertTrue(actions.isEmpty()); } @@ -244,8 +247,8 @@ public void mergeAst2SeffOutputWithRepository() throws Exception { .flatMap(component -> ((BasicComponent) component).getServiceEffectSpecifications__BasicComponent() .stream()) .collect(Collectors.toList()); - for (ServiceEffectSpecification seff : analysisRepositorySeffs) { - EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); + for (final ServiceEffectSpecification seff : analysisRepositorySeffs) { + final EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); assertTrue(actions.size() >= 2); assertTrue(actions.stream() .anyMatch(action -> action instanceof StartAction)); @@ -257,10 +260,11 @@ public void mergeAst2SeffOutputWithRepository() throws Exception { @Test public void refineIntermediateRepository() throws Exception { // Construct jobs - Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, KEY_AST2SEFF_REPOSITORY); - SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, + final Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, + KEY_AST2SEFF_REPOSITORY); + final SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, KEY_ANALYSIS_REPOSITORY); - MoCoReJob mocoreJob = new MoCoReJob(this.getBlackboard(), KEY_ANALYSIS_REPOSITORY, KEY_MOCORE_REPOSITORY, + final MoCoReJob mocoreJob = new MoCoReJob(this.getBlackboard(), KEY_ANALYSIS_REPOSITORY, KEY_MOCORE_REPOSITORY, KEY_MOCORE_SYSTEM, KEY_MOCORE_ALLOCATION, KEY_MOCORE_RESOURCE_ENVIRONMENT); // Execute jobs @@ -269,13 +273,14 @@ public void refineIntermediateRepository() throws Exception { mocoreJob.execute(new NullProgressMonitor()); // Fetch output models from blackboard - Repository repository = (Repository) this.getBlackboard() + final Repository repository = (Repository) this.getBlackboard() .getPartition(KEY_MOCORE_REPOSITORY); - org.palladiosimulator.pcm.system.System system = (org.palladiosimulator.pcm.system.System) this.getBlackboard() + final org.palladiosimulator.pcm.system.System system = (org.palladiosimulator.pcm.system.System) this + .getBlackboard() .getPartition(KEY_MOCORE_SYSTEM); - Allocation allocation = (Allocation) this.getBlackboard() + final Allocation allocation = (Allocation) this.getBlackboard() .getPartition(KEY_MOCORE_ALLOCATION); - ResourceEnvironment resourceEnvironment = (ResourceEnvironment) this.getBlackboard() + final ResourceEnvironment resourceEnvironment = (ResourceEnvironment) this.getBlackboard() .getPartition(KEY_MOCORE_RESOURCE_ENVIRONMENT); // Check repository validity @@ -285,13 +290,13 @@ public void refineIntermediateRepository() throws Exception { .size()); repository.getInterfaces__Repository() .forEach(interFace -> { - OperationInterface operationInterface = (OperationInterface) interFace; + final OperationInterface operationInterface = (OperationInterface) interFace; assertFalse(operationInterface.getSignatures__OperationInterface() .isEmpty()); }); repository.getComponents__Repository() .forEach(component -> { - BasicComponent basicComponent = (BasicComponent) component; + final BasicComponent basicComponent = (BasicComponent) component; assertFalse(basicComponent.getServiceEffectSpecifications__BasicComponent() .isEmpty()); assertFalse(basicComponent.getProvidedRoles_InterfaceProvidingEntity() @@ -322,14 +327,15 @@ public void refineIntermediateRepository() throws Exception { @Test public void persistModels() throws Exception { // Construct jobs - Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, KEY_AST2SEFF_REPOSITORY); - SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, + final Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, + KEY_AST2SEFF_REPOSITORY); + final SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, KEY_ANALYSIS_REPOSITORY); - MoCoReJob mocoreJob = new MoCoReJob(this.getBlackboard(), KEY_ANALYSIS_REPOSITORY, KEY_MOCORE_REPOSITORY, + final MoCoReJob mocoreJob = new MoCoReJob(this.getBlackboard(), KEY_ANALYSIS_REPOSITORY, KEY_MOCORE_REPOSITORY, KEY_MOCORE_SYSTEM, KEY_MOCORE_ALLOCATION, KEY_MOCORE_RESOURCE_ENVIRONMENT); - URI inputDirectory = URI.createURI(DIRECTORY_CASESTUDY); - URI outputDirectory = URI.createURI(this.temporaryOutputDirectory.toString()); - PersistenceJob persistenceJob = new PersistenceJob(this.getBlackboard(), inputDirectory, outputDirectory, + final URI inputDirectory = URI.createURI(DIRECTORY_CASESTUDY); + final URI outputDirectory = URI.createURI(this.temporaryOutputDirectory.toString()); + final PersistenceJob persistenceJob = new PersistenceJob(this.getBlackboard(), inputDirectory, outputDirectory, KEY_MOCORE_REPOSITORY, KEY_MOCORE_SYSTEM, KEY_MOCORE_ALLOCATION, KEY_MOCORE_RESOURCE_ENVIRONMENT); // Execute jobs @@ -339,35 +345,35 @@ public void persistModels() throws Exception { persistenceJob.execute(new NullProgressMonitor()); // Check if model files were created successfully - List paths = Files.walk(this.temporaryOutputDirectory) + final List paths = Files.walk(this.temporaryOutputDirectory) .toList(); - Path repositoryPath = paths.stream() + final Path repositoryPath = paths.stream() .filter(path -> com.google.common.io.Files.getFileExtension(path.toString()) .equals("repository")) .findFirst() .orElseThrow(); - Path systemPath = paths.stream() + final Path systemPath = paths.stream() .filter(path -> com.google.common.io.Files.getFileExtension(path.toString()) .equals("system")) .findFirst() .orElseThrow(); - Path resourceEnvironmentPath = paths.stream() + final Path resourceEnvironmentPath = paths.stream() .filter(path -> com.google.common.io.Files.getFileExtension(path.toString()) .equals("resourceenvironment")) .findFirst() .orElseThrow(); - Path allocationPath = paths.stream() + final Path allocationPath = paths.stream() .filter(path -> com.google.common.io.Files.getFileExtension(path.toString()) .equals("allocation")) .findFirst() .orElseThrow(); // Load model files saved to disk - Repository persistedRepository = ModelLoader.loadRepository(repositoryPath.toString()); - org.palladiosimulator.pcm.system.System persistedSystem = ModelLoader.loadSystem(systemPath.toString()); - ResourceEnvironment persistedResourceEnvironment = ModelLoader + final Repository persistedRepository = ModelLoader.loadRepository(repositoryPath.toString()); + final org.palladiosimulator.pcm.system.System persistedSystem = ModelLoader.loadSystem(systemPath.toString()); + final ResourceEnvironment persistedResourceEnvironment = ModelLoader .loadResourceEnvironment(resourceEnvironmentPath.toString()); - Allocation persistedAllocation = ModelLoader.loadAllocation(allocationPath.toString()); + final Allocation persistedAllocation = ModelLoader.loadAllocation(allocationPath.toString()); // Check loaded repository validity assertEquals(3, persistedRepository.getComponents__Repository() @@ -376,13 +382,13 @@ public void persistModels() throws Exception { .size()); persistedRepository.getInterfaces__Repository() .forEach(interFace -> { - OperationInterface operationInterface = (OperationInterface) interFace; + final OperationInterface operationInterface = (OperationInterface) interFace; assertFalse(operationInterface.getSignatures__OperationInterface() .isEmpty()); }); persistedRepository.getComponents__Repository() .forEach(component -> { - BasicComponent basicComponent = (BasicComponent) component; + final BasicComponent basicComponent = (BasicComponent) component; assertFalse(basicComponent.getServiceEffectSpecifications__BasicComponent() .isEmpty()); assertFalse(basicComponent.getProvidedRoles_InterfaceProvidingEntity() @@ -399,7 +405,7 @@ public void persistModels() throws Exception { // correctly persistedSystem.getAssemblyContexts__ComposedStructure() .forEach(assemblyContext -> { - BasicComponent basicComponent = (BasicComponent) assemblyContext + final BasicComponent basicComponent = (BasicComponent) assemblyContext .getEncapsulatedComponent__AssemblyContext(); assertFalse(basicComponent.getServiceEffectSpecifications__BasicComponent() .isEmpty()); @@ -425,7 +431,7 @@ public void persistModels() throws Exception { // resolved correctly persistedAllocation.getAllocationContexts_Allocation() .forEach(allocationContext -> { - BasicComponent basicComponent = (BasicComponent) allocationContext + final BasicComponent basicComponent = (BasicComponent) allocationContext .getAssemblyContext_AllocationContext() .getEncapsulatedComponent__AssemblyContext(); assertFalse(basicComponent.getServiceEffectSpecifications__BasicComponent() @@ -439,10 +445,10 @@ protected Blackboard getBlackboard() { return this.blackboard; } - private Map parseCasestudyPackage(Path directory) { - ASTParser parser = getASTParser(); - String[] classpathEntries = getEntries(directory, ".jar"); - final String[] sources = getEntries(directory, ".java"); + private Map parseCasestudyPackage(final Path directory) { + final ASTParser parser = this.getASTParser(); + final String[] classpathEntries = this.getEntries(directory, ".jar"); + final String[] sources = this.getEntries(directory, ".java"); final String[] encodings = new String[sources.length]; Arrays.fill(encodings, StandardCharsets.UTF_8.toString()); final Map compilationUnits = new HashMap<>(); @@ -461,7 +467,7 @@ public void acceptAST(final String sourceFilePath, final CompilationUnit ast) { } private ASTParser getASTParser() { - String javaCoreVersion = JavaCore.latestSupportedJavaVersion(); + final String javaCoreVersion = JavaCore.latestSupportedJavaVersion(); final ASTParser parser = ASTParser.newParser(AST.getJLSLatest()); parser.setResolveBindings(true); parser.setBindingsRecovery(true); @@ -471,7 +477,7 @@ private ASTParser getASTParser() { return parser; } - private String[] getEntries(Path directory, String suffix) { + private String[] getEntries(final Path directory, final String suffix) { try (Stream paths = Files.walk(directory)) { return paths.filter(path -> Files.isRegularFile(path) && path.getFileName() .toString() diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/Entity.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/Entity.java index 1b78acc6..94ea3bfd 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/Entity.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/Entity.java @@ -3,11 +3,11 @@ public class Entity { private final String identifier; - public Entity(String identifier) { + public Entity(final String identifier) { this.identifier = identifier; } public String getIdentifier() { - return identifier; + return this.identifier; } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityRepository.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityRepository.java index 2d854f71..a23fbfa4 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityRepository.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityRepository.java @@ -3,11 +3,11 @@ public class EntityRepository { private static int identifierCounter = Integer.MIN_VALUE; - public Entity findByIdentifier(String identifier) { + public Entity findByIdentifier(final String identifier) { return new Entity(identifier); } - public Entity persist(Entity entity) { + public Entity persist(final Entity entity) { if (entity.getIdentifier() == null) { return new Entity(String.valueOf(identifierCounter++)); } else { @@ -15,7 +15,7 @@ public Entity persist(Entity entity) { } } - public boolean remove(Entity entity) { + public boolean remove(final Entity entity) { return true; } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityService.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityService.java index 8afb1155..aa004a43 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityService.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityService.java @@ -3,19 +3,19 @@ public class EntityService { private final EntityRepository entityRepository; - public EntityService(EntityRepository entityRepository) { + public EntityService(final EntityRepository entityRepository) { this.entityRepository = entityRepository; } - public Entity get(String identifier) { + public Entity get(final String identifier) { return this.entityRepository.findByIdentifier(identifier); } - public Entity save(Entity entity) { + public Entity save(final Entity entity) { return this.entityRepository.persist(entity); } - public void delete(Entity entity) { + public void delete(final Entity entity) { this.entityRepository.remove(entity); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/utility/MethodDeclarationVisitor.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/utility/MethodDeclarationVisitor.java index a1743904..b66febab 100644 --- a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/utility/MethodDeclarationVisitor.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/utility/MethodDeclarationVisitor.java @@ -11,19 +11,19 @@ public final class MethodDeclarationVisitor extends ASTVisitor { private final List declarations = new ArrayList<>(); - public static List perform(ASTNode node) { - MethodDeclarationVisitor visitor = new MethodDeclarationVisitor(); + public static List perform(final ASTNode node) { + final MethodDeclarationVisitor visitor = new MethodDeclarationVisitor(); node.accept(visitor); return visitor.getMethods(); } @Override public boolean visit(final MethodDeclaration method) { - declarations.add(method); + this.declarations.add(method); return super.visit(method); } public List getMethods() { - return Collections.unmodifiableList(declarations); + return Collections.unmodifiableList(this.declarations); } }