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

io.hyperfoil.core.parser.VarParser Maven / Gradle / Ivy

There is a newer version: 0.27.1
Show newest version
package io.hyperfoil.core.parser;

import java.util.function.BiConsumer;

import org.yaml.snakeyaml.events.MappingEndEvent;
import org.yaml.snakeyaml.events.MappingStartEvent;
import org.yaml.snakeyaml.events.ScalarEvent;

import io.hyperfoil.api.config.ScenarioBuilder;

class VarParser implements Parser {
   private final BiConsumer consumer;

   VarParser(BiConsumer consumer) {
      this.consumer = consumer;
   }

   @Override
   public void parse(Context ctx, ScenarioBuilder target) throws ParserException {
      ctx.parseList(target, this::parseVar);
   }

   private void parseVar(Context ctx, ScenarioBuilder target) throws ParserException {
      ctx.expectEvent(MappingStartEvent.class);
      ScalarEvent event = ctx.expectEvent(ScalarEvent.class);
      consumer.accept(target, event.getValue());
      ctx.expectEvent(MappingEndEvent.class);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy