blob: 419af5e3b92e1c6ec7a2bfc5512e03f1b41ca05a [file] [log] [blame]
/**
* Copyright (c) 2020-2021 Robert Bosch GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial API and implementation
*/
package org.eclipse.app4mc.slg.customization;
import java.util.ArrayList;
import java.util.HashMap;
import org.eclipse.app4mc.amalthea.model.Runnable;
import org.eclipse.app4mc.slg.commons.m2t.generators.RunnableTranslationUnit;
import org.eclipse.app4mc.slg.commons.m2t.transformers.ActivityGraphItemTransformer;
import org.eclipse.app4mc.slg.commons.m2t.transformers.RunnableTransformer;
import org.eclipse.app4mc.transformation.util.OutputBuffer;
import org.eclipse.xtext.xbase.lib.CollectionLiterals;
import com.google.inject.Inject;
public class CustomRunnableTransformer extends RunnableTransformer {
@Inject private OutputBuffer outputBuffer;
@Inject private ActivityGraphItemTransformer psCallGraphItemTransformer;
@Override
public RunnableTranslationUnit transform(final Runnable runnable) {
final ArrayList<?> key = CollectionLiterals.newArrayList(runnable);
final CustomRunnableTranslationUnit result;
synchronized (_createCache_transform) {
if (_createCache_transform.containsKey(key)) {
return _createCache_transform.get(key);
}
CustomRunnableTranslationUnit tu = new CustomRunnableTranslationUnit(
this.outputBuffer, this.psCallGraphItemTransformer, runnable);
result = tu;
_createCache_transform.put(key, result);
}
doTransform(result, runnable);
return result;
}
private final HashMap<ArrayList<?>, RunnableTranslationUnit> _createCache_transform = CollectionLiterals
.newHashMap();
private void doTransform(final CustomRunnableTranslationUnit tu, final Runnable runnable) {
}
}