[NSWI080] Fwd: Task 2 - Java - Accessing (non existing) optional field
Matúš Maďar
semicco2 at gmail.com
Sun Apr 3 19:24:15 CEST 2022
---------- Forwarded message ---------
From: Matúš Maďar <semicco2 at gmail.com>
Date: Sun, Apr 3, 2022 at 7:23 PM
Subject: Re: [NSWI080] Task 2 - Java - Accessing (non existing) optional
field
To: Petr Tuma <petr.tuma at d3s.mff.cuni.cz>
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.
Thanks
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#m_-7765279413696333517_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
On Sun, Apr 3, 2022 at 6:41 PM Petr Tuma <petr.tuma at d3s.mff.cuni.cz> wrote:
> Hi,
>
> 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.
>
> Petr
>
>
> On 03/04/2022 01:02, Matúš Maďar wrote:
> > Hello all.
> > 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?
> > Thanks!
> >
> > _______________________________________________
> > NSWI080 mailing list
> > NSWI080 at d3s.mff.cuni.cz
> > https://d3s.mff.cuni.cz/mailman/listinfo/nswi080
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://d3s.mff.cuni.cz/pipermail/nswi080/attachments/20220403/c1c871bc/attachment.htm>
More information about the NSWI080
mailing list