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

io.kroxylicious.proxy.config.ConfigurationFluent Maven / Gradle / Ivy

The newest version!
package io.kroxylicious.proxy.config;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.lang.SuppressWarnings;
import io.kroxylicious.proxy.config.model.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.kroxylicious.proxy.config.admin.AdminHttpConfiguration;
import io.kroxylicious.proxy.filter.FilterFactory;
import io.kroxylicious.proxy.plugin.PluginImplConfig;
import java.util.LinkedHashMap;
import java.util.function.Predicate;
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
import io.kroxylicious.proxy.config.admin.AdminHttpConfigurationBuilder;
import io.kroxylicious.proxy.config.model.BaseFluent;
import io.kroxylicious.proxy.config.admin.AdminHttpConfigurationFluent;
import java.util.List;
import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import java.util.Collection;
import java.lang.Object;
import io.kroxylicious.proxy.plugin.PluginImplName;
import java.util.Map;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class ConfigurationFluent> extends BaseFluent{
  public ConfigurationFluent() {
  }
  
  public ConfigurationFluent(Configuration instance) {
    this.copyInstance(instance);
  }
  private AdminHttpConfigurationBuilder adminHttp;
  private Map virtualClusters;
  private List filters;
  private List micrometer;
  private boolean useIoUring;
  private Optional> development = Optional.empty();
  
  protected void copyInstance(Configuration instance) {
    if (instance != null) {
          this.withAdminHttp(instance.adminHttp());
          this.withVirtualClusters(instance.virtualClusters());
          this.withFilters(instance.filters());
          this.withMicrometer(instance.getMicrometer());
          this.withUseIoUring(instance.isUseIoUring());
          this.withDevelopment(instance.development());
        }
  }
  
  public AdminHttpConfiguration buildAdminHttp() {
    return this.adminHttp != null ? this.adminHttp.build() : null;
  }
  
  public A withAdminHttp(AdminHttpConfiguration adminHttp) {
    this._visitables.remove("adminHttp");
    if (adminHttp != null) {
        this.adminHttp = new AdminHttpConfigurationBuilder(adminHttp);
        this._visitables.get("adminHttp").add(this.adminHttp);
    } else {
        this.adminHttp = null;
        this._visitables.get("adminHttp").remove(this.adminHttp);
    }
    return (A) this;
  }
  
  public boolean hasAdminHttp() {
    return this.adminHttp != null;
  }
  
  public AdminHttpNested withNewAdminHttp() {
    return new AdminHttpNested(null);
  }
  
  public AdminHttpNested withNewAdminHttpLike(AdminHttpConfiguration item) {
    return new AdminHttpNested(item);
  }
  
  public AdminHttpNested editAdminHttp() {
    return withNewAdminHttpLike(java.util.Optional.ofNullable(buildAdminHttp()).orElse(null));
  }
  
  public AdminHttpNested editOrNewAdminHttp() {
    return withNewAdminHttpLike(java.util.Optional.ofNullable(buildAdminHttp()).orElse(new AdminHttpConfigurationBuilder().build()));
  }
  
  public AdminHttpNested editOrNewAdminHttpLike(AdminHttpConfiguration item) {
    return withNewAdminHttpLike(java.util.Optional.ofNullable(buildAdminHttp()).orElse(item));
  }
  
  public A addToVirtualClusters(String key,VirtualCluster value) {
    if(this.virtualClusters == null && key != null && value != null) { this.virtualClusters = new LinkedHashMap(); }
    if(key != null && value != null) {this.virtualClusters.put(key, value);} return (A)this;
  }
  
  public A addToVirtualClusters(Map map) {
    if(this.virtualClusters == null && map != null) { this.virtualClusters = new LinkedHashMap(); }
    if(map != null) { this.virtualClusters.putAll(map);} return (A)this;
  }
  
  public A removeFromVirtualClusters(String key) {
    if(this.virtualClusters == null) { return (A) this; }
    if(key != null && this.virtualClusters != null) {this.virtualClusters.remove(key);} return (A)this;
  }
  
  public A removeFromVirtualClusters(Map map) {
    if(this.virtualClusters == null) { return (A) this; }
    if(map != null) { for(Object key : map.keySet()) {if (this.virtualClusters != null){this.virtualClusters.remove(key);}}} return (A)this;
  }
  
  public Map getVirtualClusters() {
    return this.virtualClusters;
  }
  
  public A withVirtualClusters(Map virtualClusters) {
    if (virtualClusters == null) {
      this.virtualClusters = null;
    } else {
      this.virtualClusters = new LinkedHashMap(virtualClusters);
    }
    return (A) this;
  }
  
  public boolean hasVirtualClusters() {
    return this.virtualClusters != null;
  }
  
  public A addToFilters(int index,FilterDefinition item) {
    if (this.filters == null) {this.filters = new ArrayList();}
    this.filters.add(index, item);
    return (A)this;
  }
  
  public A setToFilters(int index,FilterDefinition item) {
    if (this.filters == null) {this.filters = new ArrayList();}
    this.filters.set(index, item); return (A)this;
  }
  
  public A addToFilters(io.kroxylicious.proxy.config.FilterDefinition... items) {
    if (this.filters == null) {this.filters = new ArrayList();}
    for (FilterDefinition item : items) {this.filters.add(item);} return (A)this;
  }
  
  public A addAllToFilters(Collection items) {
    if (this.filters == null) {this.filters = new ArrayList();}
    for (FilterDefinition item : items) {this.filters.add(item);} return (A)this;
  }
  
  public A removeFromFilters(io.kroxylicious.proxy.config.FilterDefinition... items) {
    if (this.filters == null) return (A)this;
    for (FilterDefinition item : items) { this.filters.remove(item);} return (A)this;
  }
  
  public A removeAllFromFilters(Collection items) {
    if (this.filters == null) return (A)this;
    for (FilterDefinition item : items) { this.filters.remove(item);} return (A)this;
  }
  
  public List getFilters() {
    return this.filters;
  }
  
  public FilterDefinition getFilter(int index) {
    return this.filters.get(index);
  }
  
  public FilterDefinition getFirstFilter() {
    return this.filters.get(0);
  }
  
  public FilterDefinition getLastFilter() {
    return this.filters.get(filters.size() - 1);
  }
  
  public FilterDefinition getMatchingFilter(Predicate predicate) {
      for (FilterDefinition item : filters) {
        if (predicate.test(item)) {
          return item;
        }
      }
      return null;
  }
  
  public boolean hasMatchingFilter(Predicate predicate) {
      for (FilterDefinition item : filters) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withFilters(List filters) {
    if (filters != null) {
        this.filters = new ArrayList();
        for (FilterDefinition item : filters) {
          this.addToFilters(item);
        }
    } else {
      this.filters = null;
    }
    return (A) this;
  }
  
  public A withFilters(io.kroxylicious.proxy.config.FilterDefinition... filters) {
    if (this.filters != null) {
        this.filters.clear();
        _visitables.remove("filters");
    }
    if (filters != null) {
      for (FilterDefinition item : filters) {
        this.addToFilters(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasFilters() {
    return this.filters != null && !this.filters.isEmpty();
  }
  
  public A addNewFilter(String type,Object config) {
    return (A)addToFilters(new FilterDefinition(type, config));
  }
  
  public A addToMicrometer(int index,MicrometerDefinition item) {
    if (this.micrometer == null) {this.micrometer = new ArrayList();}
    this.micrometer.add(index, item);
    return (A)this;
  }
  
  public A setToMicrometer(int index,MicrometerDefinition item) {
    if (this.micrometer == null) {this.micrometer = new ArrayList();}
    this.micrometer.set(index, item); return (A)this;
  }
  
  public A addToMicrometer(io.kroxylicious.proxy.config.MicrometerDefinition... items) {
    if (this.micrometer == null) {this.micrometer = new ArrayList();}
    for (MicrometerDefinition item : items) {this.micrometer.add(item);} return (A)this;
  }
  
  public A addAllToMicrometer(Collection items) {
    if (this.micrometer == null) {this.micrometer = new ArrayList();}
    for (MicrometerDefinition item : items) {this.micrometer.add(item);} return (A)this;
  }
  
  public A removeFromMicrometer(io.kroxylicious.proxy.config.MicrometerDefinition... items) {
    if (this.micrometer == null) return (A)this;
    for (MicrometerDefinition item : items) { this.micrometer.remove(item);} return (A)this;
  }
  
  public A removeAllFromMicrometer(Collection items) {
    if (this.micrometer == null) return (A)this;
    for (MicrometerDefinition item : items) { this.micrometer.remove(item);} return (A)this;
  }
  
  public List getMicrometer() {
    return this.micrometer;
  }
  
  public MicrometerDefinition getMicrometer(int index) {
    return this.micrometer.get(index);
  }
  
  public MicrometerDefinition getFirstMicrometer() {
    return this.micrometer.get(0);
  }
  
  public MicrometerDefinition getLastMicrometer() {
    return this.micrometer.get(micrometer.size() - 1);
  }
  
  public MicrometerDefinition getMatchingMicrometer(Predicate predicate) {
      for (MicrometerDefinition item : micrometer) {
        if (predicate.test(item)) {
          return item;
        }
      }
      return null;
  }
  
  public boolean hasMatchingMicrometer(Predicate predicate) {
      for (MicrometerDefinition item : micrometer) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withMicrometer(List micrometer) {
    if (micrometer != null) {
        this.micrometer = new ArrayList();
        for (MicrometerDefinition item : micrometer) {
          this.addToMicrometer(item);
        }
    } else {
      this.micrometer = null;
    }
    return (A) this;
  }
  
  public A withMicrometer(io.kroxylicious.proxy.config.MicrometerDefinition... micrometer) {
    if (this.micrometer != null) {
        this.micrometer.clear();
        _visitables.remove("micrometer");
    }
    if (micrometer != null) {
      for (MicrometerDefinition item : micrometer) {
        this.addToMicrometer(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasMicrometer() {
    return this.micrometer != null && !this.micrometer.isEmpty();
  }
  
  public A addNewMicrometer(String type,Object config) {
    return (A)addToMicrometer(new MicrometerDefinition(type, config));
  }
  
  public boolean isUseIoUring() {
    return this.useIoUring;
  }
  
  public A withUseIoUring(boolean useIoUring) {
    this.useIoUring = useIoUring;
    return (A) this;
  }
  
  public boolean hasUseIoUring() {
    return true;
  }
  
  public A withDevelopment(Optional> development) {
    if (development == null || !development.isPresent()) {
      this.development = java.util.Optional.empty();
    } else {
      this.development = development;
    }
    return (A) this;
  }
  
  public A withDevelopment(Map development) {
    if (development == null) { this.development = Optional.empty(); } else { this.development = Optional.of(development); } return (A) this;
  }
  
  public Optional> getDevelopment() {
    return this.development;
  }
  
  public boolean hasDevelopment() {
    return this.development != null && this.development.isPresent();
  }
  
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;
    ConfigurationFluent that = (ConfigurationFluent) o;
    if (!java.util.Objects.equals(adminHttp, that.adminHttp)) return false;
    if (!java.util.Objects.equals(virtualClusters, that.virtualClusters)) return false;
    if (!java.util.Objects.equals(filters, that.filters)) return false;
    if (!java.util.Objects.equals(micrometer, that.micrometer)) return false;
    if (useIoUring != that.useIoUring) return false;
    if (!java.util.Objects.equals(development, that.development)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(adminHttp,  virtualClusters,  filters,  micrometer,  useIoUring,  development,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (adminHttp != null) { sb.append("adminHttp:"); sb.append(adminHttp + ","); }
    if (virtualClusters != null && !virtualClusters.isEmpty()) { sb.append("virtualClusters:"); sb.append(virtualClusters + ","); }
    if (filters != null && !filters.isEmpty()) { sb.append("filters:"); sb.append(filters + ","); }
    if (micrometer != null && !micrometer.isEmpty()) { sb.append("micrometer:"); sb.append(micrometer + ","); }
    sb.append("useIoUring:"); sb.append(useIoUring + ",");
    if (development != null) { sb.append("development:"); sb.append(development); }
    sb.append("}");
    return sb.toString();
  }
  
  public A withUseIoUring() {
    return withUseIoUring(true);
  }
  public class AdminHttpNested extends AdminHttpConfigurationFluent> implements Nested{
    AdminHttpNested(AdminHttpConfiguration item) {
      this.builder = new AdminHttpConfigurationBuilder(this, item);
    }
    AdminHttpConfigurationBuilder builder;
    
    public N and() {
      return (N) ConfigurationFluent.this.withAdminHttp(builder.build());
    }
    
    public N endAdminHttp() {
      return and();
    }
    
  
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy