Class GroovyMethods

    • Constructor Detail

      • GroovyMethods

        GroovyMethods()
      • GroovyMethods

        GroovyMethods​(MartiniPackageProvider martiniPackageProvider,
                      io.toro.martini.ipackage.MartiniPackageToPackageConverter martiniMartiniPackageToPackageConverterPayload,
                      List<Object> groovyMethodsClassInstance,
                      io.toro.properties.ToroProperties applicationProperties)
    • Method Detail

      • withPackageEndpoints

        public static <V> V withPackageEndpoints​(GroovyObject obj,
                                                 Closure<V> closure)
        Allow a GroovyObject to execute a closure against the available Endpoints installed on the package associated with the current thread.
        Type Parameters:
        V - the expected type
        Parameters:
        obj - the object that requires the endpoints
        closure - the closure to invoke
        Returns:
        the actual result after invoking the closure against the collection of endpoints
        Throws:
        ToroRuntimeException - if there's no package associated with the current thread
      • saveTOROProperty

        @Deprecated
        public static String saveTOROProperty​(String key,
                                              String value)
        Deprecated.
        This method has been renamed. Please prefer savePackageProperty(String, String).

        Save an application property.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.saveTOROProperty('value')
         

        Parameters:
        key - the property key
        value - the property value
        Returns:
        the saved property value
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • saveTOROPropertyComment

        @Deprecated
        public static void saveTOROPropertyComment​(String key,
                                                   String comment)
        Deprecated.
        This method has been renamed. Please prefer savePackagePropertyComment(String, String).

        Add a comment to an application property, useful for providing a description of the property.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.saveTOROPropertyComment('This is a comment describing a property.')
         

        Parameters:
        key - the property key
        comment - the comment to the key
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getTOROPropertyComment

        @Deprecated
        public static String getTOROPropertyComment​(String key)
        Deprecated.
        This method has been renamed. Please prefer getPackagePropertyComment(String).

        Get the comment of an application property, useful for understanding the property's purpose.

        <

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.getTOROPropertyComment()
         

        Parameters:
        key - the property key
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getTOROPropertyArray

        @Deprecated
        public static String[] getTOROPropertyArray​(String key,
                                                    String[] defaultValue)
        Deprecated.
        This method has been renamed. Please prefer getPackagePropertyArray(String, String[]).

        Get the value of an application property as an array. Every comma-separated value in the property is assigned to one array element.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.getTOROPropertyArray(['default', 'values'])
         

        Parameters:
        key - the property key
        defaultValue - the value to return if the property doesn't exist
        Returns:
        the property value, or defaultValue if the property doesn't exist
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getTOROPropertyArray

        @Deprecated
        public static String[] getTOROPropertyArray​(String key)
        Deprecated.
        This method has been renamed. Please prefer getPackagePropertyArray(String).

        Get the value of an application property as an array. Every comma-separated value in the property is assigned to one array element.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.getTOROPropertyArray()
         

        Parameters:
        key - the property key
        Returns:
        the property value, or null if the property doesn't exist
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getTOROProperty

        @Deprecated
        public static String getTOROProperty​(String key)
        Deprecated.
        This method has been renamed. Please prefer getPackageProperty(String).

        Get the value of an application property.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.getTOROProperty()
         

        Parameters:
        key - the property key
        Returns:
        the property value, or null if the property doesn't exist
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getTOROProperty

        @Deprecated
        public static String getTOROProperty​(String key,
                                             String defaultValue)
        Deprecated.
        This method has been renamed. Please prefer getPackageProperty(String, String).

        Get the value of an application property.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.getTOROProperty('defaultValue')
         

        Parameters:
        key - the property key
        defaultValue - the value to return if the property doesn't exist
        Returns:
        the property value, or defaultValue if the property doesn't exist
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • removeTOROProperty

        @Deprecated
        public static String removeTOROProperty​(String key)
        Deprecated.
        This method has been renamed. Please prefer removePackageProperty(String).

        Delete an application property.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.removeTOROProperty()
         

        Parameters:
        key - the property key
        Returns:
        the property's assigned value
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • savePackageProperty

        @Deprecated
        public static String savePackageProperty​(String key,
                                                 String value)

        Save a package property.

        Package properties are local only to a package. This one-liner saves the property to the package in the current context; specifically in the package's package.properties file.

        Example usage:

         'key'.saveTOROProperty('value')
         

        Parameters:
        key - the property key
        value - the property value
        Returns:
        the property's assigned value
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • savePackagePropertyComment

        @Deprecated
        public static void savePackagePropertyComment​(String key,
                                                      String comment)

        Add a comment to a package property, useful for providing a description of the property.

        Package properties are local only to a package. This one-liner saves the property comment to the package in the current context; specifically in the package's package.properties file.

        Example usage:
         'key'.savePackagePropertyComment('This is a comment describing a property.')
         

        Parameters:
        key - the property key
        comment - the comment to the key
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getPackagePropertyComment

        @Deprecated
        public static String getPackagePropertyComment​(String key)

        Get the comment of a package property, useful for understanding the property's purpose.

        Package properties are local only to a package. This one-liner fetches the property comment from the package in the current context; specifically in the package's package.properties file.

        Example usage:

         'key'.getPackagePropertyComment()
         

        Parameters:
        key - the property key
        Returns:
        package property comment
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getPackagePropertyArray

        @Deprecated
        public static String[] getPackagePropertyArray​(String key,
                                                       String[] defaultValue)

        Get the value of a package property as an array. Every comma-separated value in the property is assigned to one array element.

        Package properties are local only to a package. This one-liner fetches the property from the package in the current context; specifically in the package's package.properties file.

        Example usage:

         'key'.getPackagePropertyArray(['default', 'values'])
         

        Parameters:
        key - the property key
        defaultValue - the value to return if the property doesn't exist
        Returns:
        the property value, or defaultValue if the property doesn't exist
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getPackagePropertyArray

        @Deprecated
        public static String[] getPackagePropertyArray​(String key)

        Get the value of a package property as an array. Every comma-separated value in the property is assigned to one array element.

        Package properties are local only to a package. This one-liner fetches the property from the package in the current context; specifically in the package's package.properties file.

        Example usage:

         'key'.getPackagePropertyArray()
         

        Parameters:
        key - the property key
        Returns:
        the property value, or null if the property doesn't exist
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getPackageProperty

        @Deprecated
        public static String getPackageProperty​(String key)

        Get the value of a package property.

        Package properties are local only to a package. This one-liner fetches the property from the package in the current context; specifically in the package's package.properties file.

        Example usage:

         'key'.getPackageProperty()
         

        Parameters:
        key - the property key
        Returns:
        the property value, or null if the property doesn't exist
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getPackageProperty

        @Deprecated
        public static String getPackageProperty​(String key,
                                                String defaultValue)

        Get the value of a package property.

        Package properties are local only to a package. This one-liner fetches the property from the package in the current context; specifically in the package's package.properties file.

        Example usage:

         'key'.getPackageProperty('defaultValue')
         

        Parameters:
        key - the property key
        defaultValue - the value to return if the property doesn't exist
        Returns:
        the property value, or defaultValue if the property doesn't exist
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • removePackageProperty

        @Deprecated
        public static String removePackageProperty​(String key)

        Delete a package property.

        Package properties are local only to a package. This one-liner removes the property from the package in the current context; specifically in the package's package.properties file.

        Example usage:
         'key'.removePackageProperty()
         

        Parameters:
        key - the property key
        Returns:
        the property's assigned value
        Throws:
        IllegalStateException - if package has not been set
        Since:
        1.0
      • getApplicationProperty

        public static String getApplicationProperty​(String key)

        Get the value of an application property.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.getApplicationProperty()
         

        Parameters:
        key - the property key
        Returns:
        the property value, or null if the property doesn't exist
        Since:
        1.0
      • getApplicationProperty

        public static String getApplicationProperty​(String key,
                                                    String defaultValue)

        Get the value of an application property.

        Application properties are global, and stored in the core package's application.properties file.

        Example usage:

         'key'.getApplicationProperty('defaultValue')
         

        Parameters:
        key - the property key
        defaultValue - the value to return if the property doesn't exist
        Returns:
        the property value, or defaultValue if the property doesn't exist
        Since:
        1.0