Skip to content

Method For Setting Null Value in Required Fields #622

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
adkapur opened this issue Dec 11, 2018 · 1 comment
Closed

Method For Setting Null Value in Required Fields #622

adkapur opened this issue Dec 11, 2018 · 1 comment
Labels

Comments

@adkapur
Copy link

adkapur commented Dec 11, 2018

Just a quick question regarding null values for required fields

For example if a timestamp field (uInt64) is specified with presence="required" then why is there a method for setting/getting null value for a required field? If a field is required then there should ideally be no setter method for setting a null value for it

Encoding:

public static long requestTimestampNullValue() {
return -1L;
}

public static long requestTimestampMinValue() {
return 0L;
}

public static long requestTimestampMaxValue() {
return -2L;
}

public XXXXXXXXEncoder requestTimestamp(long value) {
this.buffer.putLong(this.offset + 64, value, ByteOrder.LITTLE_ENDIAN);
return this;
}

Decoder:

public static long requestTimestampNullValue() {
return -1L;
}

public static long requestTimestampMinValue() {
return 0L;
}

public static long requestTimestampMaxValue() {
return -2L;
}

public long requestTimestamp() {
return this.buffer.getLong(this.offset + 64, ByteOrder.LITTLE_ENDIAN);
}

@mjpt777
Copy link
Contributor

mjpt777 commented Dec 11, 2018

Simplicity of code generation. Checking presence indicates if it is required rather than if a null value is defined.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants