Conversation
| */ | ||
| public Object getById(String id) { | ||
|
|
||
| for (Bean bean: beans) { |
There was a problem hiding this comment.
Бегать в цикле плохо, заведите Map<String, Bean>
| */ | ||
| public Object getByClass(String className) { | ||
| for (Bean bean: beans) { | ||
| if (bean.getClassName().equals(className)) { |
|
|
||
| return object; | ||
|
|
||
| } catch (ClassNotFoundException e) { |
| @@ -0,0 +1,185 @@ | |||
| <?xml version="1.0"?> | |||
There was a problem hiding this comment.
Служебные и .class файлы не должны попадпть в реквест. Добавьте их в .gitignore
| propertyValue = getById(property.getVal()); | ||
| } | ||
| for (Field field: object.getClass().getDeclaredFields()) { | ||
| if (field.getName().equals(property.getName())) { |
There was a problem hiding this comment.
В задании было устанавливать значение через метод, а не через поле
| String properyName = new String(properyNameCharSet); | ||
| for (Method method: object.getClass().getDeclaredMethods()) { | ||
| if (method.getName().equals("set" + properyName)) { | ||
| if (method.getParameterTypes()[0].getName().equals(INT)) { |
There was a problem hiding this comment.
Почему случай с int вынесен отдельно? А если там будет double или String? Нужен общий код, который может установить поле любого примитивного типа или String
| e.printStackTrace(); | ||
| } catch (InvocationTargetException e) { | ||
| } catch (Exception e) { | ||
| e.printStackTrace(); |
There was a problem hiding this comment.
Давайте кидать InvalidConfigurationException - сейчас вы игнорируете ошибку
arhangeldim
left a comment
There was a problem hiding this comment.
Принято. Только в след пулл-реквест не отправляйте служебные файлы (.class etc.). Файлы можно скрыть от гита с помощью .gitignore (почитайте что это)
| String properyName = new String(properyNameCharSet); | ||
| for (Method method : object.getClass().getDeclaredMethods()) { | ||
| if (method.getName().equals("set" + properyName)) { | ||
| for (Primitives primitive : Primitives.values()) { |
There was a problem hiding this comment.
интересное решение. Единственное, я бы хранил все примитивы в мапе, чтобы вытаскивать их по типу за одно действие (а не в цикле)
No description provided.