lbehnke / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

Suggestion: as of H2 requires Java5 or later use enum instead of int const for Trigger #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Enums, are more developer friendly and ofter more then int-consts.
So how about convert
 /**The trigger is called for INSERT statements. */
 int INSERT = 1;
 /** The trigger is called for UPDATE statements.*/
 int UPDATE = 2;
 /** The trigger is called for DELETE statements. */
 int DELETE = 4;

to smth. like this:

public enum TriggerType
{
 /**The trigger is called for INSERT statements. */
 INSERT(1), 
 /** The trigger is called for UPDATE statements.*/
 int UPDATE(2),
 /** The trigger is called for DELETE statements. */
 int DELETE(3);

 private final int code;
 private TriggerType(int code)
 {this.code = code;}

 /** get code for backward compatibility */
 public int getCode()
 {return code;}
}

Yes, it can lead to breaking of existing code
 and old code would need some changes to be compatible with enum instead 
of int-consts.

It is just a suggestion.

Original issue reported on code.google.com by kua...@gmail.com on 6 Oct 2009 at 7:29

GoogleCodeExporter commented 9 years ago
I don't think I will change the API because of that, but if I anyway have to 
change
it I will consider it.

Moved to the roadmap.

Original comment by thomas.t...@gmail.com on 7 Oct 2009 at 7:08

GoogleCodeExporter commented 9 years ago
Yes, there no reason to break API right now.

But may by for H2 v2.0 it would be very reasonable to replace ALL such consts 
to 
enums across all code base, not just Trigger interface.

With enums you code base would be more safe and readable and usable.

Original comment by kua...@gmail.com on 8 Oct 2009 at 4:00