belgattitude / soluble-japha

PHP Java integration
https://belgattitude.github.io/soluble-japha/
MIT License
69 stars 15 forks source link

How to access class properties and static factories? #37

Closed marcospassos closed 7 years ago

marcospassos commented 7 years ago

How to handle this simple case using the bridge?

EnumSet set = EnumSet.of(CustomEnum.FOO);
belgattitude commented 7 years ago

Hi Marcos,

You should be able do to something like below:

$formatStyle = $ba->java('java.time.format.FormatStyle');
$enumSetClass = $ba->javaClass('java.util.EnumSet');
$mySet = $enumSetClass->of($formatStyle->LONG, $formatStyle->SHORT);
echo (string) $mySet->toString(); // -> will print '[LONG, SHORT]'

Note the use of $ba->javaClass('java.util.EnumSet) instead of $ba->java(...). You can refer to the documentation to understand their differences here.

I've also added a unit test about it, have a look at

https://github.com/belgattitude/soluble-japha/blob/master/test/src/SolubleTest/Japha/Bridge/AdapterUsageUtilTest.php#L88

to complete the picture.

Let me know if it helps, so I'll close the issue... I'll update the doc once back from holidays, but if you have any comment, ideas, questions... to help for doc, the are very welcome.

Thanks for asking

marcospassos commented 7 years ago

@belgattitude first of all, thank you for supporting such an amazing project like this. We're in means of evaluating the bridge to use in a huge project. So, you will see us around more often :)

Let me know if it helps, so I'll close the issue... I'll update the doc once back from holidays, but if you have any comment, ideas, questions... to help for doc, the are very welcome.

Yes, it works smoothly. Thank you!

belgattitude commented 7 years ago

Great !

Out of curiosity, will your project will be php7.0 only.... I would love to release a v2, dropping pre-7 support soon, but not sure if it's the right time to do it

marcospassos commented 7 years ago

Yes. In fact it is 7.1+ On Tue, Apr 18, 2017 at 7:32 AM Sébastien Vanvelthem < notifications@github.com> wrote:

Great !

Out of curiosity, will your project will be php7.0 only.... I would love to release a v2, dropping pre-7 support soon, but not sure if it's the right time to do it

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/belgattitude/soluble-japha/issues/37#issuecomment-294771956, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5jvO8T-vXDReUX9diiryXcVsSsNaCtks5rxJFGgaJpZM4M-ni5 .