com.twitter

bijection

package bijection

Bijection trait with numerous implementations.

A Bijection[A, B] is an invertible function from A -> B. Knowing that two types have this relationship can be very helpful for serialization (Bijection[T, Array[Byte]]]), communication between libraries (Bijection[MyTrait, YourTrait]) and many other purposes.

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. bijection
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. type @@[T, Tag] = T with Tagged[Tag]

    Tag a type T with Tag.

    Tag a type T with Tag. The resulting type is a subtype of T.

    The resulting type is used to discriminate between type class instances.

  2. abstract class AbstractBijection[A, B] extends Bijection[A, B]

    Abstract class to ease Bijection creation from Java.

  3. abstract class AbstractBufferable[T] extends Bufferable[T]

    For Java and avoiding trait bloat

  4. abstract class AbstractInjection[A, B] extends Injection[A, B]

    Abstract class to ease Injection creation from Java (and reduce instance size in scala).

    Abstract class to ease Injection creation from Java (and reduce instance size in scala). Prefer to subclass this for anonymous instances.

  5. type Attempt[T] = Try[T]

    Injections may not be defined for their inverse conversion.

    Injections may not be defined for their inverse conversion. This type represents the attempted conversion. A failure will result in a scala.util.Failure containing the InversionFailure. A success will result in a scala.util.Success containing the inverted value.

    TODO: Remove in 0.6.0.

  6. final case class Base64String(str: String) extends AnyVal with Product with Serializable

  7. trait Bijection[A, B] extends Serializable

    A Bijection[A, B] is a pair of functions that transform an element between types A and B isomorphically; that is, for all items,

    A Bijection[A, B] is a pair of functions that transform an element between types A and B isomorphically; that is, for all items,

    item == someBijection.inverse(someBijection.apply(item))

    Annotations
    @implicitNotFound( ... )
  8. trait BinaryBijections extends StringBijections

    A collection of utilities for encoding strings and byte arrays to and decoding from strings compressed from with gzip.

    A collection of utilities for encoding strings and byte arrays to and decoding from strings compressed from with gzip.

    This object is thread-safe because there are no streams shared outside of method scope, and therefore no contention for shared byte arrays.

  9. trait Bufferable[T] extends Serializable

    Bufferable[T] is a typeclass to work with java.nio.ByteBuffer for serialization/injections to Array[Byte] Always call .duplicate before using the ByteBuffer so the original is not modified (though obviously the backing array is)

    Bufferable[T] is a typeclass to work with java.nio.ByteBuffer for serialization/injections to Array[Byte] Always call .duplicate before using the ByteBuffer so the original is not modified (though obviously the backing array is)

    Annotations
    @implicitNotFound( ... )
  10. class ClassBijection[T] extends Bijection[Class[T], @@[String, Rep[Class[T]]]]

    Bijection between Class objects and string.

  11. class ClassInjection[T] extends AbstractInjection[Class[T], String]

    Injection between Class objects and string.

  12. type Codec[T] = Injection[T, Array[Byte]]

    Using Injections for serialization is a common pattern.

    Using Injections for serialization is a common pattern. Currying the byte array parameter makes it easier to write code like this:

    def getProducer[T: Codec] = ...
  13. trait CollectionBijections extends BinaryBijections

  14. trait CollectionInjections extends StringInjections

  15. trait Conversion[A, B] extends Serializable

  16. final case class Convert[A](a: A) extends AnyVal with Product with Serializable

    Convert allows the user to convert an instance of type A to type B given an implicit Conversion that goes between the two.

    Convert allows the user to convert an instance of type A to type B given an implicit Conversion that goes between the two.

    For example, with an implicit Bijection[String,Array[Byte]], the following works: Array(1.toByte, 2.toByte).as[String]

    Thanks to [hylotech](https://github.com/hylotech/suits/blob/master/src/main/scala/hylotech/util/Bijection.scala) for the following "as" pattern.

  17. trait CrazyLowPriorityConversion extends Serializable

  18. final case class EnglishInt(get: String) extends AnyVal with Product with Serializable

  19. case class Forward[A, B](bijection: Bijection[A, B]) extends ImplicitBijection[A, B] with Product with Serializable

  20. final case class GZippedBase64String(str: String) extends AnyVal with Product with Serializable

  21. final case class GZippedBytes(bytes: Array[Byte]) extends AnyVal with Product with Serializable

  22. trait GeneratedTupleBijections extends LowPriorityBijections

  23. trait GeneratedTupleBufferable extends AnyRef

  24. trait GeneratedTupleCollectionInjections extends LowPriorityInjections

  25. trait GeneratedTupleInjections extends GeneratedTupleCollectionInjections

  26. trait HasRep[A, B] extends AnyRef

    Type class for summoning the function that can check whether the instance can be tagged with Rep

  27. class IdentityBijection[A] extends Bijection[A, A]

  28. sealed trait ImplicitBijection[A, B] extends Serializable

    Annotations
    @implicitNotFound( ... )
  29. trait Injection[A, B] extends Serializable

    An Injection[A, B] is a function from A to B, and from some B back to A.

    An Injection[A, B] is a function from A to B, and from some B back to A. see: http://mathworld.wolfram.com/Injection.html

    Annotations
    @implicitNotFound( ... )
  30. class IntModDivInjection extends Injection[Int, (Int, Int)]

    A common injection on numbers: N -> (m = N mod K, (N-m)/K) The first element in result tuple is always [0, modulus)

  31. case class InversionFailure(failed: Any, ex: Throwable) extends UnsupportedOperationException with Product with Serializable

    When Injection inversion attempts are known to fail, the attempt will encode an InversionFailure to represent that failure

  32. class JavaSerializationInjection[T <: Serializable] extends Injection[T, Array[Byte]]

    Use Java serialization to write/read bytes.

    Use Java serialization to write/read bytes. We avoid manifests here to make it easier from Java

  33. class LongModDivInjection extends Injection[Long, (Long, Long)]

    A common injection on numbers: N -> (m = N mod K, (N-m)/K) The first element in result tuple is always [0, modulus)

  34. trait LowPriorityBijections extends AnyRef

  35. trait LowPriorityConversion extends NotSuperLowPriorityConversion

  36. trait LowPriorityImplicitBijection extends Serializable

  37. trait LowPriorityInjections extends AnyRef

  38. trait NotSuperLowPriorityConversion extends SuperLowPriorityConversion

  39. trait NumericBijections extends GeneratedTupleBijections

  40. trait NumericInjections extends GeneratedTupleInjections

  41. trait Pivot[K, K1, K2] extends Bijection[Iterable[K], Map[K1, Iterable[K2]]]

    Pivot is useful in moving from a 1D space of K to a 2D mapping space of K1 x K2.

    Pivot is useful in moving from a 1D space of K to a 2D mapping space of K1 x K2. If the elements within the K space have many repeated elements -- imagine the "time" component of a Key in a timeseries key-value store -- pivoting the changing component into an inner K2 while leaving the repeated component in an outer K1 can assist in compressing a datastore's space requirements.

    Type Parameters:

    K: Original Key K1: Outer Key K2: Inner Key

    Trivial: Pivot[(Event, Timestamp), Event, Timestamp] would pivot the timestamp component out of a compound key.

  42. trait PivotDecoder[K, K1, K2] extends (Map[K1, Iterable[K2]]) ⇒ Iterable[K] with Serializable

  43. trait PivotEncoder[K, K1, K2] extends (Iterable[K]) ⇒ Map[K1, Iterable[K2]] with Serializable

  44. class PivotImpl[K, K1, K2] extends Pivot[K, K1, K2]

  45. trait Rep[A] extends AnyRef

    Type tag used to indicate that an instance of a type such as String contains a valid representation of another type, such as Int or URL.

  46. case class Reverse[A, B](inv: Bijection[B, A]) extends ImplicitBijection[A, B] with Product with Serializable

  47. trait StringBijections extends NumericBijections

  48. trait StringInjections extends NumericInjections

  49. abstract class SubclassBijection[A, B <: A] extends Bijection[A, B]

    When you have conversion between A and B where B is a subclass of A, which is often free, i.e.

    When you have conversion between A and B where B is a subclass of A, which is often free, i.e. A is already an instance of A, then this can be faster

  50. trait SuperLowPriorityConversion extends CrazyLowPriorityConversion

  51. type Tagged[T] = AnyRef { type Tag = T }

    Tagging infrastructure.

  52. trait TypeclassBijection[T[_]] extends AnyRef

Value Members

  1. object Base64String extends Serializable

  2. object Bijection extends CollectionBijections with Serializable

  3. object Bufferable extends GeneratedTupleBufferable with Serializable

  4. object CastInjection

    Injection to cast back and forth between two types.

    Injection to cast back and forth between two types. WARNING: this uses java's Class.cast, which is subject to type erasure. If you have a type parameterized type, like List[String] => List[Any], the cast will succeed, but the inner items will not be correct. This is intended for experts.

  5. object ClassBijection extends Serializable

  6. object Conversion extends LowPriorityConversion

  7. object EnglishInt extends Serializable

  8. object GZippedBase64String extends Serializable

  9. object ImplicitBijection extends LowPriorityImplicitBijection

  10. object Injection extends CollectionInjections with Serializable

  11. object Inversion

    Factory for applying inversion attempts

  12. object InversionFailure extends Serializable

    Factory for producing InversionFailures

  13. object JavaSerializationInjection extends Serializable

  14. object NumberSystems

  15. object Pivot extends Serializable

  16. object Rep

    Useful HasRep

  17. object StringCodec extends StringInjections

  18. object StringJoinBijection

    Bijection for joining together iterables of strings into a single string and splitting them back out.

    Bijection for joining together iterables of strings into a single string and splitting them back out. Useful for storing sequences of strings in Config maps.

  19. object SwapBijection

    Bijection that flips the order of items in a Tuple2.

  20. object TypeclassBijection

  21. package avro

  22. package clojure

  23. package codec

  24. package finagle_mysql

  25. package guava

  26. package hbase

  27. package jodatime

  28. package json

  29. package json4s

    Since

    1/18/14

  30. package macros

  31. package netty

  32. package protobuf

  33. package scrooge

  34. package thrift

  35. package twitter_util

Inherited from AnyRef

Inherited from Any

Ungrouped