Scala function that returns requested type -


i have configuration file several properties in (mostly) json format

"server_name": "fooserver", "server_port": [9999], "debug": "false", "max_users": [1000], "max_instances": [5] 

that i'm loading via typesafe config library. have wrapper class has function returns property based on name. want able call

config.get("server_name")  

and have string "fooserver" returned me. or int, or boolean, depending on value type in configuration.

my current function here:

val factory = configfactory.load()  def get(configvalue: string) : anyref = {    val javaobject = factory.getanyref(configvalue)    //return } 

which sadly not compile. getanyref function returns whatever config value unwrapped boxed java object, handles type inference config file. should match on type of object? should return type function? anyref closest thing found all-inclusive type.

i realize scala functions must specify return type, there way can away simple syntax have?

any , anyref mixed sometimes, can use any instead , should compile.


Comments

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -