blob: d0cd3cb51c6f9ad34a8788b4ae458d3f5dabb911 [file] [log] [blame]
/*
* Copyright (c) 2014, 2015, 2018 Eike Stepper (Loehne, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.oomph.workingsets.impl;
import org.eclipse.oomph.base.impl.ModelElementImpl;
import org.eclipse.oomph.predicates.Predicate;
import org.eclipse.oomph.workingsets.WorkingSet;
import org.eclipse.oomph.workingsets.WorkingSetsPackage;
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.core.resources.IResource;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Working Set</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.oomph.workingsets.impl.WorkingSetImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.oomph.workingsets.impl.WorkingSetImpl#getPredicates <em>Predicates</em>}</li>
* <li>{@link org.eclipse.oomph.workingsets.impl.WorkingSetImpl#getID <em>ID</em>}</li>
* </ul>
*
* @generated
*/
public class WorkingSetImpl extends ModelElementImpl implements WorkingSet
{
/**
* 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 cached value of the '{@link #getPredicates() <em>Predicates</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPredicates()
* @generated
* @ordered
*/
protected EList<Predicate> predicates;
/**
* 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;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected WorkingSetImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return WorkingSetsPackage.Literals.WORKING_SET;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Predicate> getPredicates()
{
if (predicates == null)
{
predicates = new EObjectContainmentEList<Predicate>(Predicate.class, this, WorkingSetsPackage.WORKING_SET__PREDICATES);
}
return predicates;
}
/**
* <!-- 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, WorkingSetsPackage.WORKING_SET__ID, oldID, iD));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public boolean matches(IResource resource)
{
for (Predicate predicate : getPredicates())
{
if (predicate.matches(resource))
{
return true;
}
}
return false;
}
/**
* <!-- 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, WorkingSetsPackage.WORKING_SET__NAME, oldName, name));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case WorkingSetsPackage.WORKING_SET__PREDICATES:
return ((InternalEList<?>)getPredicates()).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 WorkingSetsPackage.WORKING_SET__NAME:
return getName();
case WorkingSetsPackage.WORKING_SET__PREDICATES:
return getPredicates();
case WorkingSetsPackage.WORKING_SET__ID:
return getID();
}
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 WorkingSetsPackage.WORKING_SET__NAME:
setName((String)newValue);
return;
case WorkingSetsPackage.WORKING_SET__PREDICATES:
getPredicates().clear();
getPredicates().addAll((Collection<? extends Predicate>)newValue);
return;
case WorkingSetsPackage.WORKING_SET__ID:
setID((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case WorkingSetsPackage.WORKING_SET__NAME:
setName(NAME_EDEFAULT);
return;
case WorkingSetsPackage.WORKING_SET__PREDICATES:
getPredicates().clear();
return;
case WorkingSetsPackage.WORKING_SET__ID:
setID(ID_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case WorkingSetsPackage.WORKING_SET__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case WorkingSetsPackage.WORKING_SET__PREDICATES:
return predicates != null && !predicates.isEmpty();
case WorkingSetsPackage.WORKING_SET__ID:
return ID_EDEFAULT == null ? iD != null : !ID_EDEFAULT.equals(iD);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException
{
switch (operationID)
{
case WorkingSetsPackage.WORKING_SET___MATCHES__IRESOURCE:
return matches((IResource)arguments.get(0));
}
return super.eInvoke(operationID, arguments);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString()
{
if (eIsProxy())
{
return super.toString();
}
StringBuilder result = new StringBuilder(super.toString());
result.append(" (name: "); //$NON-NLS-1$
result.append(name);
result.append(", iD: "); //$NON-NLS-1$
result.append(iD);
result.append(')');
return result.toString();
}
} // WorkingSetImpl