braintree_java icon indicating copy to clipboard operation
braintree_java copied to clipboard

toString methods are missing

Open uwemaurer opened this issue 7 years ago • 9 comments

the library would be much easier to work with if there were toString() methods on the classes

uwemaurer avatar Jan 05 '18 14:01 uwemaurer

Thanks for the feedback, we'll take it into consideration. Adding this is not on our current roadmap, but I can see how it would be useful.

As always, PRs are welcome!

crookedneighbor avatar Jan 05 '18 16:01 crookedneighbor

What in your opinion is the best approach of implementing toString() methods for SDK classes? Should it be some JSON like structure that represents all object properties or something more sophisticated, like for example this

Transaction@182f0db={
    amount: "100.88",
    creditCard: CreditCard@152ffda={
        cardType: "AMEX".
        customerId: "123",
        subscriptions: []
    }
}

What should be a date/time format of a string representation? @uwemaurer Is there some subset of classes in the library that should have toString() method, or you rather thought about adding it to all of them?

kmichalak avatar Feb 20 '18 15:02 kmichalak

Just the IDE generated toString() implementation is fine. For the date format you can just call the date objects toString() method.

The response classes which are returned by the API are most important to have a toString() method.

uwemaurer avatar Feb 20 '18 20:02 uwemaurer

If such implementation of toString() method is fine for you, I'll prepare some PR in a couple of days.

kmichalak avatar Feb 21 '18 09:02 kmichalak

Hey all !

Just a quick update. We have taken this into consideration. We are fancying the idea of using lombok library to do the heavy lifting for us. Currently, the idea is to use it for toString method only, but hopefully more in future, if things go out well. We are still testing a bunch of changes, and making sure it will not cause a breaking change to us. We will keep you posted.

jaypatel512 avatar Feb 21 '18 17:02 jaypatel512

Thanks for notification. As this is curretnly in progress, then no additional changes/pull requests will be needed from my side?

kmichalak avatar Feb 21 '18 18:02 kmichalak

A quick update. We have not forgotten you. We are running into issues using lombok with Java 7. We are working our way trying to fix that, and making a lot of new features from lombok available for our library. Apologies for the delay.

jaypatel512 avatar May 07 '18 19:05 jaypatel512

I am very interested in this feature (and/or #80).

I am using Braintree in a language that runs on top of Java, but I am not a java developer so unfortunately I can't offer any hope of a PR. We need to store the charge response in our database for record-keeping, but the SDK returns java objects that are not serializable. The toString() method simply prints the class name, e.g. com.braintreegateway.Result@1c1538d2 and nothing more.

I can spelunk through the response methods and cobble together my own native-data representation of the result and then serialize that, but the number of possibilities that would need to be accounted for in the variations of response contents would be very high (for example, responses can be significantly different between charges made with cc/venmo/paypal/google pay/apple pay).

atuttle avatar Apr 20 '21 13:04 atuttle

for internal notekeeping, ticket 631

hollabaq86 avatar May 02 '22 21:05 hollabaq86