Class StringConfigSource

  • All Implemented Interfaces:
    ConfigSource

    public final class StringConfigSource
    extends java.lang.Object
    implements ConfigSource
    Load a config source from a String. The string must be in the format provided, so if a property file it would be db.port = 1234 db.password = password dp.user = notroot

    If the format is json the string would be { db { "port" = 1234 "password" = "password" "user" = "notroot" }. }

    A format for the data in the string must also be provided.

    • Constructor Summary

      Constructors 
      Constructor Description
      StringConfigSource​(java.lang.String config, java.lang.String format)
      Create a Configuration from a provided string.
      StringConfigSource​(java.lang.String config, java.lang.String format, Tags tags)
      Create a Configuration from a provided string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.lang.String format()
      The format of the config source, for example this can be envVars, the extension of a file (properties, json, ect).
      Tags getTags()
      A source can have a set of tags that apply to all nodes in the source.
      int hashCode()  
      boolean hasList()
      If this config source provides a list of config values.
      boolean hasStream()
      If this config source has a stream to load from.
      java.util.UUID id()
      Id that represents this source as unique.
      java.util.List<Pair<java.lang.String,​java.lang.String>> loadList()
      provides a list of config values.
      java.io.InputStream loadStream()
      If this config source has a stream, this will return the stream of data.
      java.lang.String name()
      human-readable name for logging.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringConfigSource

        public StringConfigSource​(java.lang.String config,
                                  java.lang.String format)
                           throws GestaltException
        Create a Configuration from a provided string. Must alos provide the format.
        Parameters:
        config - config as a string.
        format - format for the string.
        Throws:
        GestaltException - any exception
      • StringConfigSource

        public StringConfigSource​(java.lang.String config,
                                  java.lang.String format,
                                  Tags tags)
                           throws GestaltException
        Create a Configuration from a provided string. Must alos provide the format.
        Parameters:
        config - config as a string.
        format - format for the string.
        tags - tags associated with this source
        Throws:
        GestaltException - any exception
    • Method Detail

      • hasStream

        public boolean hasStream()
        Description copied from interface: ConfigSource
        If this config source has a stream to load from.
        Specified by:
        hasStream in interface ConfigSource
        Returns:
        if this config source has a stream to load from
      • loadStream

        public java.io.InputStream loadStream()
        Description copied from interface: ConfigSource
        If this config source has a stream, this will return the stream of data. Or if not supported it will throw an exception.
        Specified by:
        loadStream in interface ConfigSource
        Returns:
        input stream of data
      • hasList

        public boolean hasList()
        Description copied from interface: ConfigSource
        If this config source provides a list of config values.
        Specified by:
        hasList in interface ConfigSource
        Returns:
        if this config source provides a list of config values
      • loadList

        public java.util.List<Pair<java.lang.String,​java.lang.String>> loadList()
                                                                               throws GestaltException
        Description copied from interface: ConfigSource
        provides a list of config values.
        Specified by:
        loadList in interface ConfigSource
        Returns:
        provides a list of config values
        Throws:
        GestaltException - if there are any IO or if this is an unsupported operation
      • format

        public java.lang.String format()
        Description copied from interface: ConfigSource
        The format of the config source, for example this can be envVars, the extension of a file (properties, json, ect).
        Specified by:
        format in interface ConfigSource
        Returns:
        The format of the config source
      • name

        public java.lang.String name()
        Description copied from interface: ConfigSource
        human-readable name for logging.
        Specified by:
        name in interface ConfigSource
        Returns:
        human-readable name for logging.
      • id

        public java.util.UUID id()
        Description copied from interface: ConfigSource
        Id that represents this source as unique.
        Specified by:
        id in interface ConfigSource
        Returns:
        id
      • getTags

        public Tags getTags()
        Description copied from interface: ConfigSource
        A source can have a set of tags that apply to all nodes in the source.
        Specified by:
        getTags in interface ConfigSource
        Returns:
        tags assigned to the source
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object