-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #312 from AnthonyGrod/core-refactor
Core refactor
- Loading branch information
Showing
276 changed files
with
2,281 additions
and
1,842 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...terators/kebs/matchers/KebsMatchers.scala → ...kebs/akkahttp/matchers/KebsMatchers.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../pl/iterators/kebs/matchers/package.scala → ...tors/kebs/akkahttp/matchers/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package pl.iterators.kebs | ||
package pl.iterators.kebs.akkahttp | ||
|
||
package object matchers extends KebsMatchers |
12 changes: 6 additions & 6 deletions
12
...ebs/unmarshallers/KebsUnmarshallers.scala → ...ttp/unmarshallers/KebsUnmarshallers.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...src/main/scala/pl/iterators/kebs/akkahttp/unmarshallers/enums/KebsEnumUnmarshallers.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package pl.iterators.kebs.akkahttp.unmarshallers.enums | ||
|
||
import akka.http.scaladsl.unmarshalling.PredefinedFromStringUnmarshallers._ | ||
import akka.http.scaladsl.unmarshalling.{FromStringUnmarshaller, Unmarshaller} | ||
import akka.http.scaladsl.util.FastFuture | ||
import pl.iterators.kebs.core.enums.{EnumLike, ValueEnumLike, ValueEnumLikeEntry} | ||
|
||
trait EnumUnmarshallers { | ||
final def enumUnmarshaller[E](`enum`: EnumLike[E]): FromStringUnmarshaller[E] = Unmarshaller { _ =>name => | ||
`enum`.withNameInsensitiveOption(name) match { | ||
case Some(enumEntry) => FastFuture.successful(enumEntry) | ||
case None => | ||
FastFuture.failed(new IllegalArgumentException(s"""Invalid value '$name'. Expected one of: ${`enum`.getNamesToValuesMap.keysIterator | ||
.mkString(", ")}""")) | ||
} | ||
} | ||
|
||
implicit def kebsEnumUnmarshaller[E](implicit ev: EnumLike[E]): FromStringUnmarshaller[E] = | ||
enumUnmarshaller(ev) | ||
} | ||
|
||
trait ValueEnumUnmarshallers { | ||
final def valueEnumUnmarshaller[V, E <: ValueEnumLikeEntry[V]](`enum`: ValueEnumLike[V, E]): Unmarshaller[V, E] = Unmarshaller { _ =>v => | ||
`enum`.withValueOption(v) match { | ||
case Some(enumEntry) => FastFuture.successful(enumEntry) | ||
case None => | ||
FastFuture.failed(new IllegalArgumentException(s"""Invalid value '$v'. Expected one of: ${`enum`.getValuesToEntriesMap.keysIterator | ||
.mkString(", ")}""")) | ||
} | ||
} | ||
|
||
implicit def kebsValueEnumUnmarshaller[V, E <: ValueEnumLikeEntry[V]](implicit ev: ValueEnumLike[V, E]): Unmarshaller[V, E] = | ||
valueEnumUnmarshaller(ev) | ||
|
||
implicit def kebsIntValueEnumFromStringUnmarshaller[E <: ValueEnumLikeEntry[Int]](implicit ev: ValueEnumLike[Int, E]): FromStringUnmarshaller[E] = | ||
intFromStringUnmarshaller andThen valueEnumUnmarshaller(ev) | ||
implicit def kebsLongValueEnumFromStringUnmarshaller[E <: ValueEnumLikeEntry[Long]](implicit ev: ValueEnumLike[Long, E]): FromStringUnmarshaller[E] = | ||
longFromStringUnmarshaller andThen valueEnumUnmarshaller(ev) | ||
implicit def kebsShortValueEnumFromStringUnmarshaller[E <: ValueEnumLikeEntry[Short]]( | ||
implicit ev: ValueEnumLike[Short, E]): FromStringUnmarshaller[E] = | ||
shortFromStringUnmarshaller andThen valueEnumUnmarshaller(ev) | ||
implicit def kebsByteValueEnumFromStringUnmarshaller[E <: ValueEnumLikeEntry[Byte]](implicit ev: ValueEnumLike[Byte, E]): FromStringUnmarshaller[E] = | ||
byteFromStringUnmarshaller andThen valueEnumUnmarshaller(ev) | ||
} | ||
|
||
trait KebsEnumUnmarshallers extends EnumUnmarshallers with ValueEnumUnmarshallers {} |
2 changes: 1 addition & 1 deletion
2
...scala-2/unmarshallers/enums/package.scala → ...kkahttp/unmarshallers/enums/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package pl.iterators.kebs.unmarshallers | ||
package pl.iterators.kebs.akkahttp.unmarshallers | ||
|
||
package object enums extends KebsEnumUnmarshallers |
2 changes: 1 addition & 1 deletion
2
...terators/kebs/unmarshallers/package.scala → ...kebs/akkahttp/unmarshallers/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package pl.iterators.kebs | ||
package pl.iterators.kebs.akkahttp | ||
|
||
package object unmarshallers extends KebsUnmarshallers |
3 changes: 0 additions & 3 deletions
3
akka-http/src/main/scala/pl/iterators/kebs/matchers/package.scala
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
akka-http/src/main/scala/pl/iterators/kebs/unmarshallers/enums/KebsEnumUnmarshallers.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.