Package org.pdtextensions.semanticanalysis.model.validators.impl

Source Code of org.pdtextensions.semanticanalysis.model.validators.impl.ValidatorImpl

/**
*/
package org.pdtextensions.semanticanalysis.model.validators.impl;

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
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.EObjectResolvingEList;
import org.pdtextensions.semanticanalysis.PEXAnalysisPlugin;
import org.pdtextensions.semanticanalysis.model.validators.Category;
import org.pdtextensions.semanticanalysis.model.validators.Type;
import org.pdtextensions.semanticanalysis.model.validators.Validator;
import org.pdtextensions.semanticanalysis.model.validators.ValidatorsPackage;
import org.pdtextensions.semanticanalysis.validation.IValidatorFactory;

/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Validator</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
*   <li>{@link org.pdtextensions.semanticanalysis.model.validators.impl.ValidatorImpl#getId <em>Id</em>}</li>
*   <li>{@link org.pdtextensions.semanticanalysis.model.validators.impl.ValidatorImpl#getCategory <em>Category</em>}</li>
*   <li>{@link org.pdtextensions.semanticanalysis.model.validators.impl.ValidatorImpl#getTypes <em>Types</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ValidatorImpl extends MinimalEObjectImpl.Container implements Validator {
  /**
   * The default value of the '{@link #getId() <em>Id</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getId()
   * @generated
   * @ordered
   */
  protected static final String ID_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getId()
   * @generated
   * @ordered
   */
  protected String id = ID_EDEFAULT;

  /**
   * The cached value of the '{@link #getCategory() <em>Category</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getCategory()
   * @generated
   * @ordered
   */
  protected Category category;

  /**
   * The cached value of the '{@link #getTypes() <em>Types</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTypes()
   * @generated
   * @ordered
   */
  protected EList<Type> types;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ValidatorImpl() {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass() {
    return ValidatorsPackage.Literals.VALIDATOR;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getId() {
    return id;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setId(String newId) {
    String oldId = id;
    id = newId;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ValidatorsPackage.VALIDATOR__ID, oldId, id));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Category getCategory() {
    if (category != null && category.eIsProxy()) {
      InternalEObject oldCategory = (InternalEObject)category;
      category = (Category)eResolveProxy(oldCategory);
      if (category != oldCategory) {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, ValidatorsPackage.VALIDATOR__CATEGORY, oldCategory, category));
      }
    }
    return category;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Category basicGetCategory() {
    return category;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setCategory(Category newCategory) {
    Category oldCategory = category;
    category = newCategory;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ValidatorsPackage.VALIDATOR__CATEGORY, oldCategory, category));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Type> getTypes() {
    if (types == null) {
      types = new EObjectResolvingEList<Type>(Type.class, this, ValidatorsPackage.VALIDATOR__TYPES);
    }
    return types;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   */
  public Type getType(String id) {
    for (Type t : getTypes()) {
      if (t.getId().equals(id)) {
        return t;
      }
    }
   
    return null;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   */
  public IValidatorFactory getValidatorFactory() {
    try {
      return PEXAnalysisPlugin.getDefault().getValidatorManager().getValidatorFactory(this);
    } catch (CoreException e) {
      PEXAnalysisPlugin.error(e);
      return null;
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID) {
      case ValidatorsPackage.VALIDATOR__ID:
        return getId();
      case ValidatorsPackage.VALIDATOR__CATEGORY:
        if (resolve) return getCategory();
        return basicGetCategory();
      case ValidatorsPackage.VALIDATOR__TYPES:
        return getTypes();
    }
    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 ValidatorsPackage.VALIDATOR__ID:
        setId((String)newValue);
        return;
      case ValidatorsPackage.VALIDATOR__CATEGORY:
        setCategory((Category)newValue);
        return;
      case ValidatorsPackage.VALIDATOR__TYPES:
        getTypes().clear();
        getTypes().addAll((Collection<? extends Type>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID) {
    switch (featureID) {
      case ValidatorsPackage.VALIDATOR__ID:
        setId(ID_EDEFAULT);
        return;
      case ValidatorsPackage.VALIDATOR__CATEGORY:
        setCategory((Category)null);
        return;
      case ValidatorsPackage.VALIDATOR__TYPES:
        getTypes().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID) {
    switch (featureID) {
      case ValidatorsPackage.VALIDATOR__ID:
        return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
      case ValidatorsPackage.VALIDATOR__CATEGORY:
        return category != null;
      case ValidatorsPackage.VALIDATOR__TYPES:
        return types != null && !types.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
    switch (operationID) {
      case ValidatorsPackage.VALIDATOR___GET_TYPE__STRING:
        return getType((String)arguments.get(0));
      case ValidatorsPackage.VALIDATOR___GET_VALIDATOR_FACTORY:
        return getValidatorFactory();
    }
    return super.eInvoke(operationID, arguments);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString() {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (id: ");
    result.append(id);
    result.append(')');
    return result.toString();
  }

} //ValidatorImpl
TOP

Related Classes of org.pdtextensions.semanticanalysis.model.validators.impl.ValidatorImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.