Class PackageMethods
- java.lang.Object
-
- io.toro.martini.PackageMethods
-
public final class PackageMethods extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPackageMethods.MartiniPackageSetterAn internal class used for setting theMartiniPackageof theThreadLocal(package private) static classPackageMethods.PackageInheritableThreadLocal
-
Field Summary
Fields Modifier and Type Field Description (package private) static ThreadLocal<EnhancedStack<MartiniPackage>>context(package private) static io.toro.martini.ipackage.PackageInfoServicepackageInfoService
-
Constructor Summary
Constructors Constructor Description PackageMethods(io.toro.martini.ipackage.PackageInfoService infoService)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MartiniPackagegetPackage()Get the package assigned to the current context.static io.toro.martini.ipackage.PackageInfogetPackageByName(String packageName)Get PackageInfo based on packageNamestatic StringgetPackageProperty(String key)Get the value of a package property.static StringgetPackageProperty(String key, String defaultValue)Get the value of a package property.static StringgetPackageProperty(String packageName, String key, String defaultValue)Get the value of a package propertystatic String[]getPackagePropertyArray(String key)Get the value of a package property as an array.static String[]getPackagePropertyArray(String key, String[] defaultValue)Get the value of a package property as an array.static String[]getPackagePropertyArray(String packageName, String key, String[] defaultValue)Get the value of a package property as an arraystatic StringgetPackagePropertyComment(String key)Get the comment of a package property, useful for understanding the property's purpose.static StringgetPackagePropertyComment(String packageName, String key)Get the comment of a package property in the package specifiedstatic StringremovePackageProperty(String key)Delete a package property.static StringremovePackageProperty(String packageName, String key)Delete a package propertystatic StringsavePackageProperty(String key, String value)Save a package property.static StringsavePackageProperty(String packageName, String key, String value)Save a property in the package specifiedstatic voidsavePackagePropertyComment(String key, String comment)Add a comment to a package property, useful for providing a description of the property.static voidsavePackagePropertyComment(String packageName, String key, String comment)Add a comment to a package property in the package specified
-
-
-
Field Detail
-
context
static ThreadLocal<EnhancedStack<MartiniPackage>> context
-
packageInfoService
static io.toro.martini.ipackage.PackageInfoService packageInfoService
-
-
Method Detail
-
getPackage
public static MartiniPackage getPackage()
Get the package assigned to the current context.- Returns:
- the current context's package
-
getPackageByName
public static io.toro.martini.ipackage.PackageInfo getPackageByName(String packageName)
Get PackageInfo based on packageName- Parameters:
packageName-- Returns:
- PackageInfo
-
savePackageProperty
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.propertiesfile.Example usage:
'key'.saveTOROProperty('value')- Parameters:
key- the property keyvalue- the property value- Returns:
- the property's assigned value
- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
savePackageProperty
public static String savePackageProperty(String packageName, String key, String value)
Save a property in the package specified- Parameters:
packageName- the name of packagekey- the property keyvalue- the property value- Returns:
- the property's assigned value
-
savePackagePropertyComment
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
Example usage:package.propertiesfile.'key'.savePackagePropertyComment('This is a comment describing a property.')- Parameters:
key- the property keycomment- the comment to the key- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
savePackagePropertyComment
public static void savePackagePropertyComment(String packageName, String key, String comment)
Add a comment to a package property in the package specified- Parameters:
packageName- the name of packagekey- the property keycomment- the comment to the keycomment-
-
getPackagePropertyComment
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.propertiesfile.Example usage:
'key'.getPackagePropertyComment()
- Parameters:
key- the property key- Returns:
- package property comment
- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackagePropertyComment
public static String getPackagePropertyComment(String packageName, String key)
Get the comment of a package property in the package specified- Parameters:
packageName- the name of packagekey- the property key- Returns:
-
getPackagePropertyArray
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.propertiesfile.Example usage:
'key'.getPackagePropertyArray(['default', 'values'])
- Parameters:
key- the property keydefaultValue- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValueif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackagePropertyArray
public static String[] getPackagePropertyArray(String packageName, String key, String[] defaultValue)
Get the value of a package property as an array- Parameters:
packageName- the name of packagekey- the property keydefaultValue-- Returns:
-
getPackagePropertyArray
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.propertiesfile.Example usage:
'key'.getPackagePropertyArray()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackageProperty
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.propertiesfile.Example usage:
'key'.getPackageProperty()
- Parameters:
key- the property key- Returns:
- the property value, or
nullif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackageProperty
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.propertiesfile.Example usage:
'key'.getPackageProperty('defaultValue')- Parameters:
key- the property keydefaultValue- the value to return if the property doesn't exist- Returns:
- the property value, or
defaultValueif the property doesn't exist - Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
getPackageProperty
public static String getPackageProperty(String packageName, String key, String defaultValue)
Get the value of a package property- Parameters:
packageName- the name of packagekey- the property keydefaultValue-- Returns:
-
removePackageProperty
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
Example usage:package.propertiesfile.'key'.removePackageProperty()
- Parameters:
key- the property key- Returns:
- the property's assigned value
- Throws:
IllegalStateException- if package has not been set- Since:
- 1.0
-
-