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

io.hyperfoil.api.session.ResourceUtilizer Maven / Gradle / Ivy

There is a newer version: 0.27
Show newest version
package io.hyperfoil.api.session;

import java.util.ArrayList;

import io.hyperfoil.impl.CollectingVisitor;

public interface ResourceUtilizer {
   void reserve(Session session);

   static void reserveForTesting(Session session, Object o) {
      Visitor visitor = new Visitor();
      visitor.visit(o);
      for (ResourceUtilizer ru : visitor.resourceUtilizers()) {
         ru.reserve(session);
      }
   }

   class Visitor extends CollectingVisitor {
      private final ArrayList resourceUtilizers = new ArrayList<>();

      public Visitor() {
         super(ResourceUtilizer.class);
      }

      @Override
      protected boolean process(ResourceUtilizer value) {
         resourceUtilizers.add(value);
         return true;
      }

      public ResourceUtilizer[] resourceUtilizers() {
         return resourceUtilizers.toArray(new ResourceUtilizer[0]);
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy