blob: f39a33c3ba5fbe7a2bc1d3c2cabf11cb41495ac7 [file] [log] [blame]
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.moka.fuml.standardlibrary.library.list;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.papyrus.moka.fuml.commonbehavior.IParameterValue;
import org.eclipse.papyrus.moka.fuml.commonbehavior.OpaqueBehaviorExecution;
import org.eclipse.papyrus.moka.fuml.debug.Debug;
import org.eclipse.papyrus.moka.fuml.simpleclassifiers.IValue;
import org.eclipse.papyrus.moka.fuml.simpleclassifiers.IntegerValue;
import org.eclipse.uml2.uml.PrimitiveType;
public class ListSize extends OpaqueBehaviorExecution {
@Override
public void doBody(List<IParameterValue> inputParameters, List<IParameterValue> outputParameters) {
try {
List<IValue> list = inputParameters.get(0).getValues();
IntegerValue result = new IntegerValue();
result.value = list.size();
result.type = (PrimitiveType) this.locus.getFactory().getBuiltInType("Integer"); // ADDED
List<IValue> outputs = new ArrayList<IValue>();
outputs.add(result);
outputParameters.get(0).setValues(outputs);
} catch (Exception e) {
Debug.println("An error occured during the execution of ListSize " + e.getMessage());
}
}
@Override
public IValue new_() {
return new ListSize();
}
}