Class DefaultTypedConfigGetter

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean getBoolean​(Config config, java.lang.String section, java.lang.String subsection, java.lang.String name, boolean defaultValue)
      Get a boolean value from a git Config.
      <T extends java.lang.Enum<?>>
      T
      getEnum​(Config config, T[] all, java.lang.String section, java.lang.String subsection, java.lang.String name, T defaultValue)
      Parse an enumeration from a git Config.
      int getInt​(Config config, java.lang.String section, java.lang.String subsection, java.lang.String name, int defaultValue)
      Obtain an integer value from a git Config.
      long getLong​(Config config, java.lang.String section, java.lang.String subsection, java.lang.String name, long defaultValue)
      Obtain a long value from a git Config.
      java.util.List<RefSpec> getRefSpecs​(Config config, java.lang.String section, java.lang.String subsection, java.lang.String name)
      Parse a list of RefSpecs from a git Config.
      long getTimeUnit​(Config config, java.lang.String section, java.lang.String subsection, java.lang.String name, long defaultValue, java.util.concurrent.TimeUnit wantUnit)
      Parse a numerical time unit, such as "1 minute", from a git Config.
      private static boolean match​(java.lang.String a, java.lang.String... cases)  
      private static java.lang.IllegalArgumentException notTimeUnit​(java.lang.String section, java.lang.String subsection, java.lang.String name, java.lang.String valueString)  
      • Methods inherited from class java.lang.Object

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

      • DefaultTypedConfigGetter

        public DefaultTypedConfigGetter()
    • Method Detail

      • getBoolean

        public boolean getBoolean​(Config config,
                                  java.lang.String section,
                                  java.lang.String subsection,
                                  java.lang.String name,
                                  boolean defaultValue)
        Get a boolean value from a git Config.
        Specified by:
        getBoolean in interface TypedConfigGetter
        Parameters:
        config - to get the value from
        section - section the key is grouped within.
        subsection - subsection name, such a remote or branch name.
        name - name of the key to get.
        defaultValue - default value to return if no value was present.
        Returns:
        true if any value or defaultValue is true, false for missing or explicit false
      • getEnum

        public <T extends java.lang.Enum<?>> T getEnum​(Config config,
                                                       T[] all,
                                                       java.lang.String section,
                                                       java.lang.String subsection,
                                                       java.lang.String name,
                                                       T defaultValue)
        Parse an enumeration from a git Config.
        Specified by:
        getEnum in interface TypedConfigGetter
        Parameters:
        config - to get the value from
        all - all possible values in the enumeration which should be recognized. Typically EnumType.values().
        section - section the key is grouped within.
        subsection - subsection name, such a remote or branch name.
        name - name of the key to get.
        defaultValue - default value to return if no value was present.
        Returns:
        the selected enumeration value, or defaultValue.
      • getInt

        public int getInt​(Config config,
                          java.lang.String section,
                          java.lang.String subsection,
                          java.lang.String name,
                          int defaultValue)
        Obtain an integer value from a git Config.
        Specified by:
        getInt in interface TypedConfigGetter
        Parameters:
        config - to get the value from
        section - section the key is grouped within.
        subsection - subsection name, such a remote or branch name.
        name - name of the key to get.
        defaultValue - default value to return if no value was present.
        Returns:
        an integer value from the configuration, or defaultValue.
      • getLong

        public long getLong​(Config config,
                            java.lang.String section,
                            java.lang.String subsection,
                            java.lang.String name,
                            long defaultValue)
        Obtain a long value from a git Config.
        Specified by:
        getLong in interface TypedConfigGetter
        Parameters:
        config - to get the value from
        section - section the key is grouped within.
        subsection - subsection name, such a remote or branch name.
        name - name of the key to get.
        defaultValue - default value to return if no value was present.
        Returns:
        a long value from the configuration, or defaultValue.
      • getTimeUnit

        public long getTimeUnit​(Config config,
                                java.lang.String section,
                                java.lang.String subsection,
                                java.lang.String name,
                                long defaultValue,
                                java.util.concurrent.TimeUnit wantUnit)
        Parse a numerical time unit, such as "1 minute", from a git Config.
        Specified by:
        getTimeUnit in interface TypedConfigGetter
        Parameters:
        config - to get the value from
        section - section the key is in.
        subsection - subsection the key is in, or null if not in a subsection.
        name - the key name.
        defaultValue - default value to return if no value was present.
        wantUnit - the units of defaultValue and the return value, as well as the units to assume if the value does not contain an indication of the units.
        Returns:
        the value, or defaultValue if not set, expressed in units.
      • match

        private static boolean match​(java.lang.String a,
                                     java.lang.String... cases)
      • notTimeUnit

        private static java.lang.IllegalArgumentException notTimeUnit​(java.lang.String section,
                                                                      java.lang.String subsection,
                                                                      java.lang.String name,
                                                                      java.lang.String valueString)
      • getRefSpecs

        @NonNull
        public java.util.List<RefSpec> getRefSpecs​(Config config,
                                                   java.lang.String section,
                                                   java.lang.String subsection,
                                                   java.lang.String name)
        Parse a list of RefSpecs from a git Config.
        Specified by:
        getRefSpecs in interface TypedConfigGetter
        Parameters:
        config - to get the list from
        section - section the key is in.
        subsection - subsection the key is in, or null if not in a subsection.
        name - the key name.
        Returns:
        a possibly empty list of RefSpecs