Copy link to clipboard
Copied
I need to use a java library from Coldfusion 2018. Everything's great except one method in the library is named ".is()", and Coldfusion throws an error on it thinking it's an operator. I cannot modify the java library to rename this method. Is there any other solution to calling it from Coldfusion?
Thanks,
Copy link to clipboard
Copied
stumbled upon an interesting scenario
this works, Coldfusion interprets "is" as a method:
<cfset local.tsrequest = CreateObject("java", "com.braintreegateway.TransactionSearchRequest").init().customerId()>
<cfset local.tsrequest = local.tsrequest.is(#arguments.customer_id#)>
but this fails, Coldfusion interprets "is" as an operator:
<cfset local.tsrequest = CreateObject("java", "com.braintreegateway.TransactionSearchRequest").init()>
<cfset local.tsrequest = local.tsrequest.customerId().is(#arguments.customer_id#)>
Copy link to clipboard
Copied
adam20174248 wrote
I need to use a java library from Coldfusion 2018. Everything's great except one method in the library is named ".is()", and Coldfusion throws an error on it thinking it's an operator. I cannot modify the java library to rename this method.
Even if you could, it would be unwise to do so. Modifying a library might lead to unexpected errors. (Recall the O in object-oriented programming's SOLID principles: classes should be Open for extension, but closed for modification)
I would suggest you go with what works. For example, your first code snippet. I suspect it works because, in it, the method is() is called directly on an object defined in integrated Java code. Nevertheless, that is rather circumstantial and therefore unreliable as a solution.
You could create a better, lasting solution as follows:
<cfset local.tsrequest = createObject("java", "com.braintreegateway.TransactionSearchRequest").init()>
<cfset local.CFtsrequest = createObject("java", "CFTransactionSearchRequest")>
<cfset local.requestResult = local.CFtsrequest.cfIs(local.tsrequest, arguments.customer_id)>