Java enums in generic type -


I want to make a generic nem-based mapper for IBTIS. I am doing this with the code below, it compiles errors of time, which I do not have to fix, maybe my solution is just wrong (keep in mind the use of IBTI), in such a way please give some better suggestions.

Any help appreciated.

What I want to achieve define later mappers:

  Public class XEnumTypeHandler expanded CommonEnumTypeHandler & lt; X & gt; {}  

Current code:

  public class CommonEnumTypeHandler & lt; T extended Enum & gt; Applicable TypeHandler callback throws {SQLException to public peer set parameter (parametersetter ps, object o) {if (o.g.class ()) isAssignableFrom (** T **)) {ps.setString (((** ** (** **) **) o). Value () .toUpperCase ()); } Again, throw a new SQLException ("Stunning Paramater Type Object" from: "+ o);} Public Object throws the GetResult (ResultGetter RS) SQLException {Object o = valueOf (rs.getString ()); if (o == faucet) New SQL Connection ("Unknown Parameter Type:" + + throwing rsgetstring ()); Return O;} Public Object Value (Strings) {For (T pt: T ** Price () **) {If (pt. ** Value () **. Equal sign (s)) return pt;} return tap;}}  

I have given the error signs as above Error message is in order:

  • T can not be solved
  • method value () is mandatory for
  • I have solved this problem with the following code:

  • Public class CommonEnumTypeHandler & lt; t extends Enum & gt; Applicable typehandler callback {class clazz; Public CommonEnumTypeHandler (class T & gt; clazz) { This.clazz = clazz; } Public zeros set parametermer (parametter ps, object o) sends SQL conception {if (ogateclass ()) isAssignableFrom (clazz)} {ps.setString ((t) o) .name () ToUpperCase ()); } Again throw the new SQLException ("Excellent" + clazz + "Object:" + o); } Public object getResult (ResultGetter RS) throws SQLException {object o = valueOf (rs.getString ()); If (o == faucet) throwing new SQL preference ("unknown parameter type:" + + rsgetstring ()); Return O; } Public object valueOf (strings) {return Enum.valueOf (clazz, s); }}

    I'm inheriting from this class:

      Public-class sales channelsLipHandler generatesNanamTypHandler Expand & lt; SalesChannel & gt; {Public SalesChannel Typ Handler () {Super (SalesChannel Class); } Public Sales ChannelLipHandler (Class & Lt; SalesChannel & gt; Clauses) {Super (Clause); }}  

I'm not sure what you are doing (general observation word good

  • You can not do isAssignableFrom (T) (you need a class item), and you < Code> T for example can not (generics are non-certified).
  • Li> It is still unclear what is desired, but perhaps it is not even clear
  • This is something on the lines of this:

      fold color {black, white; } Public static zero main (string [] args) {color c = Enum.valueOf (Color.class, "black" .toUpperCase ()); Println (c); // print "black"}  

    then we use it which is a type of token class , and it has name value with any name not case-insensitive, but from conferences, all constants should be in uppercase, so we only take the query string and turn it on .toUpperCase () .


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -