CFML in year 2021+ supports STATIC methods and STATIC variables because now Adobe has implemented it in ColdFusion 2021 (Lucee supported it since 5.0). Here is a code example of a component named Cube.cfc and a index.cfm file which uses static methods that I used in this other SO thread. I'm adding this information here for completeness.
A CFC component named Cube.cfc
component displayname="Cube" accessors ="true" {
// class properties
property name="name" type="string";
property name="model" type="string";
property name="borderColor" type="string";
property name="material" type="string";
property name="dimension" type="struct";
// set static varibales
static {
private models =[ "model-a", "model-b", "model-c" ];
private modelNameMaterialMapping ={
"model-a": "wood",
"model-b": "steel",
"model-c": "silver"
};
private modelNameDimensionsMapping ={
"model-a": {"height": 100, "length": 100, "width": 100 },
"model-b": {"height": 133, "length": 133, "width": 133 },
"model-c": {"height": 85, "length": 85, "width": 85 }
};
};
public any function init(
string name,
string borderColor,
string model
){
setName( arguments.name );
setBorderColor( arguments.borderColor );
setModel( arguments.model );
setMaterial( static.getMaterialByModelName( arguments.model ) );
setDimension( static.getDimensionByModelName( arguments.model ) );
return this;
}
public static string function getMaterialByModelName( string modelName ){
return static.modelNameMaterialMapping[ arguments.modelName ];
}
public static struct function getDimensionByModelName( string modelName ){
return static.modelNameDimensionsMapping[ arguments.modelName ];
}
public static string function isValidModel( string model ){
return static.models.contains( arguments.model );
}
}
And a index.cfm file that calls the static methods:
<cfscript>
modelsForChecking=[
"model-a",
"model-k",
"model-c",
"model-z"
];
// loop through model information without having any object instantiated by calling static functions
for( model in modelsForChecking){
if( Cube::isValidModel( model )){
writeOutput("Cube ""#model#"" is valid.<br>");
writeOutput( "Cube models ""#model#"" are made of ""#Cube::getMaterialByModelName( model )#"" and a dimension of ""#Cube::getDimensionByModelName( model ).width#x#Cube::getDimensionByModelName( model ).length#x#Cube::getDimensionByModelName( model ).height#""<br>");
}else{
writeOutput("Cube ""#model#"" is NOT a valid model.<br>");
}
}
//intantiate a specific cube object with the name "CubeOne";
writeOutput( "Instantiate an object with the component:<br>");
CubeOne=new Cube("CubeOne", "white", "model-c" );
// dump properties of the specific cube "CubeOne"
writeDump( CubeOne );
// get width with the accesso getter for property dimension for the cube named "CubeOne"
writeOutput("""CubeOne"" has a width of #CubeOne.getDimension().width# <br>");
</cfscript>