Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Дз № 4 + исправления по дз № 3 + spring + ДЗ № 5 #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Ellena557
Copy link
Owner

No description provided.

@Ellena557
Copy link
Owner Author

Изначально исправления по предыдущему дз были в прошлом PR (hw-3), перенесла их сюда.

@Ellena557 Ellena557 changed the title Дз № 4 + исправления по дз № 3 Дз № 4 + исправления по дз № 3 + ДЗ № 5 Mar 30, 2019
@Ellena557 Ellena557 changed the title Дз № 4 + исправления по дз № 3 + ДЗ № 5 Дз № 4 + исправления по дз № 3 + spring + ДЗ № 5 Mar 30, 2019
Copy link
Collaborator

@iagoshkov iagoshkov left a comment

Choose a reason for hiding this comment

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

См комментарии

import java.util.HashMap;
import java.util.Map;

public class SensorEventAdapter extends SensorEvent {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Нужно сделать через отдельный класс, который принимает на вход событие библиотечного типа и возвращает событие "нашего" типа.
Наследование здесь не нужно.


for (SensorEventProcessor eventProcessor : eventProcessors) {
EventHandler handler = new EventProcessorAdapter(eventProcessor);
((ArrayList<EventHandler>) handlers).add(handler);
Copy link
Collaborator

Choose a reason for hiding this comment

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

зачем cast к ArrayList - в Collection есть метод add

Copy link
Owner Author

@Ellena557 Ellena557 Apr 3, 2019

Choose a reason for hiding this comment

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

У меня там раньше немного другое было написано, каст идея сгенерировала, потом я поменяла строчку, а каст остался:(

public void start() {
this.eventsManager.registerEventHandler(
stringEvent -> {
toString(stringEvent.getEventType(), stringEvent.getObjectId());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Здесь не понял вообще что происходит. Зачем это?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Моя ошибка, там в Sample приведена строчка, которую выводить надо, a я написала то, как это в SensorCommand было.

public SensorEventsManagerAdapter(List<SensorEventProcessor> eventProcessors) {
this.eventsManager = new SensorEventsManager();

Collection<EventHandler> handlers = new ArrayList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Почему вообще не сделать просто:
eventProcessors.each(processor -> registerEventProcessor(processor))
?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Не догадалась:)

public class RemoteControlApp implements RemoteControl {

private HashMap<String, Command> buttonsVocab;
private RemoteControlRegistry remoteControlRegistry;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Зачем нужно это поле в этом классе?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Не нужно, не успела убрать.

@Ellena557 Ellena557 requested a review from iagoshkov April 3, 2019 19:42
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