Skip to content

change return type of metadata getter to Optional<String>  #421

@tyrasd

Description

@tyrasd

Problem Description

The getter method for metadata properties in OSHDBJdbc currently returns null when a property is not present. This could lead to unexpected NullpointerExceptions when one does not know about this.

Expected Solution

If the method returns an Optional<String> it can/must be checked if a property was actually found by testing the return value accordingly.

Alternative Solutions

Just return an empty string ("") instead. This is not optimal, because one could not distinguish a situation where the actual value stored in the metadata table is an empty string. If a user doesn't care they can get this behaviour in the solution above by using returnedOptional.getOrDefault("").

Additional Context

see #419 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    user experienceEnhances the usability of OSHDB

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions