Skip to content

Comments

Fazlrish container#97

Open
fazlrish wants to merge 12 commits intoarhangeldim:masterfrom
fazlrish:fazlrish-container
Open

Fazlrish container#97
fazlrish wants to merge 12 commits intoarhangeldim:masterfrom
fazlrish:fazlrish-container

Conversation

@fazlrish
Copy link

No description provided.

*/
public Object getById(String id) {

for (Bean bean: beans) {
Copy link
Owner

Choose a reason for hiding this comment

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

Бегать в цикле плохо, заведите Map<String, Bean>

*/
public Object getByClass(String className) {
for (Bean bean: beans) {
if (bean.getClassName().equals(className)) {
Copy link
Owner

Choose a reason for hiding this comment

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

нужна мапа


return object;

} catch (ClassNotFoundException e) {
Copy link
Owner

Choose a reason for hiding this comment

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

Ловите просто Exception

@@ -0,0 +1,185 @@
<?xml version="1.0"?>
Copy link
Owner

Choose a reason for hiding this comment

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

Служебные и .class файлы не должны попадпть в реквест. Добавьте их в .gitignore

propertyValue = getById(property.getVal());
}
for (Field field: object.getClass().getDeclaredFields()) {
if (field.getName().equals(property.getName())) {
Copy link
Owner

Choose a reason for hiding this comment

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

В задании было устанавливать значение через метод, а не через поле

String properyName = new String(properyNameCharSet);
for (Method method: object.getClass().getDeclaredMethods()) {
if (method.getName().equals("set" + properyName)) {
if (method.getParameterTypes()[0].getName().equals(INT)) {
Copy link
Owner

Choose a reason for hiding this comment

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

Почему случай с int вынесен отдельно? А если там будет double или String? Нужен общий код, который может установить поле любого примитивного типа или String

e.printStackTrace();
} catch (InvocationTargetException e) {
} catch (Exception e) {
e.printStackTrace();
Copy link
Owner

Choose a reason for hiding this comment

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

Давайте кидать InvalidConfigurationException - сейчас вы игнорируете ошибку

Copy link
Owner

@arhangeldim arhangeldim left a comment

Choose a reason for hiding this comment

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

Принято. Только в след пулл-реквест не отправляйте служебные файлы (.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()) {
Copy link
Owner

Choose a reason for hiding this comment

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

интересное решение. Единственное, я бы хранил все примитивы в мапе, чтобы вытаскивать их по типу за одно действие (а не в цикле)

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