Package

com.eharmony.aloha

factory

Permalink

package factory

Visibility
  1. Public
  2. All

Type Members

  1. trait JavaJsonFormats extends AnyRef

    Permalink
  2. sealed abstract class ModelFactory[A, B] extends ReadableByString[Try[Model[A, B]]] with GZippedReadable[Try[Model[A, B]]] with LocationLoggingReadable[Try[Model[A, B]]] with MultipleAlohaReadable[Try[Model[A, B]]] with SequenceMultipleReadable[ReadableSource, Try, Model[A, B]] with Logging

    Permalink

    A factory that produces models.

    A factory that produces models.

    A

    model input type

    B

    Model output type

  3. 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

    Permalink

    A ModelFactory is responsible for creating models from model specifications.

    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();
        }
    }
  4. sealed trait ModelParser extends AnyRef

    Permalink

    Created by ryan on 1/26/17.

  5. trait ModelParsingPlugin extends ModelParser

    Permalink
  6. trait ModelSubmodelParsingPlugin extends ModelParsingPlugin with SubmodelParsingPlugin

    Permalink
  7. trait Parser[-A, +B] extends AnyRef

    Permalink
  8. trait ParserProviderCompanion extends AnyRef

    Permalink
  9. trait ScalaJsonFormats extends AnyRef

    Permalink
  10. trait SubmodelFactory[U, A] extends AnyRef

    Permalink

    Created by ryan on 1/31/17.

  11. trait SubmodelParsingPlugin extends ModelParser

    Permalink

Value Members

  1. object Formats extends JavaJsonFormats with ScalaJsonFormats

    Permalink
  2. object JavaJsonFormats extends JavaJsonFormats

    Permalink
  3. object ModelFactory extends RuntimeClasspathScanning

    Permalink
  4. object ScalaJsonFormats extends ScalaJsonFormats

    Permalink
  5. package ex

    Permalink
  6. package jsext

    Permalink
  7. package ri2jf

    Permalink

    Provides conversions from RefInfo to spray-json's JsonFormat.

    Provides conversions from RefInfo to spray-json's JsonFormat. This allows the library user to omit including a JsonFormat. Instead, the user supplies a function to perform the conversion.

Ungrouped