Navigation Menu

Skip to content

Commit

Permalink
The extractor name should contains also the criterion, regression int…
Browse files Browse the repository at this point in the history
…roduced in 712113b
  • Loading branch information
nremond committed Nov 15, 2013
1 parent a80081d commit d3bc768
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
Expand Up @@ -26,6 +26,8 @@ trait Extractor[P, X] {
abstract class CriterionExtractor[P, T, X] extends Extractor[P, X] {
def criterion: Expression[T]
def extract(prepared: P, criterion: T): Validation[Option[X]]
def criterionName:String
def name = s"$name($criterionName)"

This comment has been minimized.

Copy link
@slandelle

slandelle Nov 18, 2013

Member

Really? ;)

def apply(session: Session, prepared: P): Validation[Option[X]] =
for {
criterion <- criterion(session).mapError(message => s"could not resolve extractor criterion: $message")
Expand Down
Expand Up @@ -49,7 +49,7 @@ object JoddCssExtractor {
}
}

abstract class JoddCssExtractor[X] extends CriterionExtractor[ExtendedNodeSelector, String, X] { val name = "css" }
abstract class JoddCssExtractor[X] extends CriterionExtractor[ExtendedNodeSelector, String, X] { val criterionName = "css" }

class SingleJoddCssExtractor[X](val criterion: Expression[String], nodeAttribute: Option[String], occurrence: Int) extends JoddCssExtractor[String] {

Expand Down
Expand Up @@ -31,7 +31,7 @@ object JsonPathExtractor {
cached(expression).map(_.queryJsonObject(json).collect(implicitly[JsonFilter[X]].filter))
}

abstract class JsonPathExtractor[X] extends CriterionExtractor[Any, String, X] { val name = "jsonPath" }
abstract class JsonPathExtractor[X] extends CriterionExtractor[Any, String, X] { val criterionName = "jsonPath" }

class SingleJsonPathExtractor[X: JsonFilter](val criterion: Expression[String], occurrence: Int) extends JsonPathExtractor[X] {

Expand Down
Expand Up @@ -42,7 +42,7 @@ object RegexExtractor {
}
}

abstract class RegexExtractor[X] extends CriterionExtractor[String, String, X] { val name = "regex" }
abstract class RegexExtractor[X] extends CriterionExtractor[String, String, X] { val criterionName = "regex" }

class SingleRegexExtractor[X: GroupExtractor](val criterion: Expression[String], occurrence: Int) extends RegexExtractor[X] {

Expand Down
Expand Up @@ -74,7 +74,7 @@ object XPathExtractor {
}
}

abstract class XPathExtractor[X] extends CriterionExtractor[Option[XdmNode], String, X] { val name = "xpath" }
abstract class XPathExtractor[X] extends CriterionExtractor[Option[XdmNode], String, X] { val criterionName = "xpath" }

class SingleXPathExtractor(val criterion: Expression[String], namespaces: List[(String, String)], occurrence: Int) extends XPathExtractor[String] {

Expand Down

0 comments on commit d3bc768

Please sign in to comment.