package org.apache.logging.log4j.core.config.plugins.visitors;

import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.Node;
import org.apache.logging.log4j.core.config.plugins.PluginValue;

public class PluginValueVisitor extends AbstractPluginVisitor<PluginValue> {
   public PluginValueVisitor() {
      super(PluginValue.class);
   }

   public Object visit(Configuration configuration, Node node, LogEvent event, StringBuilder log) {
      String name = ((PluginValue)this.annotation).value();
      String rawValue = node.getValue() != null ? node.getValue() : removeAttributeValue(node.getAttributes(), "value", new String[0]);
      String value = this.substitutor.replace(event, rawValue);
      log.append(name).append("=\"").append(value).append('"');
      return value;
   }
}
