<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <b class="gmail_sendername" dir="auto">Matúš Maďar</b> <span dir="auto"><<a href="mailto:semicco2@gmail.com">semicco2@gmail.com</a>></span><br>Date: Sun, Apr 3, 2022 at 7:23 PM<br>Subject: Re: [NSWI080] Task 2 - Java - Accessing (non existing) optional field<br>To: Petr Tuma <<a href="mailto:petr.tuma@d3s.mff.cuni.cz">petr.tuma@d3s.mff.cuni.cz</a>><br></div><br><br><div dir="ltr"><div>How to use isSet()? I can't find any static method like this. The only Java method isSet() I can find (on Google) is one in 
java.util.Calendar class. I can't find anything like isSet() similar to PHP.<br></div>Thanks<br></div><div id="m_-7765279413696333517DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br>
<table style="border-top:1px solid #d3d4de">
        <tbody><tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" target="_blank"><img src="https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif" alt="" style="width:46px;height:29px" width="46" height="29"></a></td>
                <td style="width:470px;padding-top:12px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail" style="color:#4453ea" target="_blank">www.avast.com</a>
                </td>
        </tr>
</tbody></table><a href="#m_-7765279413696333517_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 3, 2022 at 6:41 PM Petr Tuma <<a href="mailto:petr.tuma@d3s.mff.cuni.cz" target="_blank">petr.tuma@d3s.mff.cuni.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
you should first check whether the field is set with `isSet`. Calling the getter without first checking for presence returns `0` for integers, `0.0` for floats, `null` for strings etc.<br>
<br>
Petr<br>
<br>
<br>
On 03/04/2022 01:02, Matúš Maďar wrote:<br>
> Hello all.<br>
> I haven't found anything in documentation so I'd like to ask. Did anyone encounter and can explain, what is the expected behaviour in Java, when you try to access optional field in service? E.g. if ItemA doesn't have fieldZ defined; will it throw some exception or will it just return default value of the type of field?<br>
> Thanks!<br>
> <br>
> _______________________________________________<br>
> NSWI080 mailing list<br>
> <a href="mailto:NSWI080@d3s.mff.cuni.cz" target="_blank">NSWI080@d3s.mff.cuni.cz</a><br>
> <a href="https://d3s.mff.cuni.cz/mailman/listinfo/nswi080" rel="noreferrer" target="_blank">https://d3s.mff.cuni.cz/mailman/listinfo/nswi080</a><br>
</blockquote></div>
</div></div>