Skip to content
This repository has been archived by the owner on Jun 26, 2021. It is now read-only.

Commit

Permalink
Merge branch 'hallvard-issue70'
Browse files Browse the repository at this point in the history
  • Loading branch information
ghillairet committed Sep 10, 2015
2 parents e7d28b2 + 7aebd6f commit 32df137
Show file tree
Hide file tree
Showing 12 changed files with 1,331 additions and 784 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private void readReference(JsonParser jp, EObject owner,
private void readAttribute(JsonParser jp, EObject owner,
EAttribute attribute, Resource resource,
DeserializationContext ctxt) throws IOException {
final EDataType dataType = attribute.getEAttributeType();
final EDataType dataType = (EDataType) owner.eClass().getFeatureType(attribute).getEClassifier();
if (dataType == null) {
resource.getErrors().add(new JSONException("Missing feature type", jp.getCurrentLocation()));
jp.nextToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void serialize(EObject object, JsonGenerator jg, SerializerProvider provi
if (EObjects.isFeatureMap(attribute)) {
writeFeatureMap(object, attribute, jg, provider);
} else {
writeAttribute(jg, attribute.getEAttributeType(), field, value);
writeAttribute(jg, (EDataType) object.eClass().getFeatureType(attribute).getEClassifier(), field, value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
ModuleTest.class,
NoTypeTest.class,
PolymorphicTest.class,
GenericTest.class,
ProxyAttributeTest.class,
ReaderTest.class,
ReferenceTest.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/**
*/
package org.emfjson.jackson.junit.model;

import java.util.Collection;
import java.util.List;
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.EObject;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Generic Container</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link org.emfjson.jackson.junit.model.GenericContainer#getValues <em>Values</em>}</li>
* </ul>
*
* @generated
*/
public class GenericContainer extends MinimalEObjectImpl.Container implements EObject {
/**
* The cached value of the '{@link #getValues() <em>Values</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValues()
* @generated
* @ordered
*/
protected EList<GenericType<?>> values;

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected GenericContainer() {
super();
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ModelPackage.Literals.GENERIC_CONTAINER;
}

/**
* Returns the value of the '<em><b>Values</b></em>' containment reference list.
* The list contents are of type {@link org.emfjson.jackson.junit.model.GenericType}&lt;?>.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Values</em>' containment reference isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Values</em>' containment reference list.
* @generated
*/
public List<GenericType<?>> getValues() {
if (values == null) {
values = new EObjectContainmentEList.Resolving<GenericType<?>>(GenericType.class, this, ModelPackage.GENERIC_CONTAINER__VALUES);
}
return values;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ModelPackage.GENERIC_CONTAINER__VALUES:
return ((InternalEList<?>)getValues()).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 ModelPackage.GENERIC_CONTAINER__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 ModelPackage.GENERIC_CONTAINER__VALUES:
getValues().clear();
getValues().addAll((Collection<? extends GenericType<?>>)newValue);
return;
}
super.eSet(featureID, newValue);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ModelPackage.GENERIC_CONTAINER__VALUES:
getValues().clear();
return;
}
super.eUnset(featureID);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ModelPackage.GENERIC_CONTAINER__VALUES:
return values != null && !values.isEmpty();
}
return super.eIsSet(featureID);
}

} // GenericContainer
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/**
*/
package org.emfjson.jackson.junit.model;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Generic Type</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link org.emfjson.jackson.junit.model.GenericType#getValue <em>Value</em>}</li>
* </ul>
*
* @generated
*/
public abstract class GenericType<T> extends MinimalEObjectImpl.Container implements EObject {
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected T value;

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected GenericType() {
super();
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ModelPackage.Literals.GENERIC_TYPE;
}

/**
* Returns the value of the '<em><b>Value</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Value</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Value</em>' attribute.
* @see #setValue(Object)
* @generated
*/
public T getValue() {
return value;
}

/**
* Sets the value of the '{@link org.emfjson.jackson.junit.model.GenericType#getValue <em>Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Value</em>' attribute.
* @see #getValue()
* @generated
*/
public void setValue(T newValue) {
T oldValue = value;
value = newValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.GENERIC_TYPE__VALUE, oldValue, value));
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case ModelPackage.GENERIC_TYPE__VALUE:
return getValue();
}
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 ModelPackage.GENERIC_TYPE__VALUE:
setValue((T)newValue);
return;
}
super.eSet(featureID, newValue);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ModelPackage.GENERIC_TYPE__VALUE:
setValue((T)null);
return;
}
super.eUnset(featureID);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ModelPackage.GENERIC_TYPE__VALUE:
return value != null;
}
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(" (value: ");
result.append(value);
result.append(')');
return result.toString();
}

} // GenericType
Loading

0 comments on commit 32df137

Please sign in to comment.