Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added Java API support of anyOf and oneOf

Had to create a seperate object since varargs doesn't seem to work on companion objects for case clases or something
  • Loading branch information...
commit 38158e59c81b65a2669e00e5de2cce07a9e59212 1 parent 3ccab4e
@schauder authored
View
10 src/main/scala/de/schauderhaft/degraph/check/constraints.scala
@@ -10,13 +10,19 @@ import scalax.collection.mutable.{ Graph => SGraph }
import de.schauderhaft.degraph.configuration.Configuration
import de.schauderhaft.degraph.configuration.Constraint
import de.schauderhaft.degraph.configuration.ConstraintViolation
+import scala.annotation.varargs
/**
* provides a DSLish method of creating Layer instances
*/
object Layer {
- def anyOf(es: String*) = LenientLayer(es: _*)
- def oneOf(es: String*) = StrictLayer(es: _*)
+ @varargs def anyOf(es: String*) = LenientLayer(es: _*)
+ @varargs def oneOf(es: String*) = StrictLayer(es: _*)
+}
+
+object JLayer {
+ @varargs def anyOf(es: String*) = LenientLayer(es: _*)
+ @varargs def oneOf(es: String*) = StrictLayer(es: _*)
}
/**
View
10 src/test/java/de/schauderhaft/degraph/check/JavaCheckApiTest.java
@@ -24,4 +24,14 @@ public void canUseAllow() {
public void canUseAllowDirect() {
classpath().withSlicing("blah", "whatever").allowDirect("a", "b", "c");
}
+
+ @Test
+ public void canUseAnyOf() {
+ JLayer.anyOf("b", "c", "d");
+ }
+
+ @Test
+ public void canUseOneOf() {
+ JLayer.oneOf("b", "c", "d");
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.