org.nasdanika.html.model.bootstrap.impl.AppearanceImpl Maven / Gradle / Ivy
/**
*/
package org.nasdanika.html.model.bootstrap.impl;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.nasdanika.common.Util;
import org.nasdanika.html.bootstrap.Color;
import org.nasdanika.html.model.bootstrap.Appearance;
import org.nasdanika.html.model.bootstrap.BootstrapPackage;
import org.nasdanika.html.model.bootstrap.Border;
import org.nasdanika.html.model.bootstrap.Spacing;
import org.nasdanika.html.model.bootstrap.Text;
/**
*
* An implementation of the model object 'Appearance'.
*
*
* The following features are implemented:
*
*
* - {@link org.nasdanika.html.model.bootstrap.impl.AppearanceImpl#getBackground Background}
* - {@link org.nasdanika.html.model.bootstrap.impl.AppearanceImpl#getAttributes Attributes}
* - {@link org.nasdanika.html.model.bootstrap.impl.AppearanceImpl#getBorder Border}
* - {@link org.nasdanika.html.model.bootstrap.impl.AppearanceImpl#getMargin Margin}
* - {@link org.nasdanika.html.model.bootstrap.impl.AppearanceImpl#getPadding Padding}
* - {@link org.nasdanika.html.model.bootstrap.impl.AppearanceImpl#getText Text}
* - {@link org.nasdanika.html.model.bootstrap.impl.AppearanceImpl#getFloat Float}
* - {@link org.nasdanika.html.model.bootstrap.impl.AppearanceImpl#getChildren Children}
*
*
* @generated
*/
public class AppearanceImpl extends MinimalEObjectImpl.Container implements Appearance {
/**
* The default value of the '{@link #getBackground() Background}' attribute.
*
*
* @see #getBackground()
* @generated
* @ordered
*/
protected static final Color BACKGROUND_EDEFAULT = null;
/**
*
*
* @generated
*/
protected AppearanceImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return BootstrapPackage.Literals.APPEARANCE;
}
/**
*
*
* @generated
*/
@Override
protected int eStaticFeatureCount() {
return 0;
}
/**
*
*
* @generated
*/
@Override
public Color getBackground() {
return (Color)eDynamicGet(BootstrapPackage.APPEARANCE__BACKGROUND, BootstrapPackage.Literals.APPEARANCE__BACKGROUND, true, true);
}
/**
*
*
* @generated
*/
@Override
public void setBackground(Color newBackground) {
eDynamicSet(BootstrapPackage.APPEARANCE__BACKGROUND, BootstrapPackage.Literals.APPEARANCE__BACKGROUND, newBackground);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public EMap getAttributes() {
return (EMap)eDynamicGet(BootstrapPackage.APPEARANCE__ATTRIBUTES, BootstrapPackage.Literals.APPEARANCE__ATTRIBUTES, true, true);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public EList getBorder() {
return (EList)eDynamicGet(BootstrapPackage.APPEARANCE__BORDER, BootstrapPackage.Literals.APPEARANCE__BORDER, true, true);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public EList getMargin() {
return (EList)eDynamicGet(BootstrapPackage.APPEARANCE__MARGIN, BootstrapPackage.Literals.APPEARANCE__MARGIN, true, true);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public EList getPadding() {
return (EList)eDynamicGet(BootstrapPackage.APPEARANCE__PADDING, BootstrapPackage.Literals.APPEARANCE__PADDING, true, true);
}
/**
*
*
* @generated
*/
@Override
public Text getText() {
return (Text)eDynamicGet(BootstrapPackage.APPEARANCE__TEXT, BootstrapPackage.Literals.APPEARANCE__TEXT, true, true);
}
/**
*
*
* @generated
*/
public NotificationChain basicSetText(Text newText, NotificationChain msgs) {
msgs = eDynamicInverseAdd((InternalEObject)newText, BootstrapPackage.APPEARANCE__TEXT, msgs);
return msgs;
}
/**
*
*
* @generated
*/
@Override
public void setText(Text newText) {
eDynamicSet(BootstrapPackage.APPEARANCE__TEXT, BootstrapPackage.Literals.APPEARANCE__TEXT, newText);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public EList getFloat() {
return (EList)eDynamicGet(BootstrapPackage.APPEARANCE__FLOAT, BootstrapPackage.Literals.APPEARANCE__FLOAT, true, true);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public EMap getChildren() {
return (EMap)eDynamicGet(BootstrapPackage.APPEARANCE__CHILDREN, BootstrapPackage.Literals.APPEARANCE__CHILDREN, true, true);
}
/**
*
*
* @generated NOT
*/
@Override
public Appearance effectiveAppearance(String path) {
if (Util.isBlank(path)) {
return EcoreUtil.copy(this);
}
int idx = path.indexOf("/");
String childKey = idx == -1 ? path : path.substring(0, idx);
Appearance child = getChildren().get(childKey);
if (child == null) {
return EcoreUtil.copy(this);
}
Appearance ret = child.effectiveAppearance(idx == -1 ? null : path.substring(idx + 1));
merge(ret);
return ret;
}
private void merge(Appearance effectiveAppearance) {
// TODO - put attribute keys if not present, set unset features such as color. Add to list features.
throw new UnsupportedOperationException("Appearance merging is not supported yet");
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case BootstrapPackage.APPEARANCE__ATTRIBUTES:
return ((InternalEList>)getAttributes()).basicRemove(otherEnd, msgs);
case BootstrapPackage.APPEARANCE__BORDER:
return ((InternalEList>)getBorder()).basicRemove(otherEnd, msgs);
case BootstrapPackage.APPEARANCE__MARGIN:
return ((InternalEList>)getMargin()).basicRemove(otherEnd, msgs);
case BootstrapPackage.APPEARANCE__PADDING:
return ((InternalEList>)getPadding()).basicRemove(otherEnd, msgs);
case BootstrapPackage.APPEARANCE__TEXT:
return basicSetText(null, msgs);
case BootstrapPackage.APPEARANCE__FLOAT:
return ((InternalEList>)getFloat()).basicRemove(otherEnd, msgs);
case BootstrapPackage.APPEARANCE__CHILDREN:
return ((InternalEList>)getChildren()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case BootstrapPackage.APPEARANCE__BACKGROUND:
return getBackground();
case BootstrapPackage.APPEARANCE__ATTRIBUTES:
if (coreType) return getAttributes();
else return getAttributes().map();
case BootstrapPackage.APPEARANCE__BORDER:
return getBorder();
case BootstrapPackage.APPEARANCE__MARGIN:
return getMargin();
case BootstrapPackage.APPEARANCE__PADDING:
return getPadding();
case BootstrapPackage.APPEARANCE__TEXT:
return getText();
case BootstrapPackage.APPEARANCE__FLOAT:
return getFloat();
case BootstrapPackage.APPEARANCE__CHILDREN:
if (coreType) return getChildren();
else return getChildren().map();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case BootstrapPackage.APPEARANCE__BACKGROUND:
setBackground((Color)newValue);
return;
case BootstrapPackage.APPEARANCE__ATTRIBUTES:
((EStructuralFeature.Setting)getAttributes()).set(newValue);
return;
case BootstrapPackage.APPEARANCE__BORDER:
getBorder().clear();
getBorder().addAll((Collection extends Border>)newValue);
return;
case BootstrapPackage.APPEARANCE__MARGIN:
getMargin().clear();
getMargin().addAll((Collection extends Spacing>)newValue);
return;
case BootstrapPackage.APPEARANCE__PADDING:
getPadding().clear();
getPadding().addAll((Collection extends Spacing>)newValue);
return;
case BootstrapPackage.APPEARANCE__TEXT:
setText((Text)newValue);
return;
case BootstrapPackage.APPEARANCE__FLOAT:
getFloat().clear();
getFloat().addAll((Collection extends org.nasdanika.html.model.bootstrap.Float>)newValue);
return;
case BootstrapPackage.APPEARANCE__CHILDREN:
((EStructuralFeature.Setting)getChildren()).set(newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case BootstrapPackage.APPEARANCE__BACKGROUND:
setBackground(BACKGROUND_EDEFAULT);
return;
case BootstrapPackage.APPEARANCE__ATTRIBUTES:
getAttributes().clear();
return;
case BootstrapPackage.APPEARANCE__BORDER:
getBorder().clear();
return;
case BootstrapPackage.APPEARANCE__MARGIN:
getMargin().clear();
return;
case BootstrapPackage.APPEARANCE__PADDING:
getPadding().clear();
return;
case BootstrapPackage.APPEARANCE__TEXT:
setText((Text)null);
return;
case BootstrapPackage.APPEARANCE__FLOAT:
getFloat().clear();
return;
case BootstrapPackage.APPEARANCE__CHILDREN:
getChildren().clear();
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case BootstrapPackage.APPEARANCE__BACKGROUND:
return BACKGROUND_EDEFAULT == null ? getBackground() != null : !BACKGROUND_EDEFAULT.equals(getBackground());
case BootstrapPackage.APPEARANCE__ATTRIBUTES:
return !getAttributes().isEmpty();
case BootstrapPackage.APPEARANCE__BORDER:
return !getBorder().isEmpty();
case BootstrapPackage.APPEARANCE__MARGIN:
return !getMargin().isEmpty();
case BootstrapPackage.APPEARANCE__PADDING:
return !getPadding().isEmpty();
case BootstrapPackage.APPEARANCE__TEXT:
return getText() != null;
case BootstrapPackage.APPEARANCE__FLOAT:
return !getFloat().isEmpty();
case BootstrapPackage.APPEARANCE__CHILDREN:
return !getChildren().isEmpty();
}
return super.eIsSet(featureID);
}
/**
*
*
* @generated
*/
@Override
public Object eInvoke(int operationID, EList> arguments) throws InvocationTargetException {
switch (operationID) {
case BootstrapPackage.APPEARANCE___EFFECTIVE_APPEARANCE__STRING:
return effectiveAppearance((String)arguments.get(0));
}
return super.eInvoke(operationID, arguments);
}
} //AppearanceImpl
© 2015 - 2025 Weber Informatics LLC | Privacy Policy