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

io.hyperfoil.hotrod.parser.HotRodClusterParser Maven / Gradle / Ivy

There is a newer version: 0.26
Show newest version
package io.hyperfoil.hotrod.parser;


import org.yaml.snakeyaml.events.ScalarEvent;

import io.hyperfoil.core.parser.AbstractParser;
import io.hyperfoil.core.parser.Context;
import io.hyperfoil.core.parser.Parser;
import io.hyperfoil.core.parser.ParserException;
import io.hyperfoil.core.parser.PropertyParser;
import io.hyperfoil.hotrod.config.HotRodClusterBuilder;

public class HotRodClusterParser extends AbstractParser {
   static HotRodClusterParser INSTANCE = new HotRodClusterParser();

   public HotRodClusterParser() {
      register("uri", new PropertyParser.String<>(HotRodClusterBuilder::uri));
      register("caches", new CachesParser());
   }

   @Override
   public void parse(Context ctx, HotRodClusterBuilder target) throws ParserException {
      callSubBuilders(ctx, target);
   }

   private static class CachesParser implements Parser {
      @Override
      public void parse(Context ctx, HotRodClusterBuilder target) throws ParserException {
         ctx.parseList(target, this::parseItem);
      }

      private void parseItem(Context context, HotRodClusterBuilder builder) throws ParserException {
         ScalarEvent event = context.expectEvent(ScalarEvent.class);
         builder.addCache(event.getValue());
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy