deaktator.pops.fn

ProtoAccessor

object ProtoAccessor extends Serializable

Contains either and option factory methods to produce ProtoAccessor from string-based paths. Note that conversions can be called explicitly or can be used implicitly. In the following examples, Score's definition can be found at aloha-proto/Scores.proto.

import com.eharmony.aloha.score.Scores.Score

// Explicit
val a1: Either[String, ProtoAccessor[Score, Option[Long]]] =
  ProtoAccessor.either[Score, Option[Long]]("error.model.id")

// a2: Either[String, ProtoAccessor[Score, Option[Long]]]
val a2 = ProtoAccessor.either[Score, Option[Long]]("error.model.id")

// Implicit
val a3: Either[String, ProtoAccessor[Score, Option[String]]] = "error.model.name"

// Implicit, many at a time ...
val as: Seq[Either[String, ProtoAccessor[Score, Option[Long]]]] =
  Seq("error.model.id", "error.model.id")

If error information isn't important, use the Option-based API:

import com.eharmony.aloha.score.Scores.Score

// Explicit

val a1: Option[ProtoAccessor[Score, Option[Long]]] =
  ProtoAccessor.option[Score, Option[Long]]("error.model.id")

// Implicit

val a3: Option[ProtoAccessor[Score, Option[String]]] = "error.model.name"

An attempt is made to fully respect types so the following won't work because "error.model.id" is represented by a Long in the protobuf definition:

// Returns error message on the Left.
import com.eharmony.aloha.score.Scores.Score
val a1: Either[String, ProtoAccessor[Score, Option[Int]]] = "error.model.id"

Additionally, Option and non-Option based accessors are respected. If a non-required path element is found in the path, and the accessor doesn't return an Option, an error will be returned:

// Returns error message on the Left because "error" is optional in the PB definition.
import com.eharmony.aloha.score.Scores.Score
val a1: Either[String, ProtoAccessor[Score, Long]] = "error.model.id"
Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ProtoAccessor
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. implicit def either[A <: GeneratedMessage, B](path: String)(implicit ops: ProtoOps[A], c: Caster[A, B]): Either[String, ProtoAccessor[A, B]]

    Attempt to create a protobuf accessor: Right(ProtoAccessor[A, B]).

    Attempt to create a protobuf accessor: Right(ProtoAccessor[A, B]). If an error is encountered Left will contain the error message.

    A

    type of GeneratedMessage from which data should be extracted.

    B

    type of data to be extracted from A.

    path

    the path string

    ops

    an instance of deaktator.pops.msgs.ProtoOps to help with accessor function creation.

    c

    a caster that takes the untyped value returned by the PB reflection APIs and provides a typesafe value.

    returns

    an accessor on the right or an error message on the left.

  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  18. implicit def option[A <: GeneratedMessage, B](path: String)(implicit ops: ProtoOps[A], c: Caster[A, B]): Option[ProtoAccessor[A, B]]

    Attempt to create a protobuf accessor: Some(ProtoAccessor[A, B]).

    Attempt to create a protobuf accessor: Some(ProtoAccessor[A, B]). If an error is encountered None is returned. This doesn't provide diagnostic information like ProtoAccessor.either does.

    A

    type of GeneratedMessage from which data should be extracted.

    B

    type of data to be extracted from A.

    path

    the path string

    ops

    an instance of deaktator.pops.msgs.ProtoOps to help with accessor function creation.

    c

    a caster that takes the untyped value returned by the PB reflection APIs and provides a typesafe value.

    returns

    an accessor or None if an error is encountered.

  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  20. def toString(): String

    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped