ome / omero-gateway-java

Gradle project containing OMERO Java Client Library
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
1 stars 9 forks source link

getMiddleName() throws exception instead of empty string #83

Closed Rdornier closed 10 months ago

Rdornier commented 11 months ago

Is there any reasons that this method throws an exception ?

    public String getMiddleName() {
        omero.RString n = asExperimenter().getMiddleName();
        if (n == null || n.getValue() == null) {
            throw new IllegalStateException(
                    "The name should never have been null");
        }
        return n.getValue();
    }

I think it could simply be written like this (same way as getLastName()

    public String getMiddleName() {
        omero.RString n = asExperimenter().getMiddleName();
        if (n == null || n.getValue() == null) return "";
        return n.getValue();
    }

In the same way, is there any reasons to return null for getEmail(), getInstitutiom()... methods instead of returning an empty string ?

Thanks, Rémy.

dominikl commented 11 months ago

Thanks @Rdornier . Indeed, looks a bit inconsistant to me. I'm not sure, was there any reasoning behind it, why some methods throw an exception, while others return null, and yet others return an emtpy String, @jburel ? If not, I'm happy to change them.