//============================================================================== // // Copyright (c) 2015- // Authors: // * Joachim Klein (TU Dresden) // * Steffen Märcker (TU Dresden) // //------------------------------------------------------------------------------ // // This file is part of PRISM. // // PRISM is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // PRISM is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with PRISM; if not, write to the Free Software Foundation, // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //============================================================================== package explicit; import prism.PrismException; /** * Combines two (compatible) ModelTransformation. *
* The inner transformation is applied first, with the result * serving as the input for the second, outer transformation. * * @param The input type for the inner transformation * @param The output type for the inner and the input type for the outer transformation * @param The output type for the outer transformation */ public class ModelTransformationNested implements ModelTransformation { protected final ModelTransformation innerTransformation; protected final ModelTransformation outerTransformation; public ModelTransformationNested(final ModelTransformation inner, final ModelTransformation outer) { if (inner.getTransformedModel() != outer.getOriginalModel()) { throw new IllegalArgumentException("Trying to nest unrelated ModelTransformations."); } this.innerTransformation = inner; this.outerTransformation = outer; } @Override public OriginalModel getOriginalModel() { return innerTransformation.getOriginalModel(); } @Override public TransformedModel getTransformedModel() { return outerTransformation.getTransformedModel(); } @Override public StateValues projectToOriginalModel(final StateValues svTransformedModel) throws PrismException { // First, project the StateValues to the intermediate model. StateValues svIntermediate = outerTransformation.projectToOriginalModel(svTransformedModel); // Second, project them to the original model return innerTransformation.projectToOriginalModel(svIntermediate); } }