Coverage Report - com.sdmetrics.metrics.SetProcedureCompound - www.sdmetrics.com
 
Classes in this File Line Coverage Branch Coverage Complexity
SetProcedureCompound
100%
12/12
100%
2/2
2
 
 1  
 /*
 2  
  * SDMetrics Open Core for UML design measurement
 3  
  * Copyright (c) Juergen Wuest
 4  
  * To contact the author, see <http://www.sdmetrics.com/Contact.html>.
 5  
  * 
 6  
  * This file is part of the SDMetrics Open Core.
 7  
  * 
 8  
  * SDMetrics Open Core is free software: you can redistribute it and/or modify
 9  
  * it under the terms of the GNU Affero General Public License as
 10  
  * published by the Free Software Foundation, either version 3 of the
 11  
  * License, or (at your option) any later version.
 12  
     
 13  
  * SDMetrics Open Core is distributed in the hope that it will be useful,
 14  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16  
  * GNU Affero General Public License for more details.
 17  
  *
 18  
  * You should have received a copy of the GNU Affero General Public License
 19  
  * along with SDMetrics Open Core.  If not, see <http://www.gnu.org/licenses/>.
 20  
  *
 21  
  */
 22  
 package com.sdmetrics.metrics;
 23  
 
 24  
 import java.util.Collection;
 25  
 
 26  
 import com.sdmetrics.model.ModelElement;
 27  
 
 28  
 /**
 29  
  * Calculates the deprecated "compoundset" procedure for sets.
 30  
  * <p>
 31  
  * Compound sets are now just a special case of projections with "relset"
 32  
  * attribute.
 33  
  */
 34  3
 public class SetProcedureCompound extends SetProcedure {
 35  
 
 36  
         @Override
 37  
         public Collection<?> calculate(ModelElement element, Set set)
 38  
                         throws SDMetricsException {
 39  
                 // Evaluate the set expression
 40  26
                 ProcedureAttributes attributes = set.getAttributes();
 41  26
                 Variables vars = new Variables(element);
 42  51
                 Collection<ModelElement> intermediateSet = evalElementSetExpression(
 43  26
                                 element, attributes.getRequiredExpression("set"), vars);
 44  25
                 FilterAttributeProcessor fap = getFilterAttributeProcessor(attributes);
 45  50
                 SetSummationHelper summer = new SetSummationHelper(getMetricsEngine(),
 46  25
                                 set, "cum");
 47  
 
 48  
                 // Iterate over intermediate set, applying filter attributes to
 49  
                 // calculate the final result set
 50  61
                 for (ModelElement pal : fap.validIteration(intermediateSet, vars)) {
 51  11
                         summer.add(pal, vars);
 52  
                 }
 53  25
                 summer.excludeSelf(element);
 54  25
                 return summer.getResultSet();
 55  
         }
 56  
 }