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

tech.jhipster.lite.module.domain.javaproperties.JHipsterModuleSpringFactories Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package tech.jhipster.lite.module.domain.javaproperties;

import java.util.*;
import tech.jhipster.lite.module.domain.JHipsterModule.JHipsterModuleBuilder;
import tech.jhipster.lite.shared.collection.domain.JHipsterCollections;
import tech.jhipster.lite.shared.error.domain.Assert;

public final class JHipsterModuleSpringFactories {

  private final Map factories;

  private JHipsterModuleSpringFactories(JHipsterModuleSpringFactoriesBuilder builder) {
    factories = JHipsterCollections.immutable(builder.factories);
  }

  public static JHipsterModuleSpringFactoriesBuilder builder(JHipsterModuleBuilder module) {
    return new JHipsterModuleSpringFactoriesBuilder(module);
  }

  public Map factories() {
    return factories;
  }

  public static final class JHipsterModuleSpringFactoriesBuilder {

    private final JHipsterModuleBuilder module;
    private final Map factories = new HashMap<>();

    private JHipsterModuleSpringFactoriesBuilder(JHipsterModuleBuilder module) {
      Assert.notNull("module", module);

      this.module = module;
    }

    public JHipsterModuleSpringFactoriesBuilder append(PropertyKey key, PropertyValue value) {
      Assert.notNull("key", key);
      Assert.notNull("value", value);

      factories.merge(key, value, PropertyValue::merge);

      return this;
    }

    public JHipsterModuleBuilder and() {
      return module;
    }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy