Beispiel #1
0
 public Operation createOwnedOperation(
     Class aClass,
     String name,
     EList<String> paramNames,
     EList<Type> paramTypes,
     Type type,
     boolean isQuery) {
   Operation operation = aClass.createOwnedOperation(name, paramNames, paramTypes, type);
   if (isQuery) {
     operation.setIsQuery(true);
   }
   return operation;
 }
Beispiel #2
0
 public Operation createOwnedPrimitiveOperation(
     PrimitiveType aPrimitiveType,
     String name,
     EList<String> paramNames,
     EList<Type> paramTypes,
     Type type,
     boolean isQuery) {
   Operation operation = aPrimitiveType.createOwnedOperation(name, paramNames, paramTypes, type);
   if (isQuery) {
     operation.setIsQuery(true);
   }
   return operation;
 }
Beispiel #3
0
  /** Tests that unrecognized data types are represented by themselves, not by OclAny. */
  public void test_dataTypes_137158() {
    Package upackage = umlf.createPackage();
    upackage.setName("mypkg");
    Class uclass = upackage.createOwnedClass("B", false);
    DataType datatype = (DataType) pkg.createOwnedType("Thread", uml.getDataType());
    Operation operation = uclass.createOwnedOperation("f", null, null, datatype);
    operation.setIsQuery(true);

    helper.setContext(uclass);

    try {
      OCLExpression<Classifier> expr = helper.createQuery("self.f()");

      Classifier type = expr.getType();
      assertSame(datatype, type);

      operation.setUpper(LiteralUnlimitedNatural.UNLIMITED);

      expr = helper.createQuery("self.f()");

      type = expr.getType();
      assertTrue(type instanceof CollectionType<?, ?>);
      type = ((org.eclipse.ocl.uml.CollectionType) type).getElementType();
      assertSame(datatype, type);

      operation.setUpper(1);
      operation.setType(ocl.getEnvironment().getOCLStandardLibrary().getOclAny());

      expr = helper.createQuery("self.f()");

      type = expr.getType();
      assertSame(getOCLStandardLibrary().getOclAny(), type);
    } catch (Exception e) {
      fail("Failed to parse or evaluate: " + e.getLocalizedMessage());
    }
  }
Beispiel #4
0
 public void setIsQuery(Operation anOperation, boolean isQuery) {
   anOperation.setIsQuery(isQuery);
 }