Class BitbucketUtils


  • public class BitbucketUtils
    extends Object
    Collection of static methods to be used globally.
    • Field Detail

      • GSON_PARSER

        public static final com.google.gson.Gson GSON_PARSER
      • JSON_PARSER

        public static final com.google.gson.JsonParser JSON_PARSER
    • Constructor Detail

      • BitbucketUtils

        protected BitbucketUtils()
    • Method Detail

      • nullToEmpty

        public static <T> List<T> nullToEmpty​(Iterable<? extends T> input)
        Convert passed Iterable into an ImmutableList.
        Type Parameters:
        T - an arbitrary type.
        Parameters:
        input - the Iterable to copy.
        Returns:
        ImmutableList or empty ImmutableList if `input` is null.
      • nullToEmpty

        public static <K,​V> Map<K,​V> nullToEmpty​(Map<? extends K,​? extends V> input)
        Convert passed Map into an ImmutableMap.
        Type Parameters:
        K - an arbitrary type.
        V - an arbitrary type.
        Parameters:
        input - the Map to copy.
        Returns:
        ImmutableMap or empty ImmutableMap if `input` is null.
      • nullToJsonElement

        public static com.google.gson.JsonElement nullToJsonElement​(Map input)
        Convert passed Map into a JsonElement.
        Parameters:
        input - the Map to convert.
        Returns:
        JsonElement or empty JsonElement if `input` is null.
      • nullToJsonElement

        public static com.google.gson.JsonElement nullToJsonElement​(com.google.gson.JsonElement input)
        Convert passed Map into a JsonElement.
        Parameters:
        input - the Map to convert.
        Returns:
        JsonElement or empty JsonElement if `input` is null.
      • nullToJsonElement

        public static com.google.gson.JsonElement nullToJsonElement​(String input)
        Convert passed String into a JsonElement.
        Parameters:
        input - the String to convert.
        Returns:
        JsonElement or empty JsonElement if `input` is null.
      • retriveExternalValue

        public static String retriveExternalValue​(@Nullable
                                                  String systemProperty,
                                                  @Nullable
                                                  String environmentVariable)
        If the passed systemProperty is non-null we will attempt to query the `System Properties` for a value and return it. If no value was found, and environmentVariable is non-null, we will attempt to query the `Environment Variables` for a value and return it. If both are either null or can't be found than null will be returned.
        Parameters:
        systemProperty - possibly existent System Property.
        environmentVariable - possibly existent Environment Variable.
        Returns:
        found external value or null.
      • inferEndpoint

        public static String inferEndpoint()
        Find endpoint searching first within `System Properties` and then within `Environment Variables` returning whichever has a value first.
        Returns:
        endpoint or null if it can't be found.
      • inferAuthentication

        public static BitbucketAuthentication inferAuthentication()
        Find credentials (Basic, Bearer, or Anonymous) from system/environment.
        Returns:
        BitbucketCredentials
      • inferOverrides

        public static Properties inferOverrides()
        Find jclouds overrides (e.g. Properties) first searching within System Properties and then within Environment Variables (former takes precedance).
        Returns:
        Properties object with populated jclouds properties.
      • addEnvironmentVariables

        public static void addEnvironmentVariables​(Map<String,​String> addEnvVars)
        Add the passed environment variables to the currently existing env-vars.
        Parameters:
        addEnvVars - the env-vars to add.
      • removeEnvironmentVariables

        public static void removeEnvironmentVariables​(Collection<String> removeEnvVars)
        Remove the passed environment variables keys from the environment.
        Parameters:
        removeEnvVars - the env-var keys to be removed.
      • setEnvironmentVariables

        public static void setEnvironmentVariables​(Map<String,​String> newEnvVars)
        Re-set the environment variables with passed map.
        Parameters:
        newEnvVars - map to reset env-vars with.