Class

com.eharmony.aloha.factory

ModelFactoryImpl

Related Doc: package factory

Permalink

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();
    }
}
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
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])

    Permalink

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. val auditor: MorphableAuditor[U, N, B]

    Permalink
  6. def clone(): AnyRef

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

    Permalink

    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
  8. final def debug(msg: ⇒ Any): Unit

    Permalink

    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
  9. final def eq(arg0: AnyRef): Boolean

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

    Permalink

    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
  11. final def error(msg: ⇒ Any): Unit

    Permalink

    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
  12. def finalize(): Unit

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

    Permalink

    Read from a classpath resource.

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

    r

    a classpath resource path.

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

    Permalink

    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
  15. final def fromInputStream(is: InputStream): Try[Model[A, B]]

    Permalink

    Read from an InputStream.

    Read from an InputStream.

    is

    an InputStream to read. The InputStream is automatically closed.

    returns

    the result

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

    Permalink

    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
  17. def fromMultipleSources(readableTypes: Collection[ReadableSource]): Collection[Try[Model[A, B]]]

    Permalink

    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

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

    Permalink

    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
  19. final def fromReader(r: Reader): Try[Model[A, B]]

    Permalink

    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
  20. def fromResource(r: String): Try[Model[A, B]]

    Permalink

    Read from a resource.

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

    r

    a resource path.

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

    Permalink

    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

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

    Permalink

    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
  23. def fromUrl(u: URL): Try[Model[A, B]]

    Permalink

    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
  24. def fromVfs1(foVfs1: FileObject): Try[Model[A, B]]

    Permalink

    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
  25. def fromVfs2(foVfs2: FileObject): Try[Model[A, B]]

    Permalink

    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
  26. final def getClass(): Class[_]

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

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

    Permalink

    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
  29. final def info(msg: ⇒ Any): Unit

    Permalink

    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
  30. val inputCharset: String

    Permalink

    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
  31. final def isDebugEnabled: Boolean

    Permalink

    Determine whether debug logging is enabled.

    Determine whether debug logging is enabled.

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

    Permalink

    Determine whether error logging is enabled.

    Determine whether error logging is enabled.

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

    Permalink

    Determine whether info logging is enabled.

    Determine whether info logging is enabled.

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

    Permalink
    Definition Classes
    Any
  35. final def isTraceEnabled: Boolean

    Permalink

    Determine whether trace logging is enabled.

    Determine whether trace logging is enabled.

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

    Permalink

    Determine whether warn logging is enabled.

    Determine whether warn logging is enabled.

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

    Permalink

    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
  38. def loggerInitName(): String

    Permalink

    The name with which the logger is initialized.

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

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

    Permalink

    Get the name associated with this logger.

    Get the name associated with this logger.

    returns

    the name.

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

    Permalink

    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
  41. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  42. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  43. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  44. val parsers: Seq[ModelParser]

    Permalink
  45. val refInfoToJsonFormat: RefInfoToJsonFormat

    Permalink
  46. val semantics: Semantics[A]

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

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

    Permalink

    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
  49. final def trace(msg: ⇒ Any): Unit

    Permalink

    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
  50. final def wait(): Unit

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

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

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

    Permalink

    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
  54. final def warn(msg: ⇒ Any): Unit

    Permalink

    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