/******************************************************************************* * Copyright (c) 2001, 2006 IBM Corporation and others. * 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: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jst.j2ee.jca.internal.impl; import java.util.Collection; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; 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.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.jst.j2ee.common.Description; import org.eclipse.jst.j2ee.common.internal.impl.J2EEEObjectImpl; import org.eclipse.jst.j2ee.jca.JcaPackage; import org.eclipse.jst.j2ee.jca.License; /** * Specifies licensing requirements for the resource adapter module. Specifies whether a license is required to deploy and use this resource adapter, and an optional description of the licensing terms (examples: duration of license, number of connection restrictions). * @generated */ public class LicenseImpl extends J2EEEObjectImpl implements License { /** * The default value of the '{@link #getDescription() <em>Description</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDescription() * @generated * @ordered */ protected static final String DESCRIPTION_EDEFAULT = null; /** * @generated This field/method will be replaced during code generation. */ /** * @generated This field/method will be replaced during code generation. */ protected String description = DESCRIPTION_EDEFAULT; /** * The default value of the '{@link #isRequired() <em>Required</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isRequired() * @generated * @ordered */ protected static final boolean REQUIRED_EDEFAULT = false; /** * @generated This field/method will be replaced during code generation. */ protected boolean required = REQUIRED_EDEFAULT; /** * This is true if the Required attribute has been set. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ protected boolean requiredESet = false; /** * The cached value of the '{@link #getDescriptions() <em>Descriptions</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDescriptions() * @generated * @ordered */ protected EList descriptions = null; protected LicenseImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return JcaPackage.Literals.LICENSE; } /** * @generated This field/method will be replaced during code generation */ public String getDescription() { return description; } /** * @generated This field/method will be replaced during code generation. */ public void setDescription(String newDescription) { String oldDescription = description; description = newDescription; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, JcaPackage.LICENSE__DESCRIPTION, oldDescription, description)); } /** * @generated This field/method will be replaced during code generation */ public boolean isRequired() { return required; } /** * @generated This field/method will be replaced during code generation. */ public void setRequired(boolean newRequired) { boolean oldRequired = required; required = newRequired; boolean oldRequiredESet = requiredESet; requiredESet = true; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, JcaPackage.LICENSE__REQUIRED, oldRequired, required, !oldRequiredESet)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void unsetRequired() { boolean oldRequired = required; boolean oldRequiredESet = requiredESet; required = REQUIRED_EDEFAULT; requiredESet = false; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.UNSET, JcaPackage.LICENSE__REQUIRED, oldRequired, REQUIRED_EDEFAULT, oldRequiredESet)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean isSetRequired() { return requiredESet; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList getDescriptions() { if (descriptions == null) { descriptions = new EObjectContainmentEList(Description.class, this, JcaPackage.LICENSE__DESCRIPTIONS); } return descriptions; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case JcaPackage.LICENSE__DESCRIPTIONS: return ((InternalEList)getDescriptions()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case JcaPackage.LICENSE__DESCRIPTION: return getDescription(); case JcaPackage.LICENSE__REQUIRED: return isRequired() ? Boolean.TRUE : Boolean.FALSE; case JcaPackage.LICENSE__DESCRIPTIONS: return getDescriptions(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case JcaPackage.LICENSE__DESCRIPTION: setDescription((String)newValue); return; case JcaPackage.LICENSE__REQUIRED: setRequired(((Boolean)newValue).booleanValue()); return; case JcaPackage.LICENSE__DESCRIPTIONS: getDescriptions().clear(); getDescriptions().addAll((Collection)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case JcaPackage.LICENSE__DESCRIPTION: setDescription(DESCRIPTION_EDEFAULT); return; case JcaPackage.LICENSE__REQUIRED: unsetRequired(); return; case JcaPackage.LICENSE__DESCRIPTIONS: getDescriptions().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case JcaPackage.LICENSE__DESCRIPTION: return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description); case JcaPackage.LICENSE__REQUIRED: return isSetRequired(); case JcaPackage.LICENSE__DESCRIPTIONS: return descriptions != null && !descriptions.isEmpty(); } return super.eIsSet(featureID); } /** * @generated This field/method will be replaced during code generation. */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (description: "); //$NON-NLS-1$ result.append(description); result.append(", required: "); //$NON-NLS-1$ if (requiredESet) result.append(required); else result.append("<unset>"); //$NON-NLS-1$ result.append(')'); return result.toString(); } }