Conversation
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()) { |
There was a problem hiding this comment.
можно было вынести в отдельный метод, чтобы читалось лучше
| return objByClassName.get(className); | ||
| } | ||
|
|
||
| private void newObject(Bean bean) throws Exception { |
There was a problem hiding this comment.
название я бы изменила, например, getInstance()
| } | ||
| newObject(bean); | ||
| } | ||
| return objByName.get(id); |
There was a problem hiding this comment.
можно короче:
if (!objByName.containsKey(id)) {
for (Bean curBean : beans) {
if (curBean.getId().equals(id)) {
return newObject(curBean);
}
}
return null;
}
return objByName.get(id);
There was a problem hiding this comment.
а метод newObject() возвращает сам объект. тогда меньше обращений к мапе
| } | ||
|
|
||
| return objByClassName.get(className); | ||
| } |
There was a problem hiding this comment.
тоже этот метод можно покороче
| } catch (IOException e) { | ||
| throw new InvalidConfigurationException("Incorrect config"); | ||
| } | ||
| } |
There was a problem hiding this comment.
все чтение можно сделать через библиотечку
public void readJson() {
ObjectMapper mapper = new ObjectMapper();
YourClass yourClass = mapper.readValue(new File("/path/to/file"), YourClass.class);
}
Bocharov N.A.