com.eharmony.aloha.factory

ModelFactoryImpl

case class ModelFactoryImpl[U, N, A, B <: U](semantics: Semantics[A], auditor: MorphableAuditor[U, N, B], parsers: Seq[ModelParser], refInfoToJsonFormat: RefInfoToJsonFormat)(implicit refInfo: RefInfo[N]) extends ModelFactory[A, B] with Product with Serializable

A ModelFactory is responsible for creating models from model specifications.

// ===  SCALA CODE  ========================================================

val semantics: Semantics[A] = ???
// For instance OptionAuditor[Double]() is a MorphableAuditor[Opiton[_], Double, Option[Double]]
val auditor: MorphableAuditor[U, N, B] = ???
val json: String = ???

val factory = ModelFactory.defaultFactory(semantics, auditor)
val modelTry: Try[Model[A, B]] = factory.fromString(json)     // safe
val model: Model[A, B] = modelTry.get                         // unsafe

NOTE: ModelFactory has been completely rewritten. There's no longer a notion of an untyped model factory.

From Scala, it is recommended to use code (like the code above), as type information is retained.

From Java, the easiest method of instantiation is to use Spring to instantiate the factory.

// ===  JAVA CODE  ========================================================
// Set up Spring to inject class ...
public class X {
    // Injected from Spring
    @Resource
    private AlohaReadable<Try<Model<TestProto, Double>>> modelFactory = null;

    public Model<TestProto, Double> getModelFromClasspath(String path) {
        return modelFactory.fromClasspath(path).get();
    }
}
U
N
A
B

semantics
auditor
parsers
refInfoToJsonFormat

Self Type
ModelFactoryImpl[U, N, A, B]
Linear Supertypes
Serializable, Serializable, Product, Equals, ModelFactory[A, B], Logging, SequenceMultipleReadable[ReadableSource, Try, Model[A, B]], MultipleAlohaReadable[Try[Model[A, B]]], MultipleReadable[ReadableSource, Try[Model[A, B]]], LocationLoggingReadable[Try[Model[A, B]]], GZippedReadable[Try[Model[A, B]]], ReadableByString[Try[Model[A, B]]], FileReadableByInputStream[Try[Model[A, B]]], AlohaReadable[Try[Model[A, B]]], NonFileReadable[Try[Model[A, B]]], FileReadable[Try[Model[A, B]]], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ModelFactoryImpl
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. ModelFactory
  7. Logging
  8. SequenceMultipleReadable
  9. MultipleAlohaReadable
  10. MultipleReadable
  11. LocationLoggingReadable
  12. GZippedReadable
  13. ReadableByString
  14. FileReadableByInputStream
  15. AlohaReadable
  16. NonFileReadable
  17. FileReadable
  18. AnyRef
  19. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ModelFactoryImpl(semantics: Semantics[A], auditor: MorphableAuditor[U, N, B], parsers: Seq[ModelParser], refInfoToJsonFormat: RefInfoToJsonFormat)(implicit refInfo: RefInfo[N])

    semantics
    auditor
    parsers
    refInfoToJsonFormat

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. val auditor: MorphableAuditor[U, N, B]

  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. final def debug(msg: ⇒ Any, t: ⇒ Throwable): Unit

    Issue a debug logging message, with an exception.

    Issue a debug logging message, with an exception.

    msg

    the message object. toString() is called to convert it to a loggable string.

    t

    the exception to include with the logged message.

    Attributes
    protected[this]
    Definition Classes
    Logging
  10. final def debug(msg: ⇒ Any): Unit

    Issue a debug logging message.

    Issue a debug logging message.

    msg

    the message object. toString() is called to convert it to a loggable string.

    Attributes
    protected[this]
    Definition Classes
    Logging
  11. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  12. final def error(msg: ⇒ Any, t: ⇒ Throwable): Unit

    Issue a error logging message, with an exception.

    Issue a error logging message, with an exception.

    msg

    the message object. toString() is called to convert it to a loggable string.

    t

    the exception to include with the logged message.

    Attributes
    protected[this]
    Definition Classes
    Logging
  13. final def error(msg: ⇒ Any): Unit

    Issue a error logging message.

    Issue a error logging message.

    msg

    the message object. toString() is called to convert it to a loggable string.

    Attributes
    protected[this]
    Definition Classes
    Logging
  14. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. def fromClasspathResource(r: String): Try[Model[A, B]]

    Read from a classpath resource.

    Read from a classpath resource. This uses fromVfs2 under the hood.

    r

    a classpath resource path.

    returns

    Definition Classes
    FileReadableByInputStreamFileReadable
  16. def fromFile(f: File): Try[Model[A, B]]

    Read from a file.

    Read from a file. Logs the file.

    f

    a file to read. The file's InputStream is automatically closed.

    returns

    the result

    Definition Classes
    LocationLoggingReadableFileReadableByInputStreamFileReadable
  17. final def fromInputStream(is: InputStream): Try[Model[A, B]]

    Read from an InputStream.

    Read from an InputStream.

    is

    an InputStream to read. The InputStream is automatically closed.

    returns

    the result

    Definition Classes
    ReadableByStringFileReadableByInputStreamNonFileReadable
  18. def fromMultipleSources[F[_]](readableTypes: F[ReadableSource])(implicit f: Functor[F]): F[Try[Model[A, B]]]

    Parse a bunch of readable sources given a Functor (see Functors, Monads, Applicatives – can be so simple).

    Parse a bunch of readable sources given a Functor (see Functors, Monads, Applicatives – can be so simple).

    F

    the functor type

    readableTypes

    a container of instances to convert into type the output type

    f

    a function instance

    returns

    a container F of the output type B

    Definition Classes
    MultipleReadable
  19. def fromMultipleSources(readableTypes: Collection[ReadableSource]): Collection[Try[Model[A, B]]]

    Parse a bunch of readable sources from a java collection and return the results.

    Parse a bunch of readable sources from a java collection and return the results.

    readableTypes

    a collection of sources from which

    returns

    Definition Classes
    MultipleReadable
  20. def fromMultipleSources(readableTypes: List[ReadableSource]): List[Try[Model[A, B]]]

    Parse a list of readable sources and return the results.

    Parse a list of readable sources and return the results.

    readableTypes

    a list of readable sources containing the necessary information to parse the resource and produce the proper outputs.

    returns

    a list of objects produced by parsing the resources in the readable types.

    Definition Classes
    MultipleReadable
  21. final def fromReader(r: Reader): Try[Model[A, B]]

    Read from a Reader.

    Read from a Reader. Whoever extends this trait is responsible for closing the Reader.

    r

    a Reader containing data to be read.

    returns

    the result

    Definition Classes
    ReadableByStringNonFileReadable
  22. def fromResource(r: String): Try[Model[A, B]]

    Read from a resource.

    Read from a resource. This uses fromVfs2 under the hood.

    r

    a resource path.

    returns

    Definition Classes
    FileReadableByInputStreamFileReadable
  23. def fromSequencedMultipleSources[T[_]](readableTypes: T[ReadableSource])(implicit t: Traverse[T], ap: Applicative[Try]): Try[T[Model[A, B]]]

    Produce multiple outputs from multiple inputs and sequence the data so that we commute that container types.

    Produce multiple outputs from multiple inputs and sequence the data so that we commute that container types. For an example, see that trait documentation.

    T

    the Traverse container type

    readableTypes

    A container of readable sources to convert to outputs.

    t

    a Traverse type class instance

    ap

    an applicative function type class instance

    returns

    Definition Classes
    SequenceMultipleReadable
  24. def fromString(s: String): Try[Model[A, B]]

    The recommended API method from Java.

    The recommended API method from Java. It's also equally valid to use any of the other methods provided by com.eharmony.aloha.io.AlohaReadable trait. It throws away the kind information (encoded in the type parameter M) that is retained the in Scala environment.

    s

    String representation of the model.

    returns

    scala.util.Try of a com.eharmony.aloha.models.Model[A, B].

    Definition Classes
    ModelFactoryImplNonFileReadable
  25. def fromUrl(u: URL): Try[Model[A, B]]

    Read from a URL.

    Read from a URL. Logs the URL.

    u

    a URL to read. The URL's InputStream is automatically closed.

    returns

    the result

    Definition Classes
    LocationLoggingReadableFileReadableByInputStreamFileReadable
  26. def fromVfs1(foVfs1: FileObject): Try[Model[A, B]]

    Read from an Apache VFS v1 FileObject.

    Read from an Apache VFS v1 FileObject. Logs the file object location.

    foVfs1

    an Apache VFS v1 FileObject to read. The FileObject's InputStream is automatically closed.

    returns

    the result

    Definition Classes
    LocationLoggingReadableFileReadableByInputStreamFileReadable
  27. def fromVfs2(foVfs2: FileObject): Try[Model[A, B]]

    Read from an Apache VFS v1 FileObject.

    Read from an Apache VFS v1 FileObject. Logs the file object location.

    foVfs2

    an Apache VFS v1 FileObject to read. The FileObject's InputStream is automatically closed.

    returns

    the result

    Definition Classes
    LocationLoggingReadableFileReadableByInputStreamFileReadable
  28. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  29. def gz: FileReadableByInputStream[Try[Model[A, B]]] with MultipleFileReadable[Try[Model[A, B]]]

    Definition Classes
    GZippedReadable
  30. final def info(msg: ⇒ Any, t: ⇒ Throwable): Unit

    Issue a info logging message, with an exception.

    Issue a info logging message, with an exception.

    msg

    the message object. toString() is called to convert it to a loggable string.

    t

    the exception to include with the logged message.

    Attributes
    protected[this]
    Definition Classes
    Logging
  31. final def info(msg: ⇒ Any): Unit

    Issue a info logging message.

    Issue a info logging message.

    msg

    the message object. toString() is called to convert it to a loggable string.

    Attributes
    protected[this]
    Definition Classes
    Logging
  32. val inputCharset: String

    The character set that is used to decode the input streams in fromInputStream in the derived classes.

    The character set that is used to decode the input streams in fromInputStream in the derived classes.

    Attributes
    protected
    Definition Classes
    ReadableByString
  33. final def isDebugEnabled: Boolean

    Determine whether debug logging is enabled.

    Determine whether debug logging is enabled.

    Attributes
    protected[this]
    Definition Classes
    Logging
  34. final def isErrorEnabled: Boolean

    Determine whether error logging is enabled.

    Determine whether error logging is enabled.

    Attributes
    protected[this]
    Definition Classes
    Logging
  35. final def isInfoEnabled: Boolean

    Determine whether info logging is enabled.

    Determine whether info logging is enabled.

    Attributes
    protected[this]
    Definition Classes
    Logging
  36. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  37. final def isTraceEnabled: Boolean

    Determine whether trace logging is enabled.

    Determine whether trace logging is enabled.

    Attributes
    protected[this]
    Definition Classes
    Logging
  38. final def isWarnEnabled: Boolean

    Determine whether warn logging is enabled.

    Determine whether warn logging is enabled.

    Attributes
    protected[this]
    Definition Classes
    Logging
  39. final lazy val logger: Logger

    The logger is a @transient lazy val to enable proper working with Spark.

    The logger is a @transient lazy val to enable proper working with Spark. The logger will not be serialized with the rest of the class with which this trait is mixed-in.

    Attributes
    protected[this]
    Definition Classes
    Logging
  40. def loggerInitName(): String

    The name with which the logger is initialized.

    The name with which the logger is initialized. This can be overridden in a derived class.

    returns

    Attributes
    protected
    Definition Classes
    Logging
  41. final def loggerName: String

    Get the name associated with this logger.

    Get the name associated with this logger.

    returns

    the name.

    Attributes
    protected[this]
    Definition Classes
    Logging
  42. val mapper: (ReadableSource) ⇒ Try[Model[A, B]]

    A function that maps from the Readable type to the output type.

    A function that maps from the Readable type to the output type.

    returns

    a function.

    Definition Classes
    MultipleAlohaReadableMultipleReadable
  43. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  46. val parsers: Seq[ModelParser]

  47. val refInfoToJsonFormat: RefInfoToJsonFormat

  48. val semantics: Semantics[A]

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

    Definition Classes
    AnyRef
  50. final def trace(msg: ⇒ Any, t: ⇒ Throwable): Unit

    Issue a trace logging message, with an exception.

    Issue a trace logging message, with an exception.

    msg

    the message object. toString() is called to convert it to a loggable string.

    t

    the exception to include with the logged message.

    Attributes
    protected[this]
    Definition Classes
    Logging
  51. final def trace(msg: ⇒ Any): Unit

    Issue a trace logging message.

    Issue a trace logging message.

    msg

    the message object. toString() is called to convert it to a loggable string.

    Attributes
    protected[this]
    Definition Classes
    Logging
  52. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. final def warn(msg: ⇒ Any, t: ⇒ Throwable): Unit

    Issue a warn logging message, with an exception.

    Issue a warn logging message, with an exception.

    msg

    the message object. toString() is called to convert it to a loggable string.

    t

    the exception to include with the logged message.

    Attributes
    protected[this]
    Definition Classes
    Logging
  56. final def warn(msg: ⇒ Any): Unit

    Issue a warn logging message.

    Issue a warn logging message.

    msg

    the message object. toString() is called to convert it to a loggable string.

    Attributes
    protected[this]
    Definition Classes
    Logging

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from ModelFactory[A, B]

Inherited from Logging

Inherited from SequenceMultipleReadable[ReadableSource, Try, Model[A, B]]

Inherited from MultipleAlohaReadable[Try[Model[A, B]]]

Inherited from MultipleReadable[ReadableSource, Try[Model[A, B]]]

Inherited from LocationLoggingReadable[Try[Model[A, B]]]

Inherited from GZippedReadable[Try[Model[A, B]]]

Inherited from ReadableByString[Try[Model[A, B]]]

Inherited from FileReadableByInputStream[Try[Model[A, B]]]

Inherited from AlohaReadable[Try[Model[A, B]]]

Inherited from NonFileReadable[Try[Model[A, B]]]

Inherited from FileReadable[Try[Model[A, B]]]

Inherited from AnyRef

Inherited from Any

Ungrouped