blob: 8ca1596fc22c53d79fc07cb560a248f6ef2e38d2 [file] [log] [blame]
/**
* Copyright (c) 2018 CEA
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Jérémie Tatibouet (CEA) jeremie.tatibouet@cea.fr - Initial API and implementation
* Benoit Maggi (CEA) benoit.maggi@cea.fr - Initial API and implementation
* Shuai Li (CEA) shuai.li@cea.fr - Integration of sensiNact and Web of Things Thing Description
*
*/
package org.eclipse.papyrus.iotml.wot.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.papyrus.iotml.wot.ActionAffordance;
import org.eclipse.papyrus.iotml.wot.DataSchema;
import org.eclipse.papyrus.iotml.wot.WoTPackage;
import org.eclipse.uml2.uml.BehavioralFeature;
import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Parameter;
import org.eclipse.uml2.uml.util.UMLUtil;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Action Affordance</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.ActionAffordanceImpl#getBase_Operation <em>Base Operation</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.ActionAffordanceImpl#getInput <em>Input</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.ActionAffordanceImpl#getOutput <em>Output</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.ActionAffordanceImpl#isSafe <em>Safe</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.ActionAffordanceImpl#isIdempotent <em>Idempotent</em>}</li>
* </ul>
*
* @generated
*/
@JsonPropertyOrder({"@type", "title", "description", "input", "output", "safe", "idempotent"})
public class ActionAffordanceImpl extends InteractionAffordanceImpl implements ActionAffordance {
/**
* The cached value of the '{@link #getBase_Operation() <em>Base Operation</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBase_Operation()
* @generated
* @ordered
*/
protected Operation base_Operation;
/**
* The default value of the '{@link #isSafe() <em>Safe</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isSafe()
* @generated
* @ordered
*/
protected static final boolean SAFE_EDEFAULT = false;
/**
* The cached value of the '{@link #isSafe() <em>Safe</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isSafe()
* @generated
* @ordered
*/
protected boolean safe = SAFE_EDEFAULT;
/**
* The default value of the '{@link #isIdempotent() <em>Idempotent</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIdempotent()
* @generated
* @ordered
*/
protected static final boolean IDEMPOTENT_EDEFAULT = false;
/**
* The cached value of the '{@link #isIdempotent() <em>Idempotent</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIdempotent()
* @generated
* @ordered
*/
protected boolean idempotent = IDEMPOTENT_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ActionAffordanceImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return WoTPackage.Literals.ACTION_AFFORDANCE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("input")
public DataSchema getInput() {
DataSchema input = basicGetInput();
return input != null && input.eIsProxy() ? (DataSchema)eResolveProxy((InternalEObject)input) : input;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public DataSchema basicGetInput() {
BehavioralFeature behaviorFeature = this.getBase_Operation();
if (behaviorFeature != null) {
for (Parameter inputParameter : behaviorFeature.inputParameters()) {
DataSchema dataSchema = UMLUtil.getStereotypeApplication(inputParameter, DataSchema.class);
if (dataSchema != null) {
return dataSchema;
}
}
}
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setInput(DataSchema newInput) {
// TODO: implement this method to set the 'Input' reference
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("output")
public DataSchema getOutput() {
DataSchema output = basicGetOutput();
return output != null && output.eIsProxy() ? (DataSchema)eResolveProxy((InternalEObject)output) : output;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public DataSchema basicGetOutput() {
BehavioralFeature behaviorFeature = this.getBase_Operation();
if (behaviorFeature != null) {
for (Parameter inputParameter : behaviorFeature.inputParameters()) {
DataSchema dataSchema = UMLUtil.getStereotypeApplication(inputParameter, DataSchema.class);
if (dataSchema != null) {
return dataSchema;
}
}
}
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setOutput(DataSchema newOutput) {
// TODO: implement this method to set the 'Output' reference
// Ensure that you remove @generated or mark it @generated NOT
throw new UnsupportedOperationException();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("safe")
public boolean isSafe() {
return safe;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setSafe(boolean newSafe) {
boolean oldSafe = safe;
safe = newSafe;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.ACTION_AFFORDANCE__SAFE, oldSafe, safe));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("idempotent")
public boolean isIdempotent() {
return idempotent;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setIdempotent(boolean newIdempotent) {
boolean oldIdempotent = idempotent;
idempotent = newIdempotent;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.ACTION_AFFORDANCE__IDEMPOTENT, oldIdempotent, idempotent));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public Operation getBase_Operation() {
if (base_Operation != null && base_Operation.eIsProxy()) {
InternalEObject oldBase_Operation = (InternalEObject)base_Operation;
base_Operation = (Operation)eResolveProxy(oldBase_Operation);
if (base_Operation != oldBase_Operation) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, WoTPackage.ACTION_AFFORDANCE__BASE_OPERATION, oldBase_Operation, base_Operation));
}
}
return base_Operation;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Operation basicGetBase_Operation() {
return base_Operation;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setBase_Operation(Operation newBase_Operation) {
Operation oldBase_Operation = base_Operation;
base_Operation = newBase_Operation;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.ACTION_AFFORDANCE__BASE_OPERATION, oldBase_Operation, base_Operation));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case WoTPackage.ACTION_AFFORDANCE__BASE_OPERATION:
if (resolve) return getBase_Operation();
return basicGetBase_Operation();
case WoTPackage.ACTION_AFFORDANCE__INPUT:
if (resolve) return getInput();
return basicGetInput();
case WoTPackage.ACTION_AFFORDANCE__OUTPUT:
if (resolve) return getOutput();
return basicGetOutput();
case WoTPackage.ACTION_AFFORDANCE__SAFE:
return isSafe();
case WoTPackage.ACTION_AFFORDANCE__IDEMPOTENT:
return isIdempotent();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case WoTPackage.ACTION_AFFORDANCE__BASE_OPERATION:
setBase_Operation((Operation)newValue);
return;
case WoTPackage.ACTION_AFFORDANCE__INPUT:
setInput((DataSchema)newValue);
return;
case WoTPackage.ACTION_AFFORDANCE__OUTPUT:
setOutput((DataSchema)newValue);
return;
case WoTPackage.ACTION_AFFORDANCE__SAFE:
setSafe((Boolean)newValue);
return;
case WoTPackage.ACTION_AFFORDANCE__IDEMPOTENT:
setIdempotent((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case WoTPackage.ACTION_AFFORDANCE__BASE_OPERATION:
setBase_Operation((Operation)null);
return;
case WoTPackage.ACTION_AFFORDANCE__INPUT:
setInput((DataSchema)null);
return;
case WoTPackage.ACTION_AFFORDANCE__OUTPUT:
setOutput((DataSchema)null);
return;
case WoTPackage.ACTION_AFFORDANCE__SAFE:
setSafe(SAFE_EDEFAULT);
return;
case WoTPackage.ACTION_AFFORDANCE__IDEMPOTENT:
setIdempotent(IDEMPOTENT_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case WoTPackage.ACTION_AFFORDANCE__BASE_OPERATION:
return base_Operation != null;
case WoTPackage.ACTION_AFFORDANCE__INPUT:
return basicGetInput() != null;
case WoTPackage.ACTION_AFFORDANCE__OUTPUT:
return basicGetOutput() != null;
case WoTPackage.ACTION_AFFORDANCE__SAFE:
return safe != SAFE_EDEFAULT;
case WoTPackage.ACTION_AFFORDANCE__IDEMPOTENT:
return idempotent != IDEMPOTENT_EDEFAULT;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (safe: ");
result.append(safe);
result.append(", idempotent: ");
result.append(idempotent);
result.append(')');
return result.toString();
}
} //ActionAffordanceImpl