Skip to content

Commit

Permalink
Move EndpointResult.isMatched to a base class
Browse files Browse the repository at this point in the history
  • Loading branch information
vkostyukov committed Oct 25, 2018
1 parent 784730c commit fb65821
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions core/src/main/scala/io/finch/EndpointResult.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ sealed abstract class EndpointResult[F[_], +A] {
/**
* Whether the [[Endpoint]] is matched on a given [[Input]].
*/
def isMatched: Boolean
final def isMatched: Boolean = this match {
case EndpointResult.Matched(_, _, _) => true
case _ => false
}

/**
* Returns the remainder of the [[Input]] after an [[Endpoint]] is matched.
Expand Down Expand Up @@ -83,13 +86,9 @@ object EndpointResult {
rem: Input,
trc: Trace,
out: F[Output[A]]
) extends EndpointResult[F, A] {
def isMatched: Boolean = true
}
) extends EndpointResult[F, A]

abstract class NotMatched[F[_]] extends EndpointResult[F, Nothing] {
def isMatched: Boolean = false
}
abstract class NotMatched[F[_]] extends EndpointResult[F, Nothing]

object NotMatched extends NotMatched[Id] {
final case class MethodNotAllowed[F[_]](allowed: List[Method]) extends NotMatched[F]
Expand Down

0 comments on commit fb65821

Please sign in to comment.