Skip to content

Support for default values #23

@fabriziocucci

Description

@fabriziocucci

Besides this stackoverflow question, I couldn't really find any information related to this topic but it would be nice to extend the support of default values in Jackson, particularly in the context of the MrBean module.

One option could be using annotations:

interface Person {
  @DefaultValue("default first name")
  String getFirstName();
  @DefaultValue("default last name")
  String getLastName();
}

Another option could be using Java 8 default methods:

interface Person {
  default String getFirstName() { return "default first name"; }
  default String getLastName() { return "default last name"; }
}

Currently, there are two main limitation I see for MrBean:

  1. No possibility to specify default values
  2. No possibility to use Java 8 Optional

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions