A factory that produces models.
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(); } }
Created by ryan on 1/26/17.
Created by ryan on 1/31/17.
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.
A factory that produces models.
model input type
Model output type