Skip to content
Snippets Groups Projects
Commit f943b129 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

added base transformation contexts

parent b1c1770a
No related branches found
No related tags found
No related merge requests found
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.extension.base;
import org.fortiss.tooling.kernel.extension.data.ITransformationContext;
/**
* Base implementation of {@link ITransformationContext}, which stores a
* reference to another context.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 662BCDD98432EED08BA052803173A5D0
*/
public abstract class TransformationContextChainBase implements
ITransformationContext {
/** Stores the chained context. */
protected final ITransformationContext chainedContext;
/** Constructor. */
public TransformationContextChainBase(ITransformationContext chainedContext) {
this.chainedContext = chainedContext;
}
/** Constructor. */
public TransformationContextChainBase() {
this(null);
}
/** Returns the next {@link ITransformationContext} in the chain. */
public ITransformationContext getNextContext() {
return chainedContext;
}
/** Finds an ITransform of the given class in the chain. */
@SuppressWarnings("unchecked")
public <T extends ITransformationContext> T findContextinChain(
Class<T> clazz) {
if (clazz.isAssignableFrom(this.getClass())) {
return (T) this;
}
if (chainedContext instanceof TransformationContextChainBase) {
return ((TransformationContextChainBase) chainedContext)
.findContextinChain(clazz);
}
return null;
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.extension.data;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.base.TransformationContextChainBase;
/**
* An {@link ITransformationContext} with an EObject context element.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 86FBA7A228E86492FB4A54CDD086CFCC
*/
public class ModelElementTransformationContext extends
TransformationContextChainBase {
/** Stores the model element. */
protected final EObject modelElement;
/** Constructor. */
public ModelElementTransformationContext(EObject modelElement,
ITransformationContext context) {
super(context);
this.modelElement = modelElement;
}
/** Constructor. */
public ModelElementTransformationContext(EObject modelElement) {
this(modelElement, null);
}
/** Returns the model element. */
public EObject getModelElement() {
return modelElement;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment