RE: Extended Enumerations

From: Kevin Menard (kmenar..ervprise.com)
Date: Mon Feb 25 2008 - 11:47:50 EST

  • Next message: Kevin Menard: "RE: [JIRA] Closed: (CAY-989) Garbage SQL generated for EJBQL subqueries"

    Right. What I was suggesting was being able to do:

    public interface MyInterface extends ExtendedEnumeration<String>
    {
            public String databaseValue();
    }

    And the Cayenne bit could just accept Object anyway.

    As another suggested improvement, it'd probably be useful to rename
    databaseValue to adhere to the JavaBeans naming convention. It would
    make introspection a bit easier.

    -- 
    Kevin Menard
    Servprise International, Inc.
    Remote reboot & power control for your network
    www.servprise.com                  +1 508.892.3823 x308
    

    > -----Original Message----- > From: Michael Gentry [mailto:blacknex..mail.com] > Sent: Monday, February 25, 2008 11:32 AM > To: de..ayenne.apache.org > Subject: Re: Extended Enumerations > > By typing, I assume you mean the return type? That's why I originally > had two different interfaces: > > public interface IntegerEnumeration > { > public Integer databaseValue(); > } > > public interface StringEnumeration > { > public String databaseValue(); > } > > I then decided to collapse it down into one thinking that might be > easier on the user. Cayenne internally does care which one it is (I > use instanceof Integer/String on the return value to determine it). > It actually made the Cayenne code a tad easier to deal with only one > interface, but the real answer is if it is better for the end-user to > only have to deal with one interface (I think). > > Thanks, > > /dev/mrg > > > On Mon, Feb 25, 2008 at 11:18 AM, Kevin Menard <kmenar..ervprise.com> > wrote: > > All in all, this looks like a good step in the right direction. I > might > > recommend typing ExtendedEnumeration. You may even be able to > constrain > > the domain to both String & Integer via wildcards, but that'd likely > be > > an evil beast to inflict on someone. That would allow you to > tighten > > the contract on the return type though (or at least force the > developer > > to specify it). > > > > On the other hand, if I always work with String or Integer, it could > get > > annoying to type it every time, especially if Cayenne ultimately > doesn't > > care. > > > > -- > > Kevin Menard > > Servprise International, Inc. > > Remote reboot & power control for your network > > www.servprise.com +1 508.892.3823 x308



    This archive was generated by hypermail 2.0.0 : Mon Feb 25 2008 - 11:48:29 EST