com.ecfeed.core.model.GlobalParameterNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ecfeed.junit Show documentation
Show all versions of ecfeed.junit Show documentation
An open library used to connect to the ecFeed service. It can be also used as a standalone testing tool. It is integrated with Junit5 and generates a stream of test cases using a selected algorithm (e.g. Cartesian, N-Wise). There are no limitations associated with the off-line version but the user cannot access the on-line computation servers and the model database.
The newest version!
/*******************************************************************************
*
* Copyright (c) 2016 ecFeed AS.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
package com.ecfeed.core.model;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class GlobalParameterNode extends AbstractParameterNode {
public GlobalParameterNode(String name, IModelChangeRegistrator modelChangeRegistrator, String type) {
super(name, modelChangeRegistrator, type);
}
//copy constructor creating a global parameter instance from other types, eg. MethodParameterNode
public GlobalParameterNode(AbstractParameterNode source) {
this(source.getFullName(), source.getModelChangeRegistrator(), source.getType());
for(ChoiceNode choice : source.getChoices()){
addChoice(choice.makeClone());
}
}
@Override
public GlobalParameterNode makeClone() {
GlobalParameterNode copy = new GlobalParameterNode(getFullName(), getModelChangeRegistrator(), getType());
copy.setProperties(getProperties());
for(ChoiceNode choice : getChoices()){
copy.addChoice(choice.makeClone());
}
return copy;
}
@Override
public List getMethods() {
GlobalParametersParentNode globalParametersParentNode = getParametersParent();
if (globalParametersParentNode == null) {
return null;
}
return globalParametersParentNode.getMethods(getParameter());
}
public List getLinkers(){
List result = new ArrayList<>();
for(MethodNode method : getMethods()){
result.addAll(method.getLinkers(this));
}
return result;
}
@Override
public Object accept(IParameterVisitor visitor) throws Exception {
return visitor.visit(this);
}
@Override
public Object accept(IModelVisitor visitor) throws Exception {
return visitor.visit(this);
}
@Override
public Object accept(IChoicesParentVisitor visitor) throws Exception{
return visitor.visit(this);
}
public String getQualifiedName() {
if(getParent() == getRoot() || getParent() == null){
return getFullName();
}
return getParent().getFullName() + ":" + getFullName();
}
@Override
public String toString(){
return getFullName() + ": " + getType();
}
@Override
public GlobalParametersParentNode getParametersParent(){
return (GlobalParametersParentNode)getParent();
}
@Override
public Set getMentioningConstraints() {
Set result = new HashSet();
for(MethodParameterNode parameter : getLinkers()){
result.addAll(parameter.getMentioningConstraints());
}
return result;
}
@Override
public Set getMentioningConstraints(String label){
Set result = new HashSet();
for(MethodParameterNode parameter : getLinkers()){
for(ConstraintNode constraint : parameter.getMentioningConstraints()){
if(constraint.mentions(parameter, label)){
result.add(constraint);
}
}
}
return result;
}
public List getChoicesCopy() {
List copy = new ArrayList<>();
for(ChoiceNode choice : getChoices()){
copy.add(choice.makeClone());
}
return copy;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy