/**
*/
package ftp.impl;
import ftp.Component;
import ftp.FtpPackage;
import ftp.Port;
import ftp.TypedPortValue;
import java.util.List;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Component</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link ftp.impl.ComponentImpl#getName <em>Name</em>}</li>
* <li>{@link ftp.impl.ComponentImpl#getType <em>Type</em>}</li>
* </ul>
*
* @generated
*/
public class ComponentImpl extends CompositionElementImpl implements Component {
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The default value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected static final String TYPE_EDEFAULT = null;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected String type = TYPE_EDEFAULT;
public String safeFunctor;
public List<Predicate> logic = null;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ComponentImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return FtpPackage.Literals.COMPONENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName() {
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName) {
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, FtpPackage.COMPONENT__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getType() {
return type;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public void setType(String newType) {
String oldType = type;
type = newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, FtpPackage.COMPONENT__TYPE, oldType, type));
safeFunctor = safe_functor(type);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case FtpPackage.COMPONENT__NAME:
return getName();
case FtpPackage.COMPONENT__TYPE:
return getType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case FtpPackage.COMPONENT__NAME:
setName((String)newValue);
return;
case FtpPackage.COMPONENT__TYPE:
setType((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case FtpPackage.COMPONENT__NAME:
setName(NAME_EDEFAULT);
return;
case FtpPackage.COMPONENT__TYPE:
setType(TYPE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case FtpPackage.COMPONENT__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case FtpPackage.COMPONENT__TYPE:
return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (name: ");
result.append(name);
result.append(", type: ");
result.append(type);
result.append(')');
return result.toString();
}
@Override
public List<Port> retrievePorts() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<TypedPortValue> retrieveParams() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<Predicate> translateToLogic() {
// TODO Auto-generated method stub
return null;
}
private String safe_functor(String type) {
String s1 = type.replace(' ', '_');
String s2 = s1.replace('-', '_');
if (Character.isDigit(s2.charAt(0)))
return "p" + s2;
else if (Character.isUpperCase(s2.charAt(0)))
return Character.toString(Character.toLowerCase(s2.charAt(0))) + s2.substring(1);
else
return type;
}
@Override
public String getSafeFunctor() {
return safeFunctor;
}
} //ComponentImpl