jackson-databind-nullable icon indicating copy to clipboard operation
jackson-databind-nullable copied to clipboard

New Method isUndefined

Open MelleD opened this issue 5 years ago • 5 comments

Hey,

@cbornet convinced me, it's really better to use the JsonNullable instead of Optionals. From the discussion here https://github.com/OpenAPITools/openapi-generator/pull/3214, the question: Make it sense to create a new method isUndefined()

@JsonIgnore
public boolean isUndefined(){
    return UNDEFINED.equals(this);
}

Before i create a PR, is there a reason why we should not create this method?

MelleD avatar Jun 27 '19 07:06 MelleD

Glad I convinced you 😀. At first I thought that it wouldn't be necessary since we already have isPresent() but I see that Java 11 introduced isEmpty() for Optional so I guess we can do the same. It's probably nice to use it as method reference in filter operations. About the implementation, I think it would be better to just return !isPresent.

cbornet avatar Jun 28 '19 04:06 cbornet

Maybe I misunderstood it, but how can you find out if the state is a "reset" or not?

Is the reset state a JsonNullable.of(null). So it's present but the value is null?

MelleD avatar Jun 28 '19 05:06 MelleD

If JsonNullable is in state "undefined", isPresent() returns false. Otherwise it returns true. Why did you close ?

cbornet avatar Jun 28 '19 08:06 cbornet

Yes, then an extension for isUndefined would make more sense.

I adjust the title of the ticket.

MelleD avatar Jul 01 '19 05:07 MelleD

Hi @cbornet , PR is open :)

MelleD avatar Jul 03 '19 08:07 MelleD