-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into converters_v2
Conflicts: core/src/main/java/org/sql2o/PojoResultSetIterator.java
- Loading branch information
Showing
22 changed files
with
929 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.sql2o; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* User: dimzon | ||
* Date: 4/7/14 | ||
* Time: 12:01 AM | ||
*/ | ||
public interface ResultSetHandler<T> { | ||
T handle(ResultSet resultSet) throws SQLException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.sql2o; | ||
|
||
import java.sql.ResultSetMetaData; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* User: dimzon | ||
* Date: 4/7/14 | ||
* Time: 12:02 AM | ||
*/ | ||
public interface ResultSetHandlerFactory { | ||
<T> ResultSetHandler<T> newResultSetHandler(Class<T> type, ResultSetMetaData resultSetMetaData) throws SQLException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
core/src/main/java/org/sql2o/reflection/FactoryFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.sql2o.reflection; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
|
||
@SuppressWarnings("Unsafe") | ||
public class FactoryFacade { | ||
private final static FactoryFacade instance; | ||
|
||
static { | ||
MethodSetterFactory m; | ||
try { | ||
m = (MethodSetterFactory) Class | ||
.forName("org.sql2o.reflection.MethodAccessorsGenerator") | ||
.newInstance(); | ||
} catch (Throwable ex) { | ||
m = new ReflectionMethodSetterFactory(); | ||
} | ||
FieldSetterFactory f; | ||
ObjectConstructorFactory o; | ||
try { | ||
Class cls = Class.forName("org.sql2o.reflection.UnsafeFieldSetterFactory"); | ||
f = (FieldSetterFactory) cls.newInstance(); | ||
o = (ObjectConstructorFactory) f; | ||
} catch (Throwable ex) { | ||
f = new ReflectionFieldSetterFactory(); | ||
o = new ReflectionObjectConstructorFactory(); | ||
} | ||
instance = new FactoryFacade(f, m, o); | ||
} | ||
|
||
private final FieldSetterFactory fieldSetterFactory; | ||
private final MethodSetterFactory methodSetterFactory; | ||
private final ObjectConstructorFactory objectConstructorFactory; | ||
|
||
public FactoryFacade(FieldSetterFactory fieldSetterFactory, MethodSetterFactory methodSetterFactory, ObjectConstructorFactory objectConstructorFactory) { | ||
this.fieldSetterFactory = fieldSetterFactory; | ||
this.methodSetterFactory = methodSetterFactory; | ||
this.objectConstructorFactory = objectConstructorFactory; | ||
} | ||
|
||
public static FactoryFacade getInstance() { | ||
return instance; | ||
} | ||
|
||
public Setter newSetter(Field field) { | ||
return fieldSetterFactory.newSetter(field); | ||
} | ||
|
||
public Setter newSetter(Method method) { | ||
return methodSetterFactory.newSetter(method); | ||
} | ||
|
||
public ObjectConstructor newConstructor(Class<?> cls) { | ||
return objectConstructorFactory.newConstructor(cls); | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
core/src/main/java/org/sql2o/reflection/FieldSetterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.sql2o.reflection; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: dimzon | ||
* Date: 4/6/14 | ||
* Time: 12:39 AM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
public interface FieldSetterFactory { | ||
Setter newSetter(Field field); | ||
} |
Oops, something went wrong.