Небольшой рефакторинг

This commit is contained in:
Struchkov Mark 2022-07-30 10:27:09 +03:00
parent 0bbdcaae07
commit d4f6a672ef
9 changed files with 20 additions and 17 deletions

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>dev.struchkov.godfather</groupId> <groupId>dev.struchkov.godfather</groupId>
<artifactId>godfather-bot</artifactId> <artifactId>godfather-bot</artifactId>
<version>0.0.18</version> <version>0.0.22</version>
</parent> </parent>
<artifactId>bot-context</artifactId> <artifactId>bot-context</artifactId>

View File

@ -90,7 +90,7 @@ public class Mail extends Message implements Event {
} }
@Override @Override
public String getType() { public String getEventType() {
return TYPE; return TYPE;
} }

View File

@ -2,6 +2,6 @@ package dev.struchkov.godfather.context.domain.event;
public interface Event { public interface Event {
String getType(); String getEventType();
} }

View File

@ -28,7 +28,7 @@ public class SimpleButton implements KeyBoardButton {
this.callbackData = callbackData; this.callbackData = callbackData;
} }
public static SimpleButton simpleButton(@NotNull String label, @NotNull String callbackData) { public static SimpleButton simpleButton(@NotNull String label, String callbackData) {
return new SimpleButton(label, callbackData); return new SimpleButton(label, callbackData);
} }

View File

@ -2,9 +2,9 @@ package dev.struchkov.godfather.context.service;
import dev.struchkov.godfather.context.domain.event.Event; import dev.struchkov.godfather.context.domain.event.Event;
public interface EventProvider<T extends Event> { public interface EventHandler<T extends Event> {
void sendEvent(T event); void handle(T event);
String getEventType(); String getEventType();

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>dev.struchkov.godfather</groupId> <groupId>dev.struchkov.godfather</groupId>
<artifactId>godfather-bot</artifactId> <artifactId>godfather-bot</artifactId>
<version>0.0.18</version> <version>0.0.22</version>
</parent> </parent>
<artifactId>bot-core</artifactId> <artifactId>bot-core</artifactId>

View File

@ -11,6 +11,8 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import static dev.struchkov.haiti.utils.Checker.checkNull;
public class Storyline<M extends Message> { public class Storyline<M extends Message> {
private final Set<MainUnit<M>> startingUnits = new HashSet<>(); private final Set<MainUnit<M>> startingUnits = new HashSet<>();
@ -50,6 +52,9 @@ public class Storyline<M extends Message> {
final MainUnit<M> firstUnit = units.get(firstName); final MainUnit<M> firstUnit = units.get(firstName);
final MainUnit<M> secondUnit = units.get(secondName); final MainUnit<M> secondUnit = units.get(secondName);
Inspector.isNotNull(firstUnit, secondUnit); Inspector.isNotNull(firstUnit, secondUnit);
if (checkNull(firstUnit.getNextUnits())) {
firstUnit.setNextUnits(new HashSet<>());
}
firstUnit.getNextUnits().add(secondUnit); firstUnit.getNextUnits().add(secondUnit);
} }

View File

@ -1,19 +1,19 @@
package dev.struchkov.godfather.core.service.provider; package dev.struchkov.godfather.core.service.provider;
import dev.struchkov.godfather.context.domain.content.Mail; import dev.struchkov.godfather.context.domain.content.Mail;
import dev.struchkov.godfather.context.service.EventProvider; import dev.struchkov.godfather.context.service.EventHandler;
import dev.struchkov.godfather.core.GeneralAutoResponder; import dev.struchkov.godfather.core.GeneralAutoResponder;
public class EventStoryLineProvider implements EventProvider<Mail> { public class StoryLineHandler implements EventHandler<Mail> {
private final GeneralAutoResponder<Mail> generalAutoResponder; private final GeneralAutoResponder<Mail> generalAutoResponder;
public EventStoryLineProvider(GeneralAutoResponder<Mail> generalAutoResponder) { public StoryLineHandler(GeneralAutoResponder<Mail> generalAutoResponder) {
this.generalAutoResponder = generalAutoResponder; this.generalAutoResponder = generalAutoResponder;
} }
@Override @Override
public void sendEvent(Mail message) { public void handle(Mail message) {
generalAutoResponder.processingNewMessage(message); generalAutoResponder.processingNewMessage(message);
} }

10
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>dev.struchkov.godfather</groupId> <groupId>dev.struchkov.godfather</groupId>
<artifactId>godfather-bot</artifactId> <artifactId>godfather-bot</artifactId>
<version>0.0.18</version> <version>0.0.22</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
@ -32,13 +32,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<godfather.ver>0.0.18</godfather.ver> <godfather.context.ver>${project.version}</godfather.context.ver>
<godfather.core.ver>${project.version}</godfather.core.ver>
<godfather.context.ver>${godfather.ver}</godfather.context.ver>
<godfather.core.ver>${godfather.ver}</godfather.core.ver>
<autoresponder.ver>3.4.0</autoresponder.ver> <autoresponder.ver>3.4.0</autoresponder.ver>
<haiti.utils>1.2.0</haiti.utils> <haiti.utils>1.3.0</haiti.utils>
<javax.persistence.api.ver>2.2</javax.persistence.api.ver> <javax.persistence.api.ver>2.2</javax.persistence.api.ver>
<validation.api.ver>2.0.1.Final</validation.api.ver> <validation.api.ver>2.0.1.Final</validation.api.ver>