-
Notifications
You must be signed in to change notification settings - Fork 18
Using record extractField. Helpers to RecordBox #68
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
Conversation
} | ||
|
||
private <T> boolean isNotInstance(Class<T> clazz, Object object) { | ||
return object != null && !clazz.isInstance(object); |
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.
clazz != null (?)
clazz.isInstance already does a non-null check
Map<String, T> newMap = new LinkedHashMap<>(map.size()); | ||
for (Map.Entry<String, Object> entry : map.entrySet()) { | ||
Object object = entry.getValue(); | ||
if (isNotInstance(clazz, object)) { |
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.
above.
could just replace with !clazz.isInstance(object)
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.
String key = entry.getKey()
and
newMap.put(key, ...)
if (casted == null) { | ||
throw new RuntimeException("Object " + casted + " is not an instance of class " + clazz.getName()); | ||
} | ||
newMap.put(entry.getKey(), (Map<String, T>) entry.getValue()); |
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.
might as well use key instead of entry.getKey()
Objects.requireNonNull(entries); | ||
List<T> newList = new ArrayList<>(entries.length); | ||
for (Object entry : entries) { | ||
if (isNotInstance(clazz, entry)) { |
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.
!clazz.isInstance
for (Map.Entry<String, Object> entry : map.entrySet()) { | ||
Object object = entry.getValue(); | ||
if (isNotInstance(clazz, object)) { | ||
if (!clazz.isInstance(entry)) { |
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.
should be object
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.
Whoops, thanks!
Addresses #47