| /** |
| * ******************************************************************************* |
| * Copyright (c) 2020 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.commons.m2t.transformers.sw |
| |
| import com.google.inject.Inject |
| import com.google.inject.Singleton |
| import java.util.ArrayList |
| import java.util.List |
| import org.eclipse.app4mc.amalthea.model.Ticks |
| import org.eclipse.app4mc.slg.commons.m2t.transformers.SLGBaseTransformer |
| import org.eclipse.app4mc.slg.commons.m2t.generators.TicksTranslationUnit |
| import org.eclipse.app4mc.transformation.util.OutputBuffer |
| |
| @Singleton |
| class TicksTransformer extends SLGBaseTransformer { |
| |
| @Inject OutputBuffer outputBuffer |
| @Inject TicksUtilsTransformer ticksUtilsTransformer |
| |
| def TicksTranslationUnit transform(Ticks ticks) { |
| if (ticks.^default !== null) { |
| val tuTicks = ticksUtilsTransformer.generate(ticks.^default) |
| return new TicksTranslationUnit(outputBuffer, tuTicks, ticks, "default", ticks.^default) |
| } |
| } |
| |
| def List<TicksTranslationUnit> transformAllItems(Ticks ticks) { |
| |
| val List<TicksTranslationUnit> result = new ArrayList |
| |
| val defaultTicks = ticks.^default |
| |
| if (defaultTicks !== null) { |
| val tuTicks = ticksUtilsTransformer.generate(ticks.^default) |
| result.add(new TicksTranslationUnit(outputBuffer, tuTicks, ticks, "default", ticks.^default)) |
| } |
| |
| val puExtendedMap = ticks?.extended |
| |
| for (puDefinition : puExtendedMap.keySet) { |
| val ticksValue = puExtendedMap.get(puDefinition) |
| if (puDefinition !== null && ticksValue !== null) { |
| |
| val tuTicks = ticksUtilsTransformer.generate(ticksValue) |
| result.add(new TicksTranslationUnit(outputBuffer, tuTicks, ticks, puDefinition.name, ticksValue)) |
| |
| } |
| } |
| |
| return result |
| } |
| |
| } |