private EClassifier resolveFeatureType(
     EStructuralFeature feature,
     Collection<EClassifierMapping> eClassifierMappings,
     Collection<EPackage> ePackages) {
   EAnnotation eAnnotation = feature.getEAnnotation(TypesPackage.eNS_URI);
   if (eAnnotation != null) {
     JvmTypeReference type = getEObject(eAnnotation.getReferences(), JvmTypeReference.class, null);
     if (type == null) {
       return null;
     }
     EClassifier eClassifier = null;
     for (EClassifierMapping eClassifierMapping : eClassifierMappings) {
       if (eClassifierMapping.getDeclaredType() == type) {
         eClassifier = eClassifierMapping.getEClassifier();
         break;
       }
     }
     String typeName = getTypeName(type);
     if (eClassifier == null) {
       for (EPackage ePackage : ePackages) {
         eClassifier = findEClassifier(typeName, ePackage);
         if (eClassifier != null) {
           break;
         }
       }
     }
     if (eClassifier == null) {
       eClassifier = findEClassifier(typeName, EcorePackage.eINSTANCE);
     }
     feature.setEType(eClassifier);
     return eClassifier;
   }
   return null;
 }
Ejemplo n.º 2
0
  /**
   * CDO persists the isUnset state of an eObject in the database. The indicator for this is that
   * the feature is null in the revision (see CDOStore.isSet()). When committing a legacy object all
   * values in the instance for native attributes are set with the java default values. So, these
   * values will be stored in the revision and CDO cannot distinguish whether the feature is set or
   * not. This method must ensure that the value will be set to null if the feature is not set.
   */
  public void cdoInternalPreCommit() {
    // We have to set this here because the CDOLegacyAdapter will not be notified when the instance
    // is the target of a
    // single-directional containment reference.
    // If the container is not an legacy Object the system will get no information
    instanceToRevisionContainment();

    InternalCDORevision revision = cdoRevision();
    for (EStructuralFeature feature : classInfo.getAllPersistentFeatures()) {
      if (feature.isUnsettable()) {
        if (!isSetInstanceValue(instance, feature)) {
          if (feature.isMany()) {
            @SuppressWarnings("unchecked")
            InternalEList<Object> list = (InternalEList<Object>) instance.eGet(feature);
            clearEList(list);
          } else {
            revision.set(feature, EStore.NO_INDEX, null);
          }
        } else if (instance.eGet(feature) == null) {
          // Must be single-valued!
          revision.set(feature, EStore.NO_INDEX, CDORevisionData.NIL);
        }
      }
    }
  }
Ejemplo n.º 3
0
 public static boolean isMany(EClass eClass, String featureName) {
   if (eClass == null || featureName == null) {
     return false;
   }
   EStructuralFeature feature = eClass.getEStructuralFeature(featureName);
   return feature != null && feature.isMany();
 }
    UncontrolUpdate(
        EStructuralFeature.Setting setting,
        EObject originalObject,
        CDOID originalProxy,
        URI destinationURI,
        CDOID destinationProxy) {
      super(setting);
      this.originalObject = originalObject;
      this.originalProxy = originalProxy;
      this.destinationURI = destinationURI;
      this.destinationProxy = destinationProxy;

      EStructuralFeature feature = setting.getEStructuralFeature();
      InternalEObject owner = (InternalEObject) setting.getEObject();

      if (!feature.isMany()) {
        index = EStore.NO_INDEX;
      } else {
        // don't go directly to the store because it may have proxies.
        // Use the resolved view in the EObject, instead
        index = ((EList<?>) owner.eGet(feature)).indexOf(originalObject);
        if (index < 0) {
          Activator.log.error(
              "Setting does not include the object being replaced by a proxy.",
              null); //$NON-NLS-1$
        }
      }
    }
Ejemplo n.º 5
0
 /**
  * Get the value of the named AD parameter for the activity as a string. Works with several types,
  * not just strings -- enums, for example.
  *
  * @param element
  * @param parameterName
  * @return null if the parameter is not found
  */
 public static String getParameterString(EPlanElement element, String parameterName) {
   EObject data = element.getData();
   if (data == null) return null;
   EStructuralFeature feature;
   try {
     feature = getParameterFeature(data, parameterName);
   } catch (UndefinedParameterException e) {
     return null;
   }
   Object object = data.eGet(feature);
   if (object instanceof EEnumLiteral) {
     EEnumLiteral literal = (EEnumLiteral) object;
     return literal.getName();
   }
   EClassifier type = feature.getEType();
   if (type instanceof EDataType) {
     EDataType dataType = (EDataType) type;
     EPackage typePackage = dataType.getEPackage();
     EFactory factory = typePackage.getEFactoryInstance();
     String string = factory.convertToString(dataType, object);
     return string;
   }
   LogUtil.warnOnce("feature type '" + type + "'is not EDataType: " + parameterName);
   return String.valueOf(object);
 }
  /*
   * (non-Javadoc)
   *
   * @see com.puppetlabs.geppetto.pp.dsl.linking.IMessageAcceptor#accept(org.eclipse.xtext.diagnostics.Severity, java.lang.String,
   * org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EStructuralFeature, int, java.lang.String, java.lang.String)
   */
  @Override
  public void accept(
      Severity severity,
      String message,
      EObject source,
      EStructuralFeature feature,
      int index,
      String issueCode,
      String... issueData) {

    if (severity == null) throw new IllegalArgumentException("severity can not be null");
    if (feature == null) throw new IllegalArgumentException("feature can not be null");
    if (source == null) throw new IllegalArgumentException("source can not be null");

    if (source.eClass().getEStructuralFeature(feature.getName()) != feature) {
      throw new IllegalArgumentException(
          "EClass '"
              + source.eClass().getName()
              + "' does not expose a feature '"
              + feature.getName()
              + //
              "' (id: "
              + feature.getFeatureID()
              + ")");
    }

    producer.setNode(getNode(source, feature, index));
    DiagnosticMessage m = new DiagnosticMessage(message, severity, issueCode, issueData);
    producer.addDiagnostic(m);
  }
Ejemplo n.º 7
0
  protected Declaration handleStyleFeature(Style style, EStructuralFeature feature) {
    Declaration declaration = CssFactory.eINSTANCE.createDeclaration();
    declaration.setProperty(feature.getName());

    GMFToCSSConverter converter = GMFToCSSConverter.instance;

    if (isString(feature)) {
      declaration.setExpression(converter.convert((String) style.eGet(feature)));
    }

    if (isInteger(feature)) {
      if (feature.getName().endsWith("Color")) {
        Color color = FigureUtilities.integerToColor((Integer) style.eGet(feature));
        declaration.setExpression(converter.convert(color));
        color.dispose();
      } else {
        declaration.setExpression(converter.convert((Integer) style.eGet(feature)));
      }
    }

    if (feature.getEType() == NotationPackage.eINSTANCE.getGradientData()) {
      declaration.setExpression(converter.convert((GradientData) style.eGet(feature)));
    }

    if (feature.getEType() instanceof EEnum) {
      declaration.setExpression(converter.convert((Enumerator) style.eGet(feature)));
    }

    if (isBoolean(feature)) {
      declaration.setExpression(converter.convert((Boolean) style.eGet(feature)));
    }

    return declaration;
  }
 protected EObject createInitialModel() {
   EClass eClass = ExtendedMetaData.INSTANCE.getDocumentRoot(dsPackage);
   EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature("data");
   EObject rootObject = dsFactory.create(eClass);
   rootObject.eSet(eStructuralFeature, EcoreUtil.create((EClass) eStructuralFeature.getEType()));
   return rootObject;
 }
 @SuppressWarnings({"unchecked", "rawtypes"})
 private void setSourceRef(
     DataAssociation association,
     ItemAwareElement value,
     EObject container,
     EStructuralFeature containerFeature) {
   if (association.getSourceRef().size() == 0) {
     if (container != null) {
       if (containerFeature.isMany()) ((List) container.eGet(containerFeature)).add(value);
       else container.eSet(containerFeature, value);
     }
     if (value == null) association.getSourceRef().clear();
     else association.getSourceRef().add(value);
     updateConnectionIfNeeded(association, value);
   } else {
     if (container != null) {
       if (containerFeature.isMany()) ((List) container.eGet(containerFeature)).add(value);
       else container.eSet(containerFeature, value);
     }
     updateConnectionIfNeeded(association, value);
     if (value == null) association.getSourceRef().clear();
     else association.getSourceRef().set(0, value);
     updateConnectionIfNeeded(association, value);
   }
   if (association.getTargetRef() != null) {
     ItemAwareElement targetRef = association.getTargetRef();
     if (value != null) targetRef.setItemSubjectRef(value.getItemSubjectRef());
     else targetRef.setItemSubjectRef(null);
     updateConnectionIfNeeded(association, value);
   }
 }
Ejemplo n.º 10
0
  protected Map<Declaration, Boolean> handleStyle(Style style) {
    if (style instanceof NamedStyle) {
      return Collections.emptyMap();
    }

    Map<Declaration, Boolean> declarations = new LinkedHashMap<Declaration, Boolean>();

    for (EStructuralFeature feature : style.eClass().getEAllStructuralFeatures()) {
      if (NotationPackage.eINSTANCE.getStyle().isSuperTypeOf(feature.getEContainingClass())) {
        Object currentValue = style.eGet(feature);
        Object defaultValue = feature.getDefaultValue();
        boolean check =
            currentValue == null
                ? currentValue != defaultValue
                : !currentValue.equals(defaultValue);

        Declaration declaration = handleStyleFeature(style, feature);
        if (declaration.getExpression()
            != null) { // If expression is null, the type of this property is not supported
          declarations.put(declaration, check);
        }
      }
    }

    return declarations;
  }
Ejemplo n.º 11
0
 protected String toString(IEObjectRegion region) {
   EObject obj = region.getSemanticElement();
   StringBuilder builder =
       new StringBuilder(Strings.padEnd(toClassWithName(obj), textWidth, ' ') + " ");
   EObject element = region.getGrammarElement();
   if (element instanceof AbstractElement)
     builder.append(grammarToString.apply((AbstractElement) element));
   else if (element instanceof AbstractRule) builder.append(((AbstractRule) element).getName());
   else builder.append(": ERROR: No grammar element.");
   List<String> segments = Lists.newArrayList();
   EObject current = obj;
   while (current.eContainer() != null) {
     EObject container = current.eContainer();
     EStructuralFeature containingFeature = current.eContainingFeature();
     StringBuilder segment = new StringBuilder();
     segment.append(toClassWithName(container));
     segment.append("/");
     segment.append(containingFeature.getName());
     if (containingFeature.isMany()) {
       int index = ((List<?>) container.eGet(containingFeature)).indexOf(current);
       segment.append("[" + index + "]");
     }
     current = container;
     segments.add(segment.toString());
   }
   if (!segments.isEmpty()) {
     builder.append(" path:");
     builder.append(Joiner.on("=").join(segments));
   }
   return builder.toString();
 }
Ejemplo n.º 12
0
 public CharSequence assignmentOperator(final EStructuralFeature it) {
   StringConcatenation _builder = new StringConcatenation();
   {
     boolean _isMany = it.isMany();
     if (_isMany) {
       _builder.append("+=");
     } else {
       boolean _and = false;
       EClassifier _eType = it.getEType();
       boolean _isBoolean = Ecore2XtextExtensions.isBoolean(_eType);
       if (!_isBoolean) {
         _and = false;
       } else {
         boolean _isPrefixBooleanFeature = Ecore2XtextExtensions.isPrefixBooleanFeature(it);
         _and = (_isBoolean && _isPrefixBooleanFeature);
       }
       if (_and) {
         _builder.append("?=");
       } else {
         _builder.append("=");
       }
     }
   }
   return _builder;
 }
Ejemplo n.º 13
0
 protected Object convertValue(EStructuralFeature feature, Object value) {
   String constantName = String.valueOf(value).toUpperCase();
   Class<?> constants = SWT.class;
   String constantClass =
       EcoreUtil.getAnnotation(feature, SwtBuilder.getAnnotationUri(), "constantClass");
   if (constantClass != null) {
     try {
       constants = context.convert(constantClass, Class.class);
     } catch (Exception e) {
       throw new IllegalArgumentException(
           "Conversion from " + value + " failed: " + e.getMessage(), e);
     }
   }
   if (feature.getEType() == EcorePackage.eINSTANCE.getEString()) {
     String type = EcoreUtil.getAnnotation(feature, SwtBuilder.getAnnotationUri(), "type");
     if ("int".equals(type)) {
       value = SwtBuilder.getStaticField(constants, constantName, Integer.class, SWT.DEFAULT);
     } else if (type != null) {
       try {
         Class<?> typeClass = context.convert(type, Class.class);
         value = SwtBuilder.getStaticField(constants, constantName, typeClass, null);
       } catch (Exception e) {
         throw new IllegalArgumentException(
             "Conversion from " + value + " to " + type + " failed: " + e.getMessage(), e);
       }
     }
   } else if (feature.getEType()
       == org.eclipse.e4.tm.swt.styles.StylesPackage.eINSTANCE.getSwtConstant()) {
     value = SwtBuilder.getStaticField(constants, constantName, Integer.class, SWT.DEFAULT);
   }
   return value;
 }
 /* (non-Javadoc)
  * @see org.eclipse.graphiti.features.IFeature#canExecute(org.eclipse.graphiti.features.context.IContext)
  */
 @Override
 public boolean canExecute(IContext context) {
   // TODO: clean this mess up: use {@code getWorkItemEditor()) to check if the selected task
   // has a WID and if the WID defines a customEditor
   BPMN2Editor editor =
       (BPMN2Editor)
           getFeatureProvider()
               .getDiagramTypeProvider()
               .getDiagramBehavior()
               .getDiagramContainer();
   IBpmn2RuntimeExtension rte = editor.getTargetRuntime().getRuntimeExtension();
   if (rte instanceof JBPM5RuntimeExtension && context instanceof ICustomContext) {
     PictogramElement[] pes = ((ICustomContext) context).getPictogramElements();
     if (pes.length == 1) {
       Object o = Graphiti.getLinkService().getBusinessObjectForLinkedPictogramElement(pes[0]);
       if (o instanceof Task) {
         Task task = (Task) o;
         List<EStructuralFeature> features = ModelDecorator.getAnyAttributes(task);
         for (EStructuralFeature f : features) {
           if ("taskName".equals(f.getName())) { // $NON-NLS-1$
             // make sure the Work Item Definition exists
             String taskName = (String) task.eGet(f);
             return ((JBPM5RuntimeExtension) rte).getWorkItemDefinition(taskName) != null;
           }
         }
       }
     }
   }
   return false;
 }
Ejemplo n.º 15
0
 private void writeEmbedded(PrintWriter out, EObject eObject) throws SerializerException {
   EClass class1 = eObject.eClass();
   out.print(upperCases.get(class1));
   out.print(OPEN_PAREN);
   EStructuralFeature structuralFeature = class1.getEStructuralFeature(WRAPPED_VALUE);
   if (structuralFeature != null) {
     Object realVal = eObject.eGet(structuralFeature);
     if (structuralFeature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
       Object stringVal =
           eObject.eGet(class1.getEStructuralFeature(structuralFeature.getName() + "AsString"));
       if (stringVal != null && model.isUseDoubleStrings()) {
         out.print(stringVal);
       } else {
         if (((Double) realVal).isInfinite() || (((Double) realVal).isNaN())) {
           LOGGER.info("Serializing infinite or NaN double as 0.0");
           out.print("0.0");
         } else {
           out.print(realVal);
         }
       }
     } else {
       writePrimitive(out, realVal);
     }
   }
   out.print(CLOSE_PAREN);
 }
  protected boolean matchesFeature(Object featureObj) {
    if (featureObj instanceof EStructuralFeature) {
      EStructuralFeature f = (EStructuralFeature) featureObj;
      return feature.getName().equals(f.getName());
    }

    return false;
  }
 /** Constructor. */
 public EEnumComboBoxDataProvider(Object axisElement) {
   Object object = AxisUtils.getRepresentedElement(axisElement);
   Assert.isTrue(object instanceof EStructuralFeature);
   EStructuralFeature feature = (EStructuralFeature) object;
   EClassifier type = feature.getEType();
   Assert.isTrue(type instanceof EEnum);
   this.eenum = (EEnum) type;
 }
Ejemplo n.º 18
0
 public DateFilterUtil(Class<T> eObjClass, EStructuralFeature... dateFeature) {
   final EStructuralFeature tail = dateFeature[dateFeature.length - 1];
   this.dateFeature = FeaturePath.fromList(dateFeature);
   if (!Date.class.isAssignableFrom(tail.getEType().getInstanceClass())) {
     throw new IllegalArgumentException(
         "feature type " + tail.getEType().getInstanceClass() + " not a Date subclass");
   }
 }
Ejemplo n.º 19
0
  /**
   * Tests the behavior of reference <code>conflict</code>'s accessors.
   *
   * @generated
   */
  @Test
  public void testConflict() {
    EStructuralFeature feature =
        org.eclipse.emf.compare.ComparePackage.eINSTANCE.getDiff_Conflict();
    ReferenceChange referenceChange = CompareFactory.eINSTANCE.createReferenceChange();
    referenceChange.eAdapters().add(new MockEAdapter());
    org.eclipse.emf.compare.Conflict conflictValue =
        org.eclipse.emf.compare.CompareFactory.eINSTANCE.createConflict();

    assertFalse(referenceChange.eIsSet(feature));
    assertNull(referenceChange.getConflict());

    referenceChange.setConflict(conflictValue);
    assertTrue(notified);
    notified = false;
    assertSame(conflictValue, referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertTrue(referenceChange.eIsSet(feature));
    assertTrue(conflictValue.getDifferences().contains(referenceChange));

    referenceChange.eUnset(feature);
    assertTrue(notified);
    notified = false;
    assertNull(referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertFalse(referenceChange.eIsSet(feature));
    assertFalse(conflictValue.getDifferences().contains(referenceChange));

    referenceChange.setConflict(conflictValue);
    assertTrue(notified);
    notified = false;
    assertSame(conflictValue, referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertTrue(referenceChange.eIsSet(feature));
    assertTrue(conflictValue.getDifferences().contains(referenceChange));

    referenceChange.eSet(feature, conflictValue);
    assertTrue(notified);
    notified = false;
    assertSame(conflictValue, referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertTrue(referenceChange.eIsSet(feature));
    assertTrue(conflictValue.getDifferences().contains(referenceChange));

    referenceChange.setConflict(null);
    assertTrue(notified);
    notified = false;
    assertNull(referenceChange.getConflict());
    assertSame(feature.getDefaultValue(), referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertFalse(referenceChange.eIsSet(feature));
    assertFalse(conflictValue.getDifferences().contains(referenceChange));
  }
    @Override
    public void revert() {
      EStructuralFeature feature = setting.getEStructuralFeature();

      if (index >= 0 || !feature.isMany()) {
        InternalEObject owner = (InternalEObject) setting.getEObject();
        store.set(owner, feature, index, CDOUtils.getCDOID(originalObject));
      }
    }
Ejemplo n.º 21
0
 /**
  * Returns the default alignment for the specific value type.
  *
  * <p>If you want to change the alignment use the <code>uibindings/model</code> and <code>
  * uibindings/model/feature elements</code>.
  *
  * @param valueType the value type to test
  * @return the default alignment
  */
 public static int defaultAlignment(Object valueType) {
   if (valueType instanceof EStructuralFeature) {
     final EStructuralFeature sf = (EStructuralFeature) valueType;
     valueType = sf.getEType();
   }
   final Integer alignment = DEFAULT_ALIGNMENT.get(valueType);
   if (alignment != null) return alignment;
   return SWT.NONE;
 }
 protected Task createFlowElement(ICreateContext context) {
   Task task = ModelHandler.FACTORY.createTask();
   task.setName("Email Task");
   ArrayList<EStructuralFeature> attributes = Bpmn2Preferences.getAttributes(task.eClass());
   for (EStructuralFeature eStructuralFeature : attributes) {
     if (eStructuralFeature.getName().equals("taskName")) task.eSet(eStructuralFeature, "email");
   }
   return task;
 }
    @Override
    public void apply() {
      EStructuralFeature feature = setting.getEStructuralFeature();

      if ((index >= 0) || !feature.isMany()) {
        InternalEObject owner = (InternalEObject) setting.getEObject();
        store.set(owner, feature, index, proxy);
      }
    }
Ejemplo n.º 24
0
    /**
     * @return the result feature delta, or <code>null</code> to indicate an unresolved conflict.
     */
    protected CDOFeatureDelta changedInSourceAndTarget(
        CDOFeatureDelta targetFeatureDelta, CDOFeatureDelta sourceFeatureDelta) {
      EStructuralFeature feature = targetFeatureDelta.getFeature();
      if (feature.isMany()) {
        return changedInSourceAndTargetManyValued(feature, targetFeatureDelta, sourceFeatureDelta);
      }

      return changedInSourceAndTargetSingleValued(feature, targetFeatureDelta, sourceFeatureDelta);
    }
Ejemplo n.º 25
0
 public static void markFeatureAsStatic(EStructuralFeature eFeature) {
   IntermediateStaticFieldAdapter adapter =
       (IntermediateStaticFieldAdapter)
           EcoreUtil.getAdapter(eFeature.eAdapters(), IntermediateStaticFieldAdapter.class);
   if (adapter == null) {
     adapter = new IntermediateStaticFieldAdapter();
     eFeature.eAdapters().add(adapter);
   }
 }
Ejemplo n.º 26
0
    public static int kind(EStructuralFeature eStructuralFeature) {
      int result = 0;

      EClassifier eClassifier = eStructuralFeature.getEType();

      if (eClassifier.getInstanceClass() != null) {
        result |= HAS_INSTANCE_CLASS;
      }

      if (eStructuralFeature.isUnsettable()) {
        result |= IS_UNSETTABLE;
      }

      if (eStructuralFeature instanceof EReference) {
        EReference eReference = (EReference) eStructuralFeature;
        EReference inverseEReference = eReference.getEOpposite();
        if (eReference.isContainment()) {
          result |= IS_CONTAINMENT;
        }

        if (inverseEReference != null) {
          // This forces the feature ids to be assigned.
          //
          inverseEReference.getEContainingClass().getFeatureCount();
          result |= HAS_NAVIGABLE_INVERSE;
          if (inverseEReference.isMany()) {
            result |= HAS_MANY_INVERSE;
          }
          if (inverseEReference.isContainment()) {
            result |= IS_CONTAINER;
          }
        }

        if (eReference.isResolveProxies()) {
          result |= HAS_PROXIES;
        }

        result |= IS_EOBJECT;
      } else // if (eStructuralFeature instanceof EAttribute
      {
        if (eClassifier instanceof EEnum) {
          result |= IS_ENUM;
        } else {
          Class<?> instanceClass = eClassifier.getInstanceClass();
          if (instanceClass != null && instanceClass.isPrimitive()) {
            result |= IS_PRIMITIVE;
          }
        }
      }

      if (eStructuralFeature.isUnique()) {
        result |= IS_UNIQUE;
      }

      return result;
    }
 public String syntheticName(final KeyAST b) {
   final EObject binding = b.eContainer();
   EStructuralFeature _eContainingFeature = b.eContainingFeature();
   String _name = _eContainingFeature.getName();
   String _plus = ("_" + _name);
   EObject _eContainer = binding.eContainer();
   EList<EObject> _eContents = _eContainer.eContents();
   int _indexOf = _eContents.indexOf(binding);
   return (_plus + Integer.valueOf(_indexOf));
 }
Ejemplo n.º 28
0
 /**
  * Get the value of the AD parameter by type for the activity
  *
  * @param element
  * @param parameterType
  * @return
  */
 @SuppressWarnings("unchecked")
 public static <T> Option<T> getParameterObjectByType(EPlanElement element, EClass parameterType) {
   EObject data = element.getData();
   EList<EStructuralFeature> structuralFeatures = data.eClass().getEStructuralFeatures();
   for (int i = 0; i < structuralFeatures.size(); i++) {
     final EStructuralFeature feature = structuralFeatures.get(i);
     if (parameterType == feature.getEType()) return Option.fromNull((T) data.eGet(feature));
   }
   return Option.none();
 }
Ejemplo n.º 29
0
 /**
  * Returns whether activity contains AD parameter of given type
  *
  * @param element
  * @param parameterType
  * @return
  */
 @SuppressWarnings("unchecked")
 public static boolean isParameterForType(EPlanElement element, EClass parameterType) {
   EObject data = element.getData();
   EList<EStructuralFeature> structuralFeatures = data.eClass().getEStructuralFeatures();
   for (int i = 0; i < structuralFeatures.size(); i++) {
     final EStructuralFeature feature = structuralFeatures.get(i);
     if (parameterType == feature.getEType()) return true;
   }
   return false;
 }
Ejemplo n.º 30
0
 private void writeEDataType(PrintWriter out, EObject object, EStructuralFeature feature)
     throws SerializerException {
   if (feature.getEAnnotation("derived") != null) {
     out.print(ASTERISK);
   } else if (feature.isMany()) {
     writeList(out, object, feature);
   } else {
     writeObject(out, object, feature);
   }
 }