| /** |
| * <copyright> |
| * |
| * Copyright (c) 2012 E.D.Willink and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * E.D.Willink - initial API and implementation |
| * |
| * </copyright> |
| */ |
| package org.eclipse.ocl.examples.pivot.model; |
| |
| import java.util.List; |
| |
| import org.eclipse.ocl.examples.domain.library.LibraryFeature; |
| import org.eclipse.ocl.examples.pivot.AnyType; |
| import org.eclipse.ocl.examples.pivot.AssociativityKind; |
| import org.eclipse.ocl.examples.pivot.BagType; |
| import org.eclipse.ocl.examples.pivot.Class; |
| import org.eclipse.ocl.examples.pivot.ClassifierType; |
| import org.eclipse.ocl.examples.pivot.CollectionType; |
| import org.eclipse.ocl.examples.pivot.Comment; |
| import org.eclipse.ocl.examples.pivot.DataType; |
| import org.eclipse.ocl.examples.pivot.Element; |
| import org.eclipse.ocl.examples.pivot.Enumeration; |
| import org.eclipse.ocl.examples.pivot.EnumerationLiteral; |
| import org.eclipse.ocl.examples.pivot.InvalidType; |
| import org.eclipse.ocl.examples.pivot.Iteration; |
| import org.eclipse.ocl.examples.pivot.LambdaType; |
| import org.eclipse.ocl.examples.pivot.Library; |
| import org.eclipse.ocl.examples.pivot.Operation; |
| import org.eclipse.ocl.examples.pivot.OrderedSetType; |
| import org.eclipse.ocl.examples.pivot.Package; |
| import org.eclipse.ocl.examples.pivot.Parameter; |
| import org.eclipse.ocl.examples.pivot.ParameterableElement; |
| import org.eclipse.ocl.examples.pivot.PivotFactory; |
| import org.eclipse.ocl.examples.pivot.Precedence; |
| import org.eclipse.ocl.examples.pivot.PrimitiveType; |
| import org.eclipse.ocl.examples.pivot.Property; |
| import org.eclipse.ocl.examples.pivot.SelfType; |
| import org.eclipse.ocl.examples.pivot.SequenceType; |
| import org.eclipse.ocl.examples.pivot.SetType; |
| import org.eclipse.ocl.examples.pivot.TemplateBinding; |
| import org.eclipse.ocl.examples.pivot.TemplateParameter; |
| import org.eclipse.ocl.examples.pivot.TemplateParameterSubstitution; |
| import org.eclipse.ocl.examples.pivot.TemplateSignature; |
| import org.eclipse.ocl.examples.pivot.TemplateableElement; |
| import org.eclipse.ocl.examples.pivot.TupleType; |
| import org.eclipse.ocl.examples.pivot.Type; |
| import org.eclipse.ocl.examples.pivot.TypeTemplateParameter; |
| import org.eclipse.ocl.examples.pivot.VoidType; |
| import org.eclipse.ocl.examples.pivot.manager.PivotStandardLibrary; |
| |
| public class AbstractContents |
| { |
| protected final PivotStandardLibrary standardLibrary; |
| |
| protected AbstractContents() { |
| this.standardLibrary = null; |
| } |
| |
| protected AbstractContents(PivotStandardLibrary standardLibrary) { |
| this.standardLibrary = standardLibrary; |
| } |
| |
| protected AnyType createAnyType(String name) { |
| AnyType pivotType = PivotFactory.eINSTANCE.createAnyType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected BagType createBagType(String name) { |
| BagType pivotType = PivotFactory.eINSTANCE.createBagType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected Class createClass(String name) { |
| Class pivotType = PivotFactory.eINSTANCE.createClass(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected ClassifierType createClassifierType(String name) { |
| ClassifierType pivotType = PivotFactory.eINSTANCE.createClassifierType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected CollectionType createCollectionType(String name) { |
| CollectionType pivotType = PivotFactory.eINSTANCE.createCollectionType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected DataType createDataType(String name) { |
| DataType pivotType = PivotFactory.eINSTANCE.createDataType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected Enumeration createEnumeration(String name) { |
| Enumeration pivotType = PivotFactory.eINSTANCE.createEnumeration(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected EnumerationLiteral createEnumerationLiteral(String name) { |
| EnumerationLiteral pivotEnumerationLiteral = PivotFactory.eINSTANCE.createEnumerationLiteral(); |
| pivotEnumerationLiteral.setName(name); |
| return pivotEnumerationLiteral; |
| } |
| |
| protected Iteration createIteration(String name, Type type, String implementationClass, LibraryFeature implementation) { |
| Iteration pivotIteration = PivotFactory.eINSTANCE.createIteration(); |
| pivotIteration.setName(name); |
| pivotIteration.setType(type); |
| pivotIteration.setImplementationClass(implementationClass); |
| pivotIteration.setImplementation(implementation); |
| return pivotIteration; |
| } |
| |
| protected InvalidType createInvalidType(String name) { |
| InvalidType pivotType = PivotFactory.eINSTANCE.createInvalidType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected LambdaType createLambdaType(String name) { |
| LambdaType pivotType = PivotFactory.eINSTANCE.createLambdaType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected Library createLibrary(String name, String nsPrefix, String nsURI) { |
| Library pivotLibrary = PivotFactory.eINSTANCE.createLibrary(); |
| pivotLibrary.setName(name); |
| pivotLibrary.setNsPrefix(nsPrefix); |
| pivotLibrary.setNsURI(nsURI); |
| return pivotLibrary; |
| } |
| |
| protected Operation createOperation(String name, Type type, String implementationClass, LibraryFeature implementation) { |
| Operation pivotOperation = PivotFactory.eINSTANCE.createOperation(); |
| pivotOperation.setName(name); |
| pivotOperation.setType(type); |
| pivotOperation.setImplementationClass(implementationClass); |
| pivotOperation.setImplementation(implementation); |
| return pivotOperation; |
| } |
| |
| protected OrderedSetType createOrderedSetType(String name) { |
| OrderedSetType pivotType = PivotFactory.eINSTANCE.createOrderedSetType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected Package createPackage(String name, String nsPrefix, String nsURI) { |
| Package pivotPackage = PivotFactory.eINSTANCE.createPackage(); |
| pivotPackage.setName(name); |
| pivotPackage.setNsPrefix(nsPrefix); |
| pivotPackage.setNsURI(nsURI); |
| return pivotPackage; |
| } |
| |
| protected Parameter createParameter(String name, Type type) { |
| Parameter pivotParameter = PivotFactory.eINSTANCE.createParameter(); |
| pivotParameter.setName(name); |
| pivotParameter.setType(type); |
| return pivotParameter; |
| } |
| |
| protected Precedence createPrecedence(String name, AssociativityKind kind) { |
| Precedence pivotPrecedence = PivotFactory.eINSTANCE.createPrecedence(); |
| pivotPrecedence.setName(name); |
| pivotPrecedence.setAssociativity(kind); |
| return pivotPrecedence; |
| } |
| |
| protected PrimitiveType createPrimitiveType(String name) { |
| PrimitiveType pivotType = PivotFactory.eINSTANCE.createPrimitiveType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected Property createProperty(String name, Type type) { |
| Property pivotProperty = PivotFactory.eINSTANCE.createProperty(); |
| pivotProperty.setName(name); |
| pivotProperty.setType(type); |
| return pivotProperty; |
| } |
| |
| protected SelfType createSelfType(String name) { |
| SelfType pivotType = PivotFactory.eINSTANCE.createSelfType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected SequenceType createSequenceType(String name) { |
| SequenceType pivotType = PivotFactory.eINSTANCE.createSequenceType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected SetType createSetType(String name) { |
| SetType pivotType = PivotFactory.eINSTANCE.createSetType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected TemplateBinding createTemplateBinding(TemplateSignature templateSignature, TemplateParameterSubstitution... templateParameterSubstitutions) { |
| TemplateBinding pivotTemplateBinding = PivotFactory.eINSTANCE.createTemplateBinding(); |
| List<TemplateParameterSubstitution> parameterSubstitutions = pivotTemplateBinding.getParameterSubstitutions(); |
| for (TemplateParameterSubstitution templateParameterSubstitution : templateParameterSubstitutions) { |
| parameterSubstitutions.add(templateParameterSubstitution); |
| } |
| pivotTemplateBinding.setSignature(templateSignature); |
| return pivotTemplateBinding; |
| } |
| |
| protected TemplateParameterSubstitution createTemplateParameterSubstitution(TemplateParameter formal, ParameterableElement actual) { |
| TemplateParameterSubstitution pivotTemplateParameterSubstitution = PivotFactory.eINSTANCE.createTemplateParameterSubstitution(); |
| pivotTemplateParameterSubstitution.setFormal(formal); |
| pivotTemplateParameterSubstitution.setActual(actual); |
| return pivotTemplateParameterSubstitution; |
| } |
| |
| protected TemplateSignature createTemplateSignature(TemplateableElement templateableElement, TemplateParameter... templateParameters) { |
| TemplateSignature pivotTemplateSignature = PivotFactory.eINSTANCE.createTemplateSignature(); |
| List<TemplateParameter> parameters = pivotTemplateSignature.getOwnedParameters(); |
| for (TemplateParameter templateParameter : templateParameters) { |
| parameters.add(templateParameter); |
| } |
| pivotTemplateSignature.setTemplate(templateableElement); |
| return pivotTemplateSignature; |
| } |
| |
| protected TupleType createTupleType(String name, Property... properties) { |
| TupleType pivotType = PivotFactory.eINSTANCE.createTupleType(); |
| pivotType.setName(name); |
| List<Property> ownedProperties = pivotType.getOwnedAttributes(); |
| for (Property property : properties) { |
| ownedProperties.add(property); |
| } |
| return pivotType; |
| } |
| |
| protected TypeTemplateParameter createTypeTemplateParameter(Type type) { |
| TypeTemplateParameter pivotTypeTemplateParameter = PivotFactory.eINSTANCE.createTypeTemplateParameter(); |
| pivotTypeTemplateParameter.setOwnedParameteredElement(type); |
| return pivotTypeTemplateParameter; |
| } |
| |
| protected VoidType createVoidType(String name) { |
| VoidType pivotType = PivotFactory.eINSTANCE.createVoidType(); |
| pivotType.setName(name); |
| return pivotType; |
| } |
| |
| protected void installComment(Element element, String body) { |
| Comment pivotComment = PivotFactory.eINSTANCE.createComment(); |
| pivotComment.setBody(body); |
| element.getOwnedComments().add(pivotComment); |
| } |
| } |