Hi I agree, that this would be somewhat more object-oriented. Do you see a decisive advantage in changing this right now, though? jOOQ has a lot of big if-else blocks that could be transformed into their object-oriented equivalents. Generally, I feel that would be overkill though...
Cheers Lukas 2012/6/8 digulla <[email protected]>: > Hello, > > While browsing the sources, I saw the code in DefaultBindContext and I have > some suggestions how to optimize it. > > Create a StatementSetter interface which has these methods > > set(PreparedStatement stmt, int index, Object value) > handles(Class<?> type) > > and create lots of implementations (one for each type). Put the code from > the if-statement into the handles() method. > > Now you can define a Map<Class<?>, StatementSetter> in DefaultBindContext. > Register all the defaults. When you encounter an unknown type, call > the handles() methods until one returns true and put the handler into the > map with the new key. > > The code in bindValue0() will then become: > > StatementSetter setter = lookup(type); > setter.set(stmt, nextIndex(), value); > > Regards, > > A. Digulla
