Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update FieldAdapter with Nullable/NonNull annotations. Fix code in im… #649

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lemonboston
Copy link
Contributor

…plementations where it was needed. #644

{
values.put(mFieldName, value ? 1 : 0);
values.put(mFieldName, new BooleanBinaryLong(value).value());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why long?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I started to use Long instead of String for 0/1 booleans is that I saw that in SQLite these booleans are actually stored as number. I just looked up again:
https://www.sqlite.org/datatype3.html#boolean_datatype
I see integer can be 8 bytes there, so java long would cover it, but for this 0/1, java integer could fit as well, I suppose.

This also relates to the type I've introduce in the other pull request:

public interface DateTimeFields
{
/**
* The timestamp. ({@code null} if it's empty)
*/
@Nullable
Long timestamp();
/**
* Time zone id. ({@code null} if it's empty)
*/
@Nullable
String timeZoneId();
/**
* All-day flag of the date-time. 1 for true, 0 for false.
* <p>
* ({@code null} if it's empty, which is always interpreted as 0-false)
*/
@Nullable
Long isAllDay();
}

So the all-day flag is represented as Long here as well, as its raw value.

So in order to keep this consistent, I chose Long here, too. Although, I remember that some container types only store everything in String (Which type was that? I forgot. ) which may mean a double conversion. So it's not that obvious what's best.
But the idea again was to use the raw type and keep it consistent for simplicity.

What do you think?
We could certainly change to Integer at least.

Copy link
Contributor Author

@lemonboston lemonboston Jan 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could even use Short. (I've never used that type before..:) )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short is not supported by all containers, so that's not good. Integer is supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to use Integer.

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

Successfully merging this pull request may close these issues.

2 participants