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

com.sinch.sdk.domains.sms.models.Parameters Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.sinch.sdk.domains.sms.models;

import com.sinch.sdk.core.utils.Pair;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

public class Parameters extends HashMap> {

  private static final long serialVersionUID = 1L;

  /**
   * @throws NullPointerException – if the specified map is null
   */
  public Parameters(Collection list) throws NullPointerException {
    super(list.stream().collect(Collectors.groupingBy(Parameters.Entry::getKey)));
  }

  public static class Entry {
    private final String key;
    private final Pair value;
    private final String defaultValue;

    public Entry(String key, Pair value, String defaultValue) {
      this.key = key;
      this.value = value;
      this.defaultValue = defaultValue;
    }

    public Entry(String key, Pair value) {
      this(key, value, null);
    }

    public String getKey() {
      return key;
    }

    public Pair getValue() {
      return value;
    }

    public Optional getDefaultValue() {
      return Optional.ofNullable(defaultValue);
    }

    @Override
    public String toString() {
      return "Entry{"
          + "key='"
          + key
          + '\''
          + ", value="
          + value
          + ", defaultValue="
          + defaultValue
          + '}';
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy