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

Commit 856f41a

Browse files
committed
Started work on typesafe generic requirements. Not ready yet.
1 parent 39a44ed commit 856f41a

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

ajavaplugin/src/main/java/PluginImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import org.codeoverflow.chatoverflow.api.plugin.Plugin;
2-
import org.codeoverflow.chatoverflow.api.plugin.configuration.Configuration;
2+
import org.codeoverflow.chatoverflow.api.plugin.configuration.Requirements;
33

44
public class PluginImpl implements Plugin {
55
@Override
@@ -8,7 +8,7 @@ public void start() {
88
}
99

1010
@Override
11-
public Configuration getRequirements() {
11+
public Requirements getRequirements() {
1212
return null;
1313
}
1414

anothertest/src/main/scala/anothertestMainClass.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import org.codeoverflow.chatoverflow.api.plugin.configuration.Configuration
1+
import org.codeoverflow.chatoverflow.api.plugin.configuration.Requirements
22
import org.codeoverflow.chatoverflow.api.plugin.{Pluggable, Plugin, PluginManager}
33

44
class anothertestMainClass extends Pluggable {
@@ -19,6 +19,6 @@ class anothertestMainClass extends Pluggable {
1919
println("Started another test!")
2020
}
2121

22-
override def getRequirements: Configuration = ???
22+
override def getRequirements: Requirements = ???
2323
}
2424
}
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
import org.codeoverflow.chatoverflow.api.io.input.chat.TwitchChatInput
2-
import org.codeoverflow.chatoverflow.api.io.input.event.EventInput
3-
import org.codeoverflow.chatoverflow.api.plugin.configuration.{Configuration, ParameterRequirement, SourceRequirement}
2+
import org.codeoverflow.chatoverflow.api.plugin.configuration.{ParameterRequirement, Requirements, SourceRequirement}
43
import org.codeoverflow.chatoverflow.api.plugin.{Plugin, PluginManager}
54

65
class simpletestPlugin(manager: PluginManager) extends Plugin {
76

8-
val config = new Configuration
9-
config.addInputRequirement("Twitch Channel", new SourceRequirement[TwitchChatInput])
10-
config.addInputRequirement("Some other stuff", new SourceRequirement[EventInput])
11-
//config.addOutputRequirement("Any Channel", new SourceRequirement[ChatOutput])
12-
config.addParameterRequirement("Some name", new ParameterRequirement[String])
7+
// TODO: Better?
8+
// val x: Requirement[TwitchChatInput] = config.requireTwitchChatInput("inputReq", "Twitch Channel")
9+
10+
val config = new Requirements
11+
12+
// VERSION A (Objektorientiert. Vorteil: Typsicher. Nachteil: Für jeden Input/Output eigene Methode in API)
13+
private val twitchChat = config.requireTwitchChatInput("inputReq", "A Twitch channel")
14+
twitchChat.getSource.getLastMessages(1000)
15+
16+
// VERSION B (Durch Reflection aufgelöst, Vorteil: Leicht erweiterbar, Nachteil: Nicht typsicher)
17+
//private val twitchChat2 = config.require(Class[TwitchChatInput], "inputReq2", "A twitch channel")
18+
//twitchChat2.getSource.asInstanceOf[TwitchChatInput].getLastMessages(1000)
19+
20+
21+
config.addInputRequirement("Twitch Channel", new SourceRequirement[TwitchChatInput]("input"))
22+
config.addParameterRequirement("Some name", new ParameterRequirement[String]("helloReq"))
1323

1424
override def start(): Unit = {
1525
println("Started successfully!")
1626
println(s"Dummy message is:${manager.getDummyMessage}")
1727

18-
val chatInput = config.getInputs.get("Twitch Channel").getSource.asInstanceOf[TwitchChatInput]
28+
val chatInput = config.getInputRequirement("Twitch Channel").getSource.asInstanceOf[TwitchChatInput]
1929
chatInput.registerMessageHandler(msg => println(msg))
2030

21-
println(s"Param: ${config.getParameters.get("Some name").getParameter}")
31+
println(s"Param: ${config.getParameterRequirement("Some name").getParameter}")
2232

2333
while (true) {
2434
Thread.sleep(10)
2535
}
2636
}
2737

28-
override def getRequirements: Configuration = config
38+
override def getRequirements: Requirements = config
2939
}

0 commit comments

Comments
 (0)