Skip to content

Instantly share code, notes, and snippets.

@zeryx
Last active January 22, 2016 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeryx/0b869f403e927652706c to your computer and use it in GitHub Desktop.
Save zeryx/0b869f403e927652706c to your computer and use it in GitHub Desktop.
generic apply method constructors
/**
* Created by james on 22/01/16.
*/
sealed class GenericRecommender extends Constructors{
def apply(constructor: GenericConstructor){
constructor match{
case StdOperation(operationType, algorithmID, properties) =>
...
case NewRec(rectType, algorithmID, properties) =>
...
}
}
}
trait Constructors {
abstract class GenericConstructor
case class StdOperation(operationType: String,
algorithmID: String,
properties: Map[String, String]) extends GenericConstructor
case class NewRec(recType: String,
algorithmID: String,
properties: Map[String, String]) extends GenericConstructor
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment