Skip to content

ObjectReader readValue lacks Class<T> argument #2636

@robinroos

Description

@robinroos

Since ObjectMappers are mutable, I am exposing ObjectReader and ObjectWriter through a factory.

Whereas ObjectMapper.readValue(String content, Class valueType) is of known Type =valueType, the equivalent methods on ObjectReader are declared as returning T but do not take a Class valueType parameter.

Even ObjectReader.forType(Class<?> valueType) does not return a parameterized instance of ObjectReader.

The impact is that, whereas with ObjectMapper.readValue(String,Class) I do not have to typecast the returned value, when I start using ObjectReader.readValue(String) or ObjectReader.forType(Class).readValue(String) I must explicitly typecast the result.

Surely either ObjectReader.readValue should be overloaded with Class valueType (presumably this is trivially easy), or ObjectReader.forType(Class valueType) should return a fully parameterized ObjectReader (more complicated as ObjectReader is not a parameterized class)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions