All Downloads are FREE. Search and download functionalities are using the official Maven repository.

us.ihmc.simulationconstructionset.dataBuffer.DataBufferTools Maven / Gradle / Ivy

There is a newer version: 0.25.2
Show newest version
package us.ihmc.simulationconstructionset.dataBuffer;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

import us.ihmc.simulationconstructionset.gui.config.VarGroup;
import us.ihmc.simulationconstructionset.gui.config.VarGroupList;
import us.ihmc.yoVariables.buffer.YoBuffer;
import us.ihmc.yoVariables.tools.YoSearchTools;
import us.ihmc.yoVariables.variable.YoVariable;

public class DataBufferTools
{
   public static List getVarsFromGroup(YoBuffer dataBuffer, String varGroupName, VarGroupList varGroupList)
   {
      if (varGroupName.equals("all"))
      {
         return dataBuffer.getVariables();
      }

      VarGroup varGroup = varGroupList.getVarGroup(varGroupName);
      String[] varNames = varGroup.getVars();
      String[] regularExpressions = varGroup.getRegularExpressions();
      List variables = new ArrayList();
      if (varNames != null)
         Stream.of(varNames).flatMap(varName -> dataBuffer.findVariables(varName).stream()).forEach(variables::add);
      if (regularExpressions != null)
         variables.addAll(dataBuffer.filterVariables(YoSearchTools.regularExpressionFilter(regularExpressions)));
      return variables;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy