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

us.ihmc.scs2.definition.robot.sdf.items.SDFItem Maven / Gradle / Ivy

package us.ihmc.scs2.definition.robot.sdf.items;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public interface SDFItem
{
   String getContentAsString();

   default String format(String format, Object... args)
   {
      for (int i = 0; i < args.length; i++)
      {
         if (args[i] instanceof SDFItem)
            args[i] = ((SDFItem) args[i]).getContentAsString();
      }
      return String.format(format, args);
   }

   default String itemToString()
   {
      return getClass().getSimpleName() + ": " + getContentAsString();
   }

   List getURIHolders();

   static List combineItemURIHolders(SDFItem... sdfItems)
   {
      if (sdfItems == null || sdfItems.length == 0)
         return Collections.emptyList();

      List uriHolders = new ArrayList<>();

      for (SDFItem urdfItem : sdfItems)
      {
         if (urdfItem != null)
            uriHolders.addAll(urdfItem.getURIHolders());
      }
      return uriHolders;
   }

   @SafeVarargs
   static List combineItemListsURIHolders(List... sdfItemLists)
   {
      if (sdfItemLists == null || sdfItemLists.length == 0)
         return Collections.emptyList();

      List uriHolders = new ArrayList<>();

      for (List urdfItemList : sdfItemLists)
      {
         if (urdfItemList != null)
         {
            for (SDFItem urdfItem : urdfItemList)
            {
               if (urdfItem != null)
                  uriHolders.addAll(urdfItem.getURIHolders());
            }
         }
      }

      return uriHolders;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy