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

com.yahoo.jdisc.http.ServletPathsConfig Maven / Gradle / Ivy

/**
 * This file is generated from a config definition file.
 * ------------   D O   N O T   E D I T !   ------------
 */

package com.yahoo.jdisc.http;

import java.util.*;
import java.io.File;
import java.nio.file.Path;
import com.yahoo.config.*;

/**
 * This class represents the root node of servlet-paths
 *
 * Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
 */
public final class ServletPathsConfig extends ConfigInstance {

  public final static String CONFIG_DEF_MD5 = "c9f25f7087ba57a511afbffe7acbac46";
  public final static String CONFIG_DEF_NAME = "servlet-paths";
  public final static String CONFIG_DEF_NAMESPACE = "jdisc.http";
  public final static String CONFIG_DEF_VERSION = "";
  public final static String[] CONFIG_DEF_SCHEMA = {
    "namespace=jdisc.http",
    "servlets{}.path string"
  };

  public static String getDefMd5()       { return CONFIG_DEF_MD5; }
  public static String getDefName()      { return CONFIG_DEF_NAME; }
  public static String getDefNamespace() { return CONFIG_DEF_NAMESPACE; }
  public static String getDefVersion()   { return CONFIG_DEF_VERSION; }

  public interface Producer extends ConfigInstance.Producer {
    void getConfig(Builder builder);
  }

  public static class Builder implements ConfigInstance.Builder {
    private Set __uninitialized = new HashSet();

    public Map servlets = new LinkedHashMap<>();

    public Builder() { }

    public Builder(ServletPathsConfig config) {
      for (Map.Entry __entry : config.servlets().entrySet()) {
        servlets(__entry.getKey(), new Servlets.Builder(__entry.getValue()));
      }
    }

    private Builder override(Builder __superior) {
      servlets(__superior.servlets);
      return this;
    }

    public Builder servlets(String __key, Servlets.Builder __value) {
      servlets.put(__key, __value);
      return this;
    }

    public Builder servlets(Map __values) {
      servlets.putAll(__values);
      return this;
    }

    private boolean _applyOnRestart = false;

    @java.lang.Override
    public final boolean dispatchGetConfig(ConfigInstance.Producer producer) {
      if (producer instanceof Producer) {
        ((Producer)producer).getConfig(this);
        return true;
      }
      return false;
    }

    @java.lang.Override
    public final String getDefMd5() { return CONFIG_DEF_MD5; }

    @java.lang.Override
    public final String getDefName() { return CONFIG_DEF_NAME; }

    @java.lang.Override
    public final String getDefNamespace() { return CONFIG_DEF_NAMESPACE; }

    @java.lang.Override
    public final boolean getApplyOnRestart() { return _applyOnRestart; }

    @java.lang.Override
    public final void setApplyOnRestart(boolean applyOnRestart) { _applyOnRestart = applyOnRestart; }

    public ServletPathsConfig build() {
      return new ServletPathsConfig(this);
    }

  }

  private final Map servlets;

  public ServletPathsConfig(Builder builder) {
    this(builder, true);
  }

  private ServletPathsConfig(Builder builder, boolean throwIfUninitialized) {
    if (throwIfUninitialized && ! builder.__uninitialized.isEmpty())
      throw new IllegalArgumentException("The following builder parameters for " +
          "servlet-paths must be initialized: " + builder.__uninitialized);

    servlets = Servlets.createMap(builder.servlets);
  }

  /**
   * @return servlet-paths.servlets{}
   */
  public Map servlets() {
    return Collections.unmodifiableMap(servlets);
  }

  /**
   * @param key the key of the value to return
   * @return servlet-paths.servlets{}
   */
  public Servlets servlets(String key) {
    return servlets.get(key);
  }

  private ChangesRequiringRestart getChangesRequiringRestart(ServletPathsConfig newConfig) {
    ChangesRequiringRestart changes = new ChangesRequiringRestart("servlet-paths");
    return changes;
  }

  private static boolean containsFieldsFlaggedWithRestart() {
    return false;
  }

  /**
   * This class represents servlet-paths.servlets{}
   */
  public final static class Servlets extends InnerNode { 

    public static class Builder implements ConfigBuilder {
      private Set __uninitialized = new HashSet(Arrays.asList(
        "path"
        ));

      private String path = null;

      public Builder() { }

      public Builder(Servlets config) {
        path(config.path());
      }

      private Builder override(Builder __superior) {
        if (__superior.path != null)
          path(__superior.path);
        return this;
      }

      public Builder path(String __value) {
      if (__value == null) throw new IllegalArgumentException("Null value is not allowed.");
        path = __value;
        __uninitialized.remove("path");
        return this;
      }


      public Servlets build() {
        return new Servlets(this);
      }

    }

    // path by servlet componentId
    private final StringNode path;

    public Servlets(Builder builder) {
      this(builder, true);
    }

    private Servlets(Builder builder, boolean throwIfUninitialized) {
      if (throwIfUninitialized && ! builder.__uninitialized.isEmpty())
        throw new IllegalArgumentException("The following builder parameters for " +
            "servlet-paths.servlets{} must be initialized: " + builder.__uninitialized);

      path = (builder.path == null) ?
          new StringNode() : new StringNode(builder.path);
    }

    /**
     * @return servlet-paths.servlets{}.path
     */
    public String path() {
      return path.value();
    }

    private ChangesRequiringRestart getChangesRequiringRestart(Servlets newConfig) {
      ChangesRequiringRestart changes = new ChangesRequiringRestart("servlets");
      return changes;
    }

    private static Map createMap(Map builders) {
      Map ret = new LinkedHashMap<>();
      for(String key : builders.keySet()) {
        ret.put(key, new Servlets(builders.get(key)));
      }
      return Collections.unmodifiableMap(ret);
    }
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy