diff --git a/bijection-core/src/main/scala/com/twitter/bijection/EnglishInt.scala b/bijection-core/src/main/scala/com/twitter/bijection/EnglishInt.scala index f57b45a4d..c9a32086c 100644 --- a/bijection-core/src/main/scala/com/twitter/bijection/EnglishInt.scala +++ b/bijection-core/src/main/scala/com/twitter/bijection/EnglishInt.scala @@ -13,7 +13,7 @@ package com.twitter.bijection -case class EnglishInt(get: String) +case class EnglishInt(get: String) extends AnyVal object EnglishInt { implicit val bijectionToInt: Bijection[Int, EnglishInt] = new AbstractBijection[Int, EnglishInt] { diff --git a/bijection-core/src/main/scala/com/twitter/bijection/NumberSystems.scala b/bijection-core/src/main/scala/com/twitter/bijection/NumberSystems.scala index 33672a313..d231380c7 100644 --- a/bijection-core/src/main/scala/com/twitter/bijection/NumberSystems.scala +++ b/bijection-core/src/main/scala/com/twitter/bijection/NumberSystems.scala @@ -6,9 +6,9 @@ package com.twitter.bijection object NumberSystems { - case class BinaryString(get: String) - case class HexString(get: String) - case class OctalString(get: String) + case class BinaryString(get: String) extends AnyVal + case class HexString(get: String) extends AnyVal + case class OctalString(get: String) extends AnyVal case class ArbitBaseString(get: String, base: Int) implicit val binary: Bijection[Int, BinaryString] = new AbstractBijection[Int, BinaryString] { diff --git a/bijection-core/src/main/scala/com/twitter/bijection/StringInjections.scala b/bijection-core/src/main/scala/com/twitter/bijection/StringInjections.scala index 3f340c1ea..de1db2085 100644 --- a/bijection-core/src/main/scala/com/twitter/bijection/StringInjections.scala +++ b/bijection-core/src/main/scala/com/twitter/bijection/StringInjections.scala @@ -26,6 +26,8 @@ import com.twitter.bijection.Inversion.attempt import scala.util.Try trait StringInjections extends NumericInjections { + import StringCodec.URLEncodedString + implicit val utf8: Injection[String, Array[Byte]] = withEncoding("UTF-8") def withEncoding(encoding: String): Injection[String, Array[Byte]] = @@ -48,8 +50,6 @@ trait StringInjections extends NumericInjections { override def invert(s: String) = attempt(s)(UUID.fromString(_)) } - case class URLEncodedString(encodedString: String) - implicit val string2UrlEncodedString: Injection[String, URLEncodedString] = new AbstractInjection[String, URLEncodedString] { override def apply(a: String): URLEncodedString = URLEncodedString(URLEncoder.encode(a, "UTF-8")) @@ -57,4 +57,6 @@ trait StringInjections extends NumericInjections { } } -object StringCodec extends StringInjections +object StringCodec extends StringInjections { + case class URLEncodedString(encodedString: String) extends AnyVal +} diff --git a/bijection-guava/src/main/scala/com/twitter/bijection/guava/GuavaBinaryBijections.scala b/bijection-guava/src/main/scala/com/twitter/bijection/guava/GuavaBinaryBijections.scala index 3b6c4da0d..fb7a368bf 100644 --- a/bijection-guava/src/main/scala/com/twitter/bijection/guava/GuavaBinaryBijections.scala +++ b/bijection-guava/src/main/scala/com/twitter/bijection/guava/GuavaBinaryBijections.scala @@ -23,19 +23,19 @@ import com.google.common.io.BaseEncoding */ object GuavaBinaryBijections { - trait BaseEncoding { - val str: String + trait BaseEncoding extends Any { + def str: String } - case class Base16String(str: String) extends BaseEncoding + case class Base16String(str: String) extends AnyVal with BaseEncoding - case class Base32String(str: String) extends BaseEncoding + case class Base32String(str: String) extends AnyVal with BaseEncoding - case class Base32HEXString(str: String) extends BaseEncoding + case class Base32HEXString(str: String) extends AnyVal with BaseEncoding - case class Base64String(str: String) extends BaseEncoding + case class Base64String(str: String) extends AnyVal with BaseEncoding - case class Base64URLString(str: String) extends BaseEncoding + case class Base64URLString(str: String) extends AnyVal with BaseEncoding implicit def unwrap(encodedString: BaseEncoding): String = Option(encodedString) match { case Some(x) => x.str diff --git a/bijection-json/src/main/scala/com/twitter/bijection/json/UnparsedJson.scala b/bijection-json/src/main/scala/com/twitter/bijection/json/UnparsedJson.scala index 84b836ad5..1969855c5 100644 --- a/bijection-json/src/main/scala/com/twitter/bijection/json/UnparsedJson.scala +++ b/bijection-json/src/main/scala/com/twitter/bijection/json/UnparsedJson.scala @@ -24,9 +24,8 @@ import org.codehaus.jackson.JsonNode /** * Value class representing unparsed Json text - * TODO in scala 2.10 this should be a value class */ -case class UnparsedJson(str: String) +case class UnparsedJson(str: String) extends AnyVal object UnparsedJson {