-
-
Notifications
You must be signed in to change notification settings - Fork 21
java: Use Integers in addition to Longs #310
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
base: main
Are you sure you want to change the base?
Changes from all commits
263db33
534f855
7bbbf00
6e67701
db27e26
b149e9d
c2bc505
60ec843
01acc5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,12 @@ def format_description(raw_description, indent_string: '') | |
|
||
private | ||
|
||
def language_translations_for_data_types | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review here but for all generic implementors. Is the only usage of this in |
||
def select_language_translations_for_data_types(type, property) | ||
{ | ||
'integer' => 'std::size_t', | ||
'string' => 'std::string', | ||
'boolean' => 'bool' | ||
} | ||
}[type] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -23,12 +23,20 @@ def format_description(raw_description, indent_string: '') | |||||
|
||||||
private | ||||||
|
||||||
def language_translations_for_data_types | ||||||
{ | ||||||
'integer' => 'Long', | ||||||
'string' => 'String', | ||||||
'boolean' => 'Boolean' | ||||||
} | ||||||
def select_language_translations_for_data_types(type, property) | ||||||
if type == 'integer' | ||||||
if property['maximum'] and property['maximum'] <= 2147483647 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Java, for the choice between integer and long only the upper bound matters. They're both signed. |
||||||
'Integer' | ||||||
else | ||||||
'Long' | ||||||
end | ||||||
elsif type == 'string' | ||||||
'String' | ||||||
elsif type == 'boolean' | ||||||
'Boolean' | ||||||
else | ||||||
nil | ||||||
end | ||||||
end | ||||||
end | ||||||
end |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -53,11 +53,11 @@ def nullable?(property_name, schema) | |||||
end | ||||||
|
||||||
def scalar?(property) | ||||||
property.key?('type') && language_translations_for_data_types.key?(property['type']) | ||||||
property.key?('type') && select_language_translations_for_data_types(property['type'], property) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will return |
||||||
end | ||||||
|
||||||
def scalar_type_for(property) | ||||||
language_translations_for_data_types[property['type']] | ||||||
select_language_translations_for_data_types(property['type'], property) | ||||||
end | ||||||
|
||||||
private | ||||||
|
@@ -68,12 +68,12 @@ def default_value(class_name, property_name, property, schema) | |||||
super(class_name, property_name, property) | ||||||
end | ||||||
|
||||||
def language_translations_for_data_types | ||||||
def select_language_translations_for_data_types(type, property) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is never consumed here we can use _property to be memory efficient
Suggested change
|
||||||
{ | ||||||
'string' => 'string', | ||||||
'integer' => 'int', | ||||||
'boolean' => 'bool' | ||||||
} | ||||||
}[type] | ||||||
end | ||||||
|
||||||
def non_nullable_non_scalar_constructor(parent_type, property, property_name, schema, source) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is the only location for this? If so this seems good. I think a lot of the initial work I did for codegen was converting into a generic structure - I didn't go through and tidy up. So good catch if so