All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nasdanika.models.java.impl.FieldImpl Maven / Gradle / Ivy

/**
 */
package org.nasdanika.models.java.impl;

import java.util.List;
import java.util.function.Function;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.nasdanika.models.java.Field;
import org.nasdanika.models.source.GenerationMode;
import org.nasdanika.models.java.GenericType;
import org.nasdanika.models.java.JavaPackage;
import org.nasdanika.models.source.Source;
import org.nasdanika.models.java.TypedElement;

/**
 * 
 * An implementation of the model object 'Field'.
 * 
 * 

* The following features are implemented: *

*
    *
  • {@link org.nasdanika.models.java.impl.FieldImpl#getType Type}
  • *
* * @generated */ public class FieldImpl extends CodeImpl implements Field { /** * * * @generated */ protected FieldImpl() { super(); } /** * * * @generated */ @Override protected EClass eStaticClass() { return JavaPackage.Literals.FIELD; } /** * * * @generated */ @Override public GenericType getType() { return (GenericType)eDynamicGet(JavaPackage.FIELD__TYPE, JavaPackage.Literals.TYPED_ELEMENT__TYPE, true, true); } /** * * * @generated */ public NotificationChain basicSetType(GenericType newType, NotificationChain msgs) { msgs = eDynamicInverseAdd((InternalEObject)newType, JavaPackage.FIELD__TYPE, msgs); return msgs; } /** * * * @generated */ @Override public void setType(GenericType newType) { eDynamicSet(JavaPackage.FIELD__TYPE, JavaPackage.Literals.TYPED_ELEMENT__TYPE, newType); } /** * * * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case JavaPackage.FIELD__TYPE: return basicSetType(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * * * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case JavaPackage.FIELD__TYPE: return getType(); } return super.eGet(featureID, resolve, coreType); } /** * * * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case JavaPackage.FIELD__TYPE: setType((GenericType)newValue); return; } super.eSet(featureID, newValue); } /** * * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case JavaPackage.FIELD__TYPE: setType((GenericType)null); return; } super.eUnset(featureID); } /** * * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case JavaPackage.FIELD__TYPE: return getType() != null; } return super.eIsSet(featureID); } /** * * * @generated */ @Override public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { if (baseClass == TypedElement.class) { switch (derivedFeatureID) { case JavaPackage.FIELD__TYPE: return JavaPackage.TYPED_ELEMENT__TYPE; default: return -1; } } return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); } /** * * * @generated */ @Override public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { if (baseClass == TypedElement.class) { switch (baseFeatureID) { case JavaPackage.TYPED_ELEMENT__TYPE: return JavaPackage.FIELD__TYPE; default: return -1; } } return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); } @Override protected List generateContents(Function importManager, int indent) { List contents = super.generateContents(importManager, indent); StringBuilder builder = indent(indent); for (String modifier: getModifiers()) { builder.append(modifier).append(" "); } GenericType type = getType(); builder.append(type.generate(importManager, 0)).append(" "); builder.append(getName()); Source body = getBody(); if (body != null) { builder.append(" = ").append(body.generate(importManager, indent + 1)); } builder.append(";"); if (!isMerging()) { builder.append(System.lineSeparator()); } contents.add(Source.create(builder)); return contents; } } //FieldImpl




© 2015 - 2024 Weber Informatics LLC | Privacy Policy