It seems to me it should be:

return testReq == null ? false : "TRUE".equals(testReq.toUpperCase());

Anything that is not "TRUE" is false.

-Adrian

Jacques Le Roux wrote:

I thought a bit about that, and since I spoke about APL, that's how it would be 
written in an APL style in Java :

    return testReq == null ? true : ("TRUE".equals(testReq.toUpperCase()) ? 
true : else;

(Note I choose to put true if null but maybe it should be false as BJ did...)

We used to call this type of style "one liner syndrom". The goal (play?) is to 
put the as less as characters as possible, it's a bit
better read when written

    return (testReq == null) ? true : ("TRUE".equals(testReq.toUpperCase()) ? 
true : else;

But with Java you can't really have fun with this, it's not APL...

Maybe some may argue that to use blocks and brackets still makes sense since 
it's far more readable (at a glance)...
It was always a dilemma for me when I was writting APL and C or Pascal in the 
same day... I did not take the straight road,  it's
not the one I prefer...

Jacques

PS : sorry for bothering :p


Yes clearer than my proposition using ternary operator and no worry about 
default value : + 1
We can play a lot with thing like this, I wrote thousands of APL lines code, 
I'm used to play with these kind of boolean stuffes,

I

must say that from this POV, APL is more fun than any other languages ;o)

Jacques

----- Message d'origine ----- De : "Adrian Crum" <[EMAIL PROTECTED]>
À : <[email protected]>
Envoyé : mardi 18 décembre 2007 19:26
Objet : Re: svn commit: r605186 -
/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java



Plus, you can eliminate one if() construct:

if (testReq != null) {
    return "TRUE".equals(testReq.toUpperCase());
}

-Adrian

David E Jones wrote:


1. Bad code formating
2. Makes the default true, is that what we really want?
3. If 2 is true then should use more compact and easy to read,
like if != false instead of if = true

-David


On Tue, 18 Dec 2007 11:37:55 -0000
[EMAIL PROTECTED] wrote:



Author: jleroux
Date: Tue Dec 18 03:37:47 2007
New Revision: 605186

URL: http://svn.apache.org/viewvc?rev=605186&view=rev
Log:
A patch from BJ Freeman "Allows better testing of testmode from
propties file of
authorize.net" (https://issues.apache.org/jira/browse/OFBIZ-1450) -
OFBIZ-1450

Modified:
  
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java

Modified:
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
URL:

http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentSer

vices.java?rev=605186&r1=605185&r2=605186&view=diff

==============================================================================
---
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
(original) +++
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/AIMPaymentServices.java
Tue Dec 18 03:37:47 2007 @@ -376,7 +376,15 @@ } private static
boolean isTestMode() {
-         return ("TRUE".equals((String)
AIMProperties.get("testReq")));
+       boolean ret = true;
+        String testReq = (String)AIMProperties.get("testReq");
+        if(testReq != null) {
+            if(testReq.equals("TRUE"))
+                ret = true;
+            else
+                ret = false;
+        }
+        return ret;
   }

   private static String getVersion() {







Reply via email to