JGitHostConfigEntry.java

  1. /*
  2.  * Copyright (C) 2018, Thomas Wolf <thomas.wolf@paranor.ch> and others
  3.  *
  4.  * This program and the accompanying materials are made available under the
  5.  * terms of the Eclipse Distribution License v. 1.0 which is available at
  6.  * https://www.eclipse.org/org/documents/edl-v10.php.
  7.  *
  8.  * SPDX-License-Identifier: BSD-3-Clause
  9.  */
  10. package org.eclipse.jgit.internal.transport.sshd;

  11. import java.util.Collections;
  12. import java.util.List;
  13. import java.util.Map;

  14. import org.apache.sshd.client.config.hosts.HostConfigEntry;
  15. import org.eclipse.jgit.annotations.NonNull;

  16. /**
  17.  * A {@link HostConfigEntry} that provides access to the multi-valued keys as
  18.  * lists of strings. The super class treats them as single strings containing
  19.  * comma-separated lists.
  20.  */
  21. public class JGitHostConfigEntry extends HostConfigEntry {

  22.     private Map<String, List<String>> multiValuedOptions;

  23.     /**
  24.      * Sets the multi-valued options.
  25.      *
  26.      * @param options
  27.      *            to set, may be {@code null} to set an empty map
  28.      */
  29.     public void setMultiValuedOptions(Map<String, List<String>> options) {
  30.         multiValuedOptions = options;
  31.     }

  32.     /**
  33.      * Retrieves all multi-valued options.
  34.      *
  35.      * @return an unmodifiable map
  36.      */
  37.     @NonNull
  38.     public Map<String, List<String>> getMultiValuedOptions() {
  39.         Map<String, List<String>> options = multiValuedOptions;
  40.         if (options == null) {
  41.             return Collections.emptyMap();
  42.         }
  43.         return Collections.unmodifiableMap(options);
  44.     }

  45. }