It is often desired to declare constants at the top of a script that can be referenced anywhere else in the script. In Groovy, it seems that if you declare a constant using fin
The another efficient way to add the global application level constants are declare one interface in suitable package as
interface applicationConstants {
//All constants goes here.
static final float PI = 3.14
String ADMIN_USER = "ADMIN"
Map languages = [
"en": "English",
"hi": "Hindi",
"mr": "Marathi"
]
// Like above you can declare all application level code constants here.
}
Use of constants in any class as below,
import packageNameContainingInterface.applicationConstants // import statement.
def adminUser = applicationConstants.ADMIN_USER
println adminUser