| /******************************************************************************* |
| * Copyright (c) 2014 Xored Software Inc 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: |
| * Xored Software Inc - initial API and implementation and/or initial documentation |
| *******************************************************************************/ |
| |
| package org.eclipse.rcptt.preferences.impl; |
| |
| import java.util.Collection; |
| |
| 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.impl.ENotificationImpl; |
| import org.eclipse.emf.ecore.impl.EObjectImpl; |
| |
| import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; |
| |
| import org.eclipse.rcptt.preferences.ListPrefData; |
| import org.eclipse.rcptt.preferences.PreferencesPackage; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>List Pref Data</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.rcptt.preferences.impl.ListPrefDataImpl#getKey <em>Key</em>}</li> |
| * <li>{@link org.eclipse.rcptt.preferences.impl.ListPrefDataImpl#getValues <em>Values</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class ListPrefDataImpl extends EObjectImpl implements ListPrefData { |
| /** |
| * The default value of the '{@link #getKey() <em>Key</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getKey() |
| * @generated |
| * @ordered |
| */ |
| protected static final String KEY_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getKey() <em>Key</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getKey() |
| * @generated |
| * @ordered |
| */ |
| protected String key = KEY_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getValues() <em>Values</em>}' attribute list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValues() |
| * @generated |
| * @ordered |
| */ |
| protected EList<String> values; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ListPrefDataImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return PreferencesPackage.Literals.LIST_PREF_DATA; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getKey() { |
| return key; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setKey(String newKey) { |
| String oldKey = key; |
| key = newKey; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, PreferencesPackage.LIST_PREF_DATA__KEY, oldKey, key)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<String> getValues() { |
| if (values == null) { |
| values = new EDataTypeUniqueEList<String>(String.class, this, PreferencesPackage.LIST_PREF_DATA__VALUES); |
| } |
| return values; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case PreferencesPackage.LIST_PREF_DATA__KEY: |
| return getKey(); |
| case PreferencesPackage.LIST_PREF_DATA__VALUES: |
| return getValues(); |
| } |
| 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 PreferencesPackage.LIST_PREF_DATA__KEY: |
| setKey((String)newValue); |
| return; |
| case PreferencesPackage.LIST_PREF_DATA__VALUES: |
| getValues().clear(); |
| getValues().addAll((Collection<? extends String>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case PreferencesPackage.LIST_PREF_DATA__KEY: |
| setKey(KEY_EDEFAULT); |
| return; |
| case PreferencesPackage.LIST_PREF_DATA__VALUES: |
| getValues().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case PreferencesPackage.LIST_PREF_DATA__KEY: |
| return KEY_EDEFAULT == null ? key != null : !KEY_EDEFAULT.equals(key); |
| case PreferencesPackage.LIST_PREF_DATA__VALUES: |
| return values != null && !values.isEmpty(); |
| } |
| 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(" (key: "); |
| result.append(key); |
| result.append(", values: "); |
| result.append(values); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //ListPrefDataImpl |