Skip to content

Conversation

akshaisarma
Copy link
Member

Addresses #47

@coveralls
Copy link

coveralls commented Nov 21, 2018

Coverage Status

Coverage decreased (-0.0006%) to 99.711% when pulling f78803a on akshaisarma:extract-extension into 8ec8129 on bullet-db:master.

}

private <T> boolean isNotInstance(Class<T> clazz, Object object) {
return object != null && !clazz.isInstance(object);
Copy link
Member

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)) {
Copy link
Member

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)

Copy link
Member

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());
Copy link
Member

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)) {
Copy link
Member

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)) {
Copy link
Member

Choose a reason for hiding this comment

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

should be object

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, thanks!

@akshaisarma akshaisarma merged commit 3afb090 into bullet-db:master Nov 21, 2018
@akshaisarma akshaisarma deleted the extract-extension branch November 21, 2018 21:36
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.

4 participants