Skip to content

Commit

Permalink
Extend Relationship Types to specify configure interface
Browse files Browse the repository at this point in the history
This change introduces the possibility in order to define "Interfaces"
(in addition to Source and Target Interfaces) on Relationship Types.
The new Interface is basically the implementation according to the new
YAML specification. Here, one has the possibility to define a
"Configure" interface with a couple of predefined operations (see spec
for details).

Signed-off-by: Michael Wurster <miwurster@googlemail.com>
  • Loading branch information
miwurster authored and lharzenetter committed Aug 31, 2018
1 parent 4691235 commit d120081
Show file tree
Hide file tree
Showing 21 changed files with 443 additions and 277 deletions.
@@ -0,0 +1,57 @@
/*******************************************************************************
* Copyright (c) 2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/

package org.eclipse.winery.model.tosca;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

import org.eclipse.jdt.annotation.NonNull;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"_interface"
})
public class TInterfaces {

@XmlElement(name = "Interface", required = true)
protected List<TInterface> _interface;

@NonNull
public List<TInterface> getInterface() {
if (_interface == null) {
_interface = new ArrayList<TInterface>();
}
return this._interface;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TInterfaces that = (TInterfaces) o;
return Objects.equals(_interface, that._interface);
}

@Override
public int hashCode() {
return Objects.hash(_interface);
}
}
Expand Up @@ -43,7 +43,7 @@ public class TNodeType extends TEntityType {
@XmlElement(name = "InstanceStates")
protected TTopologyElementInstanceStates instanceStates;
@XmlElement(name = "Interfaces")
protected TNodeType.Interfaces interfaces;
protected TInterfaces interfaces;

public TNodeType() {
}
Expand Down Expand Up @@ -98,11 +98,11 @@ public void setInstanceStates(@Nullable TTopologyElementInstanceStates value) {
this.instanceStates = value;
}

public TNodeType.@Nullable Interfaces getInterfaces() {
public @Nullable TInterfaces getInterfaces() {
return interfaces;
}

public void setInterfaces(TNodeType.@Nullable Interfaces value) {
public void setInterfaces(@Nullable TInterfaces value) {
this.interfaces = value;
}

Expand Down Expand Up @@ -142,56 +142,6 @@ public int hashCode() {
}
}


/**
* <p>Java class for anonymous complex type.
* <p>
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="Interface" type="{http://docs.oasis-open.org/tosca/ns/2011/12}tInterface"
* maxOccurs="unbounded"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"_interface"
})
public static class Interfaces {

@XmlElement(name = "Interface", required = true)
protected List<TInterface> _interface;

@NonNull
public List<TInterface> getInterface() {
if (_interface == null) {
_interface = new ArrayList<TInterface>();
}
return this._interface;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Interfaces that = (Interfaces) o;
return Objects.equals(_interface, that._interface);
}

@Override
public int hashCode() {
return Objects.hash(_interface);
}
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"requirementDefinition"
Expand Down Expand Up @@ -227,7 +177,7 @@ public static class Builder extends TEntityType.Builder<Builder> {
private RequirementDefinitions requirementDefinitions;
private CapabilityDefinitions capabilityDefinitions;
private TTopologyElementInstanceStates instanceStates;
private Interfaces interfaces;
private TInterfaces interfaces;

public Builder(String name) {
super(name);
Expand All @@ -252,7 +202,7 @@ public Builder setInstanceStates(TTopologyElementInstanceStates instanceStates)
return this;
}

public Builder setInterfaces(TNodeType.Interfaces interfaces) {
public Builder setInterfaces(TInterfaces interfaces) {
this.interfaces = interfaces;
return this;
}
Expand Down Expand Up @@ -323,7 +273,7 @@ public Builder addCapabilityDefinitions(TCapabilityDefinition capabilityDefiniti
return addCapabilityDefinitions(tmp);
}

public Builder addInterfaces(TNodeType.Interfaces interfaces) {
public Builder addInterfaces(TInterfaces interfaces) {
if (interfaces == null || interfaces.getInterface().isEmpty()) {
return this;
}
Expand All @@ -341,7 +291,7 @@ public Builder addInterfaces(List<TInterface> interfaces) {
return this;
}

TNodeType.Interfaces tmp = new TNodeType.Interfaces();
TInterfaces tmp = new TInterfaces();
tmp.getInterface().addAll(interfaces);
return addInterfaces(tmp);
}
Expand All @@ -351,7 +301,7 @@ public Builder addInterfaces(TInterface interfaces) {
return this;
}

TNodeType.Interfaces tmp = new TNodeType.Interfaces();
TInterfaces tmp = new TInterfaces();
tmp.getInterface().add(interfaces);
return addInterfaces(tmp);
}
Expand Down

0 comments on commit d120081

Please sign in to comment.