asheshsaraf / squiggle-sql

Automatically exported from code.google.com/p/squiggle-sql
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Use enums for MatchCriteria operators #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Instead of using the String constants MatchCriteria.EQUALS, 
MatchCriteria.GREATER, etc, an enum should be created for these operators.

This way, we could better assure the type safety of MatchCriteria's 
constructors, that currently will accept anything as a valid operator. 
e.g.:

 Criteria criteria = new MatchCriteria(myColumn, "~=", 42);

The constructors accepting String should be @deprecated and their 
implementation would be changed to use the correct enum value (or throw 
java.lang.IllegalArgumentException).

Original issue reported on code.google.com by brunoabdon on 6 Aug 2010 at 5:06

GoogleCodeExporter commented 8 years ago
But that would leave JDK < 5 users in the dust. Just my 2 cents :P. A better 
approach would be to white list the received argument against the set of match 
criteria constants. I admit though, that this may exclude exotic operators, but 
it may be a good start. Thanks!

Original comment by jjzaz...@gmail.com on 17 Aug 2010 at 7:24

GoogleCodeExporter commented 8 years ago
I don't see a problem since the project specifies:
"No dependencies on classes outside of JDK 1.5"

Original comment by hir...@gmail.com on 8 Oct 2010 at 4:27