Last active
June 17, 2018 07:48
-
-
Save juancho088/fe005a572dc645e96aa5484e508c90ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myblockbuster.core.factories | |
import com.myblockbuster.core.User | |
import com.myblockbuster.core.services.Service | |
import com.myblockbuster.movies.Movie | |
import com.myblockbuster.movies.services.MovieService | |
/** | |
* Interface Factory | |
*/ | |
interface Factory | |
/** | |
* Creates a Service according to the Entity type to manage | |
*/ | |
class ServiceFactory<T>: Factory { | |
fun <T : Any> getService(type: Class<T>): Service<T, User> { | |
return when (type) { | |
Movie::class.java -> MovieService() as Service<T, User> | |
else -> throw IllegalArgumentException() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment