-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
165 additions
and
12 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
api/src/main/java/broccolai/tags/api/service/ActionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package broccolai.tags.api.service; | ||
|
||
import broccolai.tags.api.model.tag.ConstructedTag; | ||
import broccolai.tags.api.model.user.TagsUser; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
public interface ActionService { | ||
|
||
boolean select(@NonNull TagsUser user, @NonNull ConstructedTag tag); | ||
|
||
void remove(@NonNull TagsUser user); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
core/src/main/java/broccolai/tags/core/service/action/EventActionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package broccolai.tags.core.service.action; | ||
|
||
import broccolai.tags.api.events.event.TagChangeEvent; | ||
import broccolai.tags.api.model.tag.ConstructedTag; | ||
import broccolai.tags.api.model.user.TagsUser; | ||
import broccolai.tags.api.service.ActionService; | ||
import broccolai.tags.api.service.EventService; | ||
import com.google.inject.Inject; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
public final class EventActionService implements ActionService { | ||
|
||
private final EventService eventService; | ||
|
||
@Inject | ||
public EventActionService(final @NonNull EventService eventService) { | ||
this.eventService = eventService; | ||
} | ||
|
||
@Override | ||
public boolean select(final @NonNull TagsUser user, final @NonNull ConstructedTag tag) { | ||
TagChangeEvent event = new TagChangeEvent(user, tag); | ||
this.eventService.post(event); | ||
|
||
return event.cancelled(); | ||
} | ||
|
||
@Override | ||
public void remove(final @NonNull TagsUser user) { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
core/src/main/java/broccolai/tags/core/util/FormatingUtilites.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package broccolai.tags.core.util; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class FormatingUtilites { | ||
|
||
public static List<String> splitString(String input, int maxLength) { | ||
List<String> lines = new ArrayList<>(); | ||
StringBuilder currentLine = new StringBuilder(); | ||
|
||
String[] words = input.split(" "); | ||
|
||
for (String word : words) { | ||
if (currentLine.length() + word.length() + 1 <= maxLength) { | ||
if (!currentLine.isEmpty()) { | ||
currentLine.append(" "); | ||
} | ||
currentLine.append(word); | ||
} else { | ||
lines.add(currentLine.toString()); | ||
currentLine = new StringBuilder(word); | ||
} | ||
} | ||
|
||
lines.add(currentLine.toString()); | ||
|
||
return lines; | ||
} | ||
|
||
} |