Package

com.twitter

bijection

Permalink

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.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. bijection
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

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

    Permalink

    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]

    Permalink

    Abstract class to ease Bijection creation from Java.

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

    Permalink

    For Java and avoiding trait bloat

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

    Permalink

    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]

    Permalink

    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

    Permalink
  7. trait Bijection[A, B] extends Serializable

    Permalink

    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

    Permalink

    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

    Permalink

    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. trait BufferableVersionSpecific extends AnyRef

    Permalink

    Version specific imlementation for Bufferable on scala 2.13+

  11. class ClassBijection[T] extends Bijection[Class[T], @@[String, Rep[Class[T]]]]

    Permalink

    Bijection between Class objects and string.

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

    Permalink

    Injection between Class objects and string.

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

    Permalink

    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] = ...
  14. trait CollectionBijections extends BinaryBijections

    Permalink
  15. trait CollectionInjections extends StringInjections

    Permalink
  16. trait Conversion[A, B] extends Serializable

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

    Permalink

    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.

  18. trait CrazyLowPriorityConversion extends Serializable

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

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

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

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

    Permalink
  23. trait GeneratedTupleBijections extends LowPriorityBijections

    Permalink
  24. trait GeneratedTupleBufferable extends AnyRef

    Permalink
  25. trait GeneratedTupleCollectionInjections extends LowPriorityInjections

    Permalink
  26. trait GeneratedTupleInjections extends GeneratedTupleCollectionInjections

    Permalink
  27. trait HasRep[A, B] extends AnyRef

    Permalink

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

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

    Permalink
  29. sealed trait ImplicitBijection[A, B] extends Serializable

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

    Permalink

    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( ... )
  31. class IntModDivInjection extends Injection[Int, (Int, Int)]

    Permalink

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

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

    Permalink

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

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

    Permalink

    Use Java serialization to write/read bytes.

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

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

    Permalink

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

  35. trait LowPriorityBijections extends AnyRef

    Permalink
  36. trait LowPriorityConversion extends NotSuperLowPriorityConversion

    Permalink
  37. trait LowPriorityImplicitBijection extends Serializable

    Permalink
  38. trait LowPriorityInjections extends AnyRef

    Permalink
  39. trait NotSuperLowPriorityConversion extends SuperLowPriorityConversion

    Permalink
  40. trait NumericBijections extends GeneratedTupleBijections

    Permalink
  41. trait NumericInjections extends GeneratedTupleInjections

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

    Permalink

    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.

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

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

    Permalink
  45. class PivotImpl[K, K1, K2] extends Pivot[K, K1, K2]

    Permalink
  46. trait Rep[A] extends AnyRef

    Permalink

    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.

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

    Permalink
  48. trait StringBijections extends NumericBijections

    Permalink
  49. trait StringInjections extends NumericInjections

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

    Permalink

    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

  51. trait SuperLowPriorityConversion extends CrazyLowPriorityConversion

    Permalink
  52. type Tagged[T] = AnyRef { type Tag = T }

    Permalink

    Tagging infrastructure.

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

    Permalink

Value Members

  1. object Base64String extends Serializable

    Permalink
  2. object Bijection extends CollectionBijections with Serializable

    Permalink
  3. object Bufferable extends BufferableVersionSpecific with GeneratedTupleBufferable with Serializable

    Permalink
  4. object CastInjection

    Permalink

    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

    Permalink
  6. object Conversion extends LowPriorityConversion

    Permalink
  7. object EnglishInt extends Serializable

    Permalink
  8. object GZippedBase64String extends Serializable

    Permalink
  9. object ImplicitBijection extends LowPriorityImplicitBijection

    Permalink
  10. object Injection extends CollectionInjections with Serializable

    Permalink
  11. object Inversion

    Permalink

    Factory for applying inversion attempts

  12. object InversionFailure extends Serializable

    Permalink

    Factory for producing InversionFailures

  13. object JavaSerializationInjection extends Serializable

    Permalink
  14. object NumberSystems

    Permalink
  15. object Pivot extends Serializable

    Permalink
  16. object Rep

    Permalink

    Useful HasRep

  17. object StringCodec extends StringInjections

    Permalink
  18. object StringJoinBijection

    Permalink

    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

    Permalink

    Bijection that flips the order of items in a Tuple2.

  20. object TypeclassBijection

    Permalink
  21. package codec

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped