blob: dcbc1ebbba6fdd2df058ac23aecbe8de6aa99c7d [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 java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.UniqueEList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.papyrus.iotml.wot.Form;
import org.eclipse.papyrus.iotml.wot.OpKind;
import org.eclipse.papyrus.iotml.wot.SecurityScheme;
import org.eclipse.papyrus.iotml.wot.SubProtocolKind;
import org.eclipse.papyrus.iotml.wot.WoTPackage;
import org.eclipse.uml2.uml.Comment;
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>Form</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getOp <em>Op</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getHref <em>Href</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getContentType <em>Content Type</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getContentCoding <em>Content Coding</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getSubProtocol <em>Sub Protocol</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getScopes <em>Scopes</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getResponse <em>Response</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getSecurity <em>Security</em>}</li>
* <li>{@link org.eclipse.papyrus.iotml.wot.impl.FormImpl#getBase_Comment <em>Base Comment</em>}</li>
* </ul>
*
* @generated
*/
@JsonPropertyOrder({"op", "href", "contentType", "contentCoding", "subProtocol", "security", "scopes", "response"})
public class FormImpl extends MinimalEObjectImpl.Container implements Form {
/**
* The cached value of the '{@link #getOp() <em>Op</em>}' attribute list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOp()
* @generated
* @ordered
*/
protected EList<OpKind> op;
/**
* The default value of the '{@link #getHref() <em>Href</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHref()
* @generated
* @ordered
*/
protected static final String HREF_EDEFAULT = null;
/**
* The cached value of the '{@link #getHref() <em>Href</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHref()
* @generated
* @ordered
*/
protected String href = HREF_EDEFAULT;
/**
* The default value of the '{@link #getContentType() <em>Content Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContentType()
* @generated
* @ordered
*/
protected static final String CONTENT_TYPE_EDEFAULT = "application/json";
/**
* The cached value of the '{@link #getContentType() <em>Content Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContentType()
* @generated
* @ordered
*/
protected String contentType = CONTENT_TYPE_EDEFAULT;
/**
* The default value of the '{@link #getContentCoding() <em>Content Coding</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContentCoding()
* @generated
* @ordered
*/
protected static final String CONTENT_CODING_EDEFAULT = null;
/**
* The cached value of the '{@link #getContentCoding() <em>Content Coding</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getContentCoding()
* @generated
* @ordered
*/
protected String contentCoding = CONTENT_CODING_EDEFAULT;
/**
* The default value of the '{@link #getSubProtocol() <em>Sub Protocol</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSubProtocol()
* @generated
* @ordered
*/
protected static final SubProtocolKind SUB_PROTOCOL_EDEFAULT = SubProtocolKind.NONE;
/**
* The cached value of the '{@link #getSubProtocol() <em>Sub Protocol</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSubProtocol()
* @generated
* @ordered
*/
protected SubProtocolKind subProtocol = SUB_PROTOCOL_EDEFAULT;
/**
* The cached value of the '{@link #getScopes() <em>Scopes</em>}' attribute list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getScopes()
* @generated
* @ordered
*/
protected EList<String> scopes;
/**
* The default value of the '{@link #getResponse() <em>Response</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getResponse()
* @generated
* @ordered
*/
protected static final String RESPONSE_EDEFAULT = "application/json";
/**
* The cached value of the '{@link #getResponse() <em>Response</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getResponse()
* @generated
* @ordered
*/
protected String response = RESPONSE_EDEFAULT;
/**
* The cached value of the '{@link #getSecurity() <em>Security</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSecurity()
* @generated
* @ordered
*/
protected EList<SecurityScheme> security;
/**
* The cached value of the '{@link #getBase_Comment() <em>Base Comment</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBase_Comment()
* @generated
* @ordered
*/
protected Comment base_Comment;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected FormImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return WoTPackage.Literals.FORM;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("op")
public EList<OpKind> getOp() {
if (op == null) {
op = new EDataTypeUniqueEList<OpKind>(OpKind.class, this, WoTPackage.FORM__OP);
}
return op;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("op")
public String getHref() {
return href;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setHref(String newHref) {
String oldHref = href;
href = newHref;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.FORM__HREF, oldHref, href));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("contentType")
public String getContentType() {
return contentType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setContentType(String newContentType) {
String oldContentType = contentType;
contentType = newContentType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.FORM__CONTENT_TYPE, oldContentType, contentType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("contentCoding")
public String getContentCoding() {
return contentCoding;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setContentCoding(String newContentCoding) {
String oldContentCoding = contentCoding;
contentCoding = newContentCoding;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.FORM__CONTENT_CODING, oldContentCoding, contentCoding));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("subProtocol")
public SubProtocolKind getSubProtocol() {
return subProtocol;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setSubProtocol(SubProtocolKind newSubProtocol) {
SubProtocolKind oldSubProtocol = subProtocol;
subProtocol = newSubProtocol == null ? SUB_PROTOCOL_EDEFAULT : newSubProtocol;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.FORM__SUB_PROTOCOL, oldSubProtocol, subProtocol));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("scopes")
public EList<String> getScopes() {
if (scopes == null) {
scopes = new EDataTypeUniqueEList<String>(String.class, this, WoTPackage.FORM__SCOPES);
}
return scopes;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonGetter("response")
public String getResponse() {
return response;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setResponse(String newResponse) {
String oldResponse = response;
response = newResponse;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.FORM__RESPONSE, oldResponse, response));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public EList<SecurityScheme> getSecurity() {
if (security == null) {
security = new EObjectResolvingEList<SecurityScheme>(SecurityScheme.class, this, WoTPackage.FORM__SECURITY);
}
return security;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public Comment getBase_Comment() {
if (base_Comment != null && base_Comment.eIsProxy()) {
InternalEObject oldBase_Comment = (InternalEObject)base_Comment;
base_Comment = (Comment)eResolveProxy(oldBase_Comment);
if (base_Comment != oldBase_Comment) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, WoTPackage.FORM__BASE_COMMENT, oldBase_Comment, base_Comment));
}
}
return base_Comment;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Comment basicGetBase_Comment() {
return base_Comment;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@JsonIgnore
public void setBase_Comment(Comment newBase_Comment) {
Comment oldBase_Comment = base_Comment;
base_Comment = newBase_Comment;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WoTPackage.FORM__BASE_COMMENT, oldBase_Comment, base_Comment));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case WoTPackage.FORM__OP:
return getOp();
case WoTPackage.FORM__HREF:
return getHref();
case WoTPackage.FORM__CONTENT_TYPE:
return getContentType();
case WoTPackage.FORM__CONTENT_CODING:
return getContentCoding();
case WoTPackage.FORM__SUB_PROTOCOL:
return getSubProtocol();
case WoTPackage.FORM__SCOPES:
return getScopes();
case WoTPackage.FORM__RESPONSE:
return getResponse();
case WoTPackage.FORM__SECURITY:
return getSecurity();
case WoTPackage.FORM__BASE_COMMENT:
if (resolve) return getBase_Comment();
return basicGetBase_Comment();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case WoTPackage.FORM__OP:
getOp().clear();
getOp().addAll((Collection<? extends OpKind>)newValue);
return;
case WoTPackage.FORM__HREF:
setHref((String)newValue);
return;
case WoTPackage.FORM__CONTENT_TYPE:
setContentType((String)newValue);
return;
case WoTPackage.FORM__CONTENT_CODING:
setContentCoding((String)newValue);
return;
case WoTPackage.FORM__SUB_PROTOCOL:
setSubProtocol((SubProtocolKind)newValue);
return;
case WoTPackage.FORM__SCOPES:
getScopes().clear();
getScopes().addAll((Collection<? extends String>)newValue);
return;
case WoTPackage.FORM__RESPONSE:
setResponse((String)newValue);
return;
case WoTPackage.FORM__SECURITY:
getSecurity().clear();
getSecurity().addAll((Collection<? extends SecurityScheme>)newValue);
return;
case WoTPackage.FORM__BASE_COMMENT:
setBase_Comment((Comment)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case WoTPackage.FORM__OP:
getOp().clear();
return;
case WoTPackage.FORM__HREF:
setHref(HREF_EDEFAULT);
return;
case WoTPackage.FORM__CONTENT_TYPE:
setContentType(CONTENT_TYPE_EDEFAULT);
return;
case WoTPackage.FORM__CONTENT_CODING:
setContentCoding(CONTENT_CODING_EDEFAULT);
return;
case WoTPackage.FORM__SUB_PROTOCOL:
setSubProtocol(SUB_PROTOCOL_EDEFAULT);
return;
case WoTPackage.FORM__SCOPES:
getScopes().clear();
return;
case WoTPackage.FORM__RESPONSE:
setResponse(RESPONSE_EDEFAULT);
return;
case WoTPackage.FORM__SECURITY:
getSecurity().clear();
return;
case WoTPackage.FORM__BASE_COMMENT:
setBase_Comment((Comment)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case WoTPackage.FORM__OP:
return op != null && !op.isEmpty();
case WoTPackage.FORM__HREF:
return HREF_EDEFAULT == null ? href != null : !HREF_EDEFAULT.equals(href);
case WoTPackage.FORM__CONTENT_TYPE:
return CONTENT_TYPE_EDEFAULT == null ? contentType != null : !CONTENT_TYPE_EDEFAULT.equals(contentType);
case WoTPackage.FORM__CONTENT_CODING:
return CONTENT_CODING_EDEFAULT == null ? contentCoding != null : !CONTENT_CODING_EDEFAULT.equals(contentCoding);
case WoTPackage.FORM__SUB_PROTOCOL:
return subProtocol != SUB_PROTOCOL_EDEFAULT;
case WoTPackage.FORM__SCOPES:
return scopes != null && !scopes.isEmpty();
case WoTPackage.FORM__RESPONSE:
return RESPONSE_EDEFAULT == null ? response != null : !RESPONSE_EDEFAULT.equals(response);
case WoTPackage.FORM__SECURITY:
return security != null && !security.isEmpty();
case WoTPackage.FORM__BASE_COMMENT:
return base_Comment != null;
}
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(" (op: ");
result.append(op);
result.append(", href: ");
result.append(href);
result.append(", contentType: ");
result.append(contentType);
result.append(", contentCoding: ");
result.append(contentCoding);
result.append(", subProtocol: ");
result.append(subProtocol);
result.append(", scopes: ");
result.append(scopes);
result.append(", response: ");
result.append(response);
result.append(')');
return result.toString();
}
/**
* Security attribute getter for JSON serialization
* @generated NOT
*/
@JsonGetter("security")
public EList<String> getSecurityAsString() {
EList<String> securityAsString = new UniqueEList<String>();
if (security == null) {
security = new EObjectResolvingEList<SecurityScheme>(SecurityScheme.class, this, WoTPackage.THING__SECURITY);
}
for (SecurityScheme securityScheme : security) {
if (securityScheme.getTitle() != null && !securityScheme.getTitle().isEmpty()) {
securityAsString.add(securityScheme.getTitle());
}
}
return securityAsString;
}
} //FormImpl