1
@Immutable
@Modifiable
public interface Record {

    String id();

    String fName();

    String lName();

    String mName();
}

All the fields in Record can be Nullable. One way for me to make these fields Nullable is to add @Nullable annotation on top of each field. Like this:

@Nullable
String mName()

Is there a way for me to specify at the interface level(through some annotation) that all fields can be null?

1
  • You can make the type Optional Commented Feb 15, 2023 at 0:41

1 Answer 1

0

I used the following config to disable null check in builder and with methods:

@Value.Style(
  validationMethod = Value.Style.ValidationMethod.NONE,
)

The following quote is the the ValidationMethod.NONE javadoc description:

Disables null and mandatory attribute checks. Any missing primitives will be initialized to their zero-based values: false, 0, '\0'. Object references will be nulls. Any optional, default and collection attributes will be initialized with their appropriate default values regardless of this validation setting.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.