Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit c4df298

Browse files
committed
Merge branch 'develop' into feature/41-plugin-structure-rework
2 parents 437100d + dc856bc commit c4df298

File tree

17 files changed

+284
-103
lines changed

17 files changed

+284
-103
lines changed

build.sbt

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name := "chatoverflow-api"
2-
// The source generator creates a java class with the current version info
3-
lazy val sourceGenerator = TaskKey[Unit]("sourceGenerator")
2+
lazy val apiVersionGenerator = TaskKey[Unit]("apiVersionGenerator")
3+
lazy val requirementsGenerator = TaskKey[Unit]("requirementsGenerator")
44

55
// Convention: majorVersion++ on api signature update (else: minorVersion ++)
66
val majorVersion = 3
@@ -14,23 +14,16 @@ version := s"$majorVersion.$minorVersion"
1414
// ---------------------------------------------------------------------------------------------------------------------
1515

1616

17-
sourceGenerator := {
18-
val file = new File(sourceDirectory.value, "main/java/org/codeoverflow/chatoverflow/api/APIVersion.java")
19-
IO.write(file,
20-
"""package org.codeoverflow.chatoverflow.api;
21-
|
22-
|/**
23-
| * THIS CLASS IS GENERATED WHILE COMPILING. DO CHANGE THE VERSION NUMBERS IN THE APIS BUILD.SBT!
24-
| */
25-
|public class APIVersion {
26-
| public static final int MAJOR_VERSION = %d;
27-
| public static final int MINOR_VERSION = %d;
28-
|}
29-
|""".stripMargin.format(majorVersion, minorVersion))
30-
}
17+
apiVersionGenerator := APIUtility(streams.value.log)
18+
.generateAPIVersionFile(sourceDirectory.value, majorVersion, minorVersion)
19+
20+
requirementsGenerator := APIUtility(streams.value.log).generatedRequirements(sourceDirectory.value)
21+
3122

3223
// Update the compile process to generate the api version java class
3324
compile in Compile := {
34-
sourceGenerator.value
25+
apiVersionGenerator.value
26+
(compile in Compile).value
27+
requirementsGenerator.value
3528
(compile in Compile).value
3629
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.codeoverflow.chatoverflow.api;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* This annotation is used to specify, that this interface can be used are (input / output / parameter) requirement type.
10+
* Based on this annotation, the requirement API is generated, visible to plugin developers.
11+
*/
12+
@Retention(RetentionPolicy.RUNTIME)
13+
@Target(ElementType.TYPE)
14+
public @interface IsRequirement {
15+
16+
/**
17+
* You can define the generated method name by yourself. If left empty, the name is generated like this:
18+
* "StringParameter" -> "string" or "TwitchChatInput" -> "twitchChat"
19+
*/
20+
String methodName() default "";
21+
22+
/**
23+
* Each generated methods javadoc starts with "Requires a [foo], which has to be specified by the user."
24+
* You can define, what [foo] is required. If left empty, the string is generated without additional information.
25+
*/
26+
String requires() default "";
27+
28+
}

src/main/java/org/codeoverflow/chatoverflow/api/io/input/FileInput.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.codeoverflow.chatoverflow.api.io.input;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
4+
35
import java.awt.image.BufferedImage;
46
import java.util.Optional;
57

8+
@IsRequirement(requires = "file system access")
69
public interface FileInput extends Input {
710

811
Optional<String> getFile(String pathInResources);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.codeoverflow.chatoverflow.api.io.input;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
4+
35
/**
46
* An example for an input, for implementation see SampleInputImpl in the framework
57
*/
8+
@IsRequirement
69
public interface SampleInput extends Input {
710
}

src/main/java/org/codeoverflow/chatoverflow/api/io/input/SerialInput.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.codeoverflow.chatoverflow.api.io.input;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
34
import org.codeoverflow.chatoverflow.api.io.event.serial.SerialDataAvailableEvent;
45
import org.codeoverflow.chatoverflow.api.io.event.serial.SerialEvent;
56
import org.codeoverflow.chatoverflow.api.io.input.event.EventInput;
@@ -11,6 +12,7 @@
1112
* Connects to a device that is connected to your pc through a serial port (an Arduino for example)
1213
* to receive data
1314
*/
15+
@IsRequirement(requires = "connection with a device connected to a serial port (an Arduino for example)")
1416
public interface SerialInput extends EventInput<SerialEvent> {
1517

1618
/**

src/main/java/org/codeoverflow/chatoverflow/api/io/input/chat/DiscordChatInput.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.codeoverflow.chatoverflow.api.io.input.chat;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
34
import org.codeoverflow.chatoverflow.api.io.dto.chat.discord.DiscordChatMessage;
45
import org.codeoverflow.chatoverflow.api.io.event.chat.discord.*;
56

67
import java.util.Optional;
78
import java.util.concurrent.Future;
89
import java.util.function.Consumer;
910

11+
@IsRequirement(requires = "discord chat bot")
1012
public interface DiscordChatInput extends ChatInput<DiscordChatMessage, DiscordEvent>, PrivateChatInput<DiscordChatMessage, DiscordEvent> {
1113

1214
/**

src/main/java/org/codeoverflow/chatoverflow/api/io/input/chat/MockUpChatInput.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package org.codeoverflow.chatoverflow.api.io.input.chat;
22

3-
import org.codeoverflow.chatoverflow.api.io.dto.chat.TextChannel;
3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
44
import org.codeoverflow.chatoverflow.api.io.dto.chat.ChatEmoticon;
55
import org.codeoverflow.chatoverflow.api.io.dto.chat.ChatMessage;
66
import org.codeoverflow.chatoverflow.api.io.dto.chat.ChatMessageAuthor;
7-
import org.codeoverflow.chatoverflow.api.io.event.chat.discord.DiscordChatMessageDeleteEvent;
7+
import org.codeoverflow.chatoverflow.api.io.dto.chat.TextChannel;
88
import org.codeoverflow.chatoverflow.api.io.event.chat.mockup.MockupChatMessageReceiveEvent;
99
import org.codeoverflow.chatoverflow.api.io.event.chat.mockup.MockupEvent;
1010
import org.codeoverflow.chatoverflow.api.io.event.chat.mockup.MockupPrivateChatMessageReceiveEvent;
@@ -14,6 +14,7 @@
1414
/**
1515
* A MockUp chat input for testing purposes, allows simulating public and private messages
1616
*/
17+
@IsRequirement
1718
public interface MockUpChatInput extends
1819
ChatInput<ChatMessage<ChatMessageAuthor, TextChannel, ChatEmoticon>, MockupEvent>,
1920
PrivateChatInput<ChatMessage<ChatMessageAuthor, TextChannel, ChatEmoticon>, MockupEvent> {

src/main/java/org/codeoverflow/chatoverflow/api/io/input/chat/TwitchChatInput.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package org.codeoverflow.chatoverflow.api.io.input.chat;
22

33

4+
import org.codeoverflow.chatoverflow.api.IsRequirement;
45
import org.codeoverflow.chatoverflow.api.io.dto.chat.twitch.TwitchChatMessage;
5-
import org.codeoverflow.chatoverflow.api.io.event.chat.mockup.MockupPrivateChatMessageReceiveEvent;
66
import org.codeoverflow.chatoverflow.api.io.event.chat.twitch.TwitchChatMessageReceiveEvent;
77
import org.codeoverflow.chatoverflow.api.io.event.chat.twitch.TwitchEvent;
88
import org.codeoverflow.chatoverflow.api.io.event.chat.twitch.TwitchPrivateChatMessageReceiveEvent;
9-
import org.codeoverflow.chatoverflow.api.io.input.chat.ChatInput;
109

1110
import java.util.function.Consumer;
1211

@@ -16,6 +15,7 @@
1615
* <b>Important notice:</b><br>
1716
* <b>Call {@link #setChannel(String)} to bind this input to a channel before performing any other action</b>}
1817
*/
18+
@IsRequirement
1919
public interface TwitchChatInput extends ChatInput<TwitchChatMessage, TwitchEvent>, PrivateChatInput<TwitchChatMessage, TwitchEvent> {
2020

2121
/**

src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/TipeeestreamEventInput.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.codeoverflow.chatoverflow.api.io.input.event;
22

3-
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamFollowEvent;
3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
44
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamDonationEvent;
55
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamEvent;
6+
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamFollowEvent;
67
import org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream.TipeeestreamSubscriptionEvent;
78

89
import java.util.function.Consumer;
910

11+
@IsRequirement(requires = "login for the TipeeeStream api", methodName = "tipeeeStream")
1012
public interface TipeeestreamEventInput extends EventInput<TipeeestreamEvent> {
1113

1214
/**

src/main/java/org/codeoverflow/chatoverflow/api/io/output/FileOutput.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.codeoverflow.chatoverflow.api.io.output;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
4+
35
import java.awt.image.BufferedImage;
46

7+
@IsRequirement(requires = "file system access")
58
public interface FileOutput extends Output {
69

710
boolean saveImage(BufferedImage image, String format, String pathInResources);

src/main/java/org/codeoverflow/chatoverflow/api/io/output/SerialOutput.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package org.codeoverflow.chatoverflow.api.io.output;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
4+
35
import java.io.PrintStream;
46

57
/**
68
* Connects to a device that is connected to your pc through a serial port (an Arduino for example)
79
* to output data
810
*/
11+
@IsRequirement(requires = "connection with a device connected to a serial port (an Arduino for example)")
912
public interface SerialOutput extends Output {
1013

1114
/**

src/main/java/org/codeoverflow/chatoverflow/api/io/output/chat/DiscordChatOutput.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package org.codeoverflow.chatoverflow.api.io.output.chat;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
34
import org.codeoverflow.chatoverflow.api.io.dto.chat.discord.DiscordEmbed;
45

56
/**
67
* Output to send messages in a discord chat
78
*/
9+
@IsRequirement(requires = "discord chat bot")
810
public interface DiscordChatOutput extends ChatOutput {
911

1012
/**

src/main/java/org/codeoverflow/chatoverflow/api/io/output/chat/TwitchChatOutput.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package org.codeoverflow.chatoverflow.api.io.output.chat;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
4+
35
/**
46
* Output to send messages in the twitch chat
57
* <p>
68
* <b>Important notice:</b><br>
79
* <b>Call {@link #setChannel(String)} to bind this input to a channel before performing any other action</b>}
810
*/
11+
@IsRequirement
912
public interface TwitchChatOutput extends ChatOutput {
1013

1114
/**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.codeoverflow.chatoverflow.api.io.parameter;
22

3+
import org.codeoverflow.chatoverflow.api.IsRequirement;
4+
35
/**
46
* A {@link Parameter} that is a String
57
*/
8+
@IsRequirement
69
public interface StringParameter extends Parameter<String> {
710
}

0 commit comments

Comments
 (0)