Skip to content
Permalink
Browse files

Added Int, List, Boolean and Double parameter

  • Loading branch information
derNiklaas committed Nov 7, 2019
1 parent 471dc4d commit 9d45ed28f20d3f918b41557864635422b6490b1c
@@ -65,8 +65,7 @@ class RequirementsFile(requirementsDirectory: File, requirementType: String, fil
requirement.file.getAbsolutePath.lastIndexOf(File.separator) + 1).replace(".java", "")

val requiresValue = if (requirement.requires != "") requirement.requires else className

val generatedName = className.replace(requirementType, "")
val generatedName = if(requirementType.equalsIgnoreCase("parameter")) className else className.replace(requirementType, "")

val methodNameValue = if (requirement.methodName != "") {
requirement.methodName.replace(" ", "")
@@ -0,0 +1,23 @@
package org.codeoverflow.chatoverflow.requirement.parameter

import org.codeoverflow.chatoverflow.api.io.parameter.BooleanParameter
import org.codeoverflow.chatoverflow.registry.Impl
import java.lang.Boolean

@Impl(impl = classOf[BooleanParameter])
class BooleanParameterImpl extends BooleanParameter {
private var value: Boolean = null

override def getType: Class[Boolean] = classOf[Boolean]

override def serialize(): String = get().toString

override def get(): Boolean = value

override def deserialize(value: String): Unit = {
set(Boolean.parseBoolean(value))
}

override def set(value: Boolean): Unit = this.value = value

}
@@ -0,0 +1,25 @@
package org.codeoverflow.chatoverflow.requirement.parameter

import org.codeoverflow.chatoverflow.api.io.parameter.DoubleParameter
import org.codeoverflow.chatoverflow.registry.Impl
import java.lang.Double

@Impl(impl = classOf[DoubleParameter])
class DoubleParameterImpl extends DoubleParameter {

private var value: Double = null

override def getType: Class[Double] = classOf[Double]

override def serialize(): String = get().toString

override def get(): Double = value

override def deserialize(value: String): Unit = {
try {
set(Double.valueOf(value))
}
}

override def set(value: Double): Unit = this.value = value
}
@@ -0,0 +1,24 @@
package org.codeoverflow.chatoverflow.requirement.parameter

import org.codeoverflow.chatoverflow.api.io.parameter.IntegerParameter
import org.codeoverflow.chatoverflow.registry.Impl

@Impl(impl = classOf[IntegerParameter])
class IntegerParameterImpl extends IntegerParameter {
private var value: Integer = null

override def getType: Class[Integer] = classOf[Integer]

override def serialize(): String = get().toString

override def get(): Integer = value

override def deserialize(value: String): Unit = {
try {
set(Integer.valueOf(value))
}
}

override def set(value: Integer): Unit = this.value = value

}
@@ -0,0 +1,48 @@
package org.codeoverflow.chatoverflow.requirement.parameter

import java.util.Collections
import java.util.List

import collection.JavaConverters._
import org.codeoverflow.chatoverflow.api.io.parameter.ListParameter
import org.codeoverflow.chatoverflow.registry.Impl

import scala.collection.mutable.ListBuffer


@Impl(impl = classOf[ListParameter])
class ListParameterImpl extends ListParameter {
private var value: List[String] = null

override def getType: Class[List[String]] = classOf[List[String]]

override def serialize(): String = {
var out = ""
for (part <- value.toArray()) {
if (out == "") {
out = out + part
} else {
out = out + "," + part
}
}
out
}

override def get(): List[String] = value

override def deserialize(value: String): Unit = {
var splits = value.split(",");
if (splits.length == 1) {
set(Collections.singletonList[String](splits(0)))
} else {
var list: ListBuffer[String] = ListBuffer[String]()
for (part <- splits) {
list += part
}
set(mutableSeqAsJavaList[String](list))
}
}

override def set(value: List[String]): Unit = this.value = value

}

0 comments on commit 9d45ed2

Please sign in to comment.
You can’t perform that action at this time.