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

org.interledger.link.LinkSettings Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
package org.interledger.link;

import org.immutables.value.Value;

import java.util.Map;

/**
 * Configuration information relating to a {@link Link}.
 */
public interface LinkSettings {

  static ImmutableLinkSettings.Builder builder() {
    return ImmutableLinkSettings.builder();
  }

  /**
   * The type of this ledger link.
   *
   * @return A {@link LinkType}
   */
  LinkType getLinkType();

  /**
   * Additional, custom settings that any link can define.
   *
   * @return A {@link Map} with {@link String} keys.
   */
  Map getCustomSettings();

  @Value.Immutable
  abstract class AbstractLinkSettings implements LinkSettings {

    /**
     * Additional, custom settings that any link can define. Redacted to prevent credential leakage in log files.
     *
     * @return A {@link Map} with {@link String} keys.
     */
    @Value.Redacted
    public abstract Map getCustomSettings();

    /**
     * Always normalize Link-type String values to full uppercase to avoid casing ambiguity in properties files.
     *
     * @return A {@link AbstractLinkSettings} with normalized values.
     */
    @Value.Check
    public AbstractLinkSettings normalize() {
      final String linkTypeString = this.getLinkType().value();
      if (!linkTypeString.toUpperCase().equals(linkTypeString)) {
        return ImmutableLinkSettings.builder()
            .from(this)
            .linkType(LinkType.of(linkTypeString.toUpperCase()))
            .build();
      } else {
        return this;
      }
    }

  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy