Skip to content

Comments

Mannimarco container#100

Open
Mannimarco wants to merge 16 commits intoarhangeldim:masterfrom
Mannimarco:mannimarco-container
Open

Mannimarco container#100
Mannimarco wants to merge 16 commits intoarhangeldim:masterfrom
Mannimarco:mannimarco-container

Conversation

@Mannimarco
Copy link

Bocharov N.A.

Mannimarco and others added 16 commits October 5, 2016 11:50
update with stringbuilder and for instead of string+= and Arrays.asList
fixed empty constructor and unnecessary throws in signatures
Bocharov N.A.
removed long expections lists

Bocharov N.A.
removed long expections lists

Bocharov N.A.
removed long expections lists
checkstyle fix
Bocharov N.A.
String typeName = fieldClazz.getTypeName();
method = clazz.getMethod(getSetterName(name), fieldClazz);
Object param;
switch (typeName.toLowerCase()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

можно было вынести в отдельный метод, чтобы читалось лучше

return objByClassName.get(className);
}

private void newObject(Bean bean) throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

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

название я бы изменила, например, getInstance()

}
newObject(bean);
}
return objByName.get(id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

можно короче:
if (!objByName.containsKey(id)) {
for (Bean curBean : beans) {
if (curBean.getId().equals(id)) {
return newObject(curBean);
}
}
return null;
}
return objByName.get(id);

Copy link
Collaborator

Choose a reason for hiding this comment

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

а метод newObject() возвращает сам объект. тогда меньше обращений к мапе

}

return objByClassName.get(className);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

тоже этот метод можно покороче

} catch (IOException e) {
throw new InvalidConfigurationException("Incorrect config");
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

все чтение можно сделать через библиотечку
public void readJson() {
ObjectMapper mapper = new ObjectMapper();
YourClass yourClass = mapper.readValue(new File("/path/to/file"), YourClass.class);
}

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