uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Tomás Atria <jtat...@gmail.com>
Subject @ConfParam initialization of values from symbol name of static instance?
Date Wed, 26 Apr 2017 20:29:19 GMT
Hello all!

I know that UIMA-FIT is capable of initializing enum-typed configuration
parameters from a string equal to the name of one of the values in an enum
class. i.e. this works as documented:

public static enum SomeEnum {
    A_VALUE;
}

@ConfigurationParameter( name = "example", mandatory = false,
defaultValue="A_VALUE" )
private SomeEnum enumValue;

However, I recently had to refactor one my enums into a normal class with
static members, and I found that UIMA-FIT is equally capable of
initializing these parameters from a string equal to the symbol of a class
instance set up as a static member i.e. this also works:

public static class SomeClass {
    public static final SomeClass A_VALUE = new SomeClass()
}

@ConfigurationParameter( name = "example", mandatory = false,
defaultValue="A_VALUE" )
private SomeClass classValue;

Is this known behaviour? I tried stepping through the conf param
initialization logic, but I got lost in the depths of Spring, and I get the
feeling that this is basically a side-effect of spring's implementation of
enum initialization details, which seems a little unreliable... Then again,
enum types are basically immutable collections of class instances as static
members, no?

Is it reasonable to use this "feature"? if so, should it be mentioned in
the documentation?

I have attached a working example of what I mean if my explanation above
doesn't make sense.

Any comments would be welcome, I'm very curious to know why this works and
whether it is reliable enough to be used in production...

Thanks!
jta

ps: reposting from the abandoned uima-fit mailing list. Sorry for
crossposting!
-- 

sent from a phone. please excuse terseness and tpyos.

enviado desde un teléfono. por favor disculpe la parquedad y los erroers.

Mime
View raw message