本文整理汇总了Java中se.emilsjolander.sprinkles.typeserializers.TypeSerializer类的典型用法代码示例。如果您正苦于以下问题:Java TypeSerializer类的具体用法?Java TypeSerializer怎么用?Java TypeSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeSerializer类属于se.emilsjolander.sprinkles.typeserializers包,在下文中一共展示了TypeSerializer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertSqlArgs
import se.emilsjolander.sprinkles.typeserializers.TypeSerializer; //导入依赖的package包/类
static String insertSqlArgs(String sql, Object[] args) {
if (args == null) {
return sql;
}
for (Object o : args) {
TypeSerializer typeSerializer = Sprinkles.sInstance.getTypeSerializer(o.getClass());
String sqlObject = typeSerializer.toSql(o);
sql = sql.replaceFirst("\\?", sqlObject);
}
return sql;
}
示例2: registerType
import se.emilsjolander.sprinkles.typeserializers.TypeSerializer; //导入依赖的package包/类
@Test
public void registerType() {
Sprinkles s = Sprinkles.init(Robolectric.application);
TypeSerializer serializer = new MyObjectSerializer();
s.registerType(MyObject.class, serializer);
assertEquals(s.getTypeSerializer(MyObject.class), serializer);
}
示例3: insertSqlArgs
import se.emilsjolander.sprinkles.typeserializers.TypeSerializer; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
static String insertSqlArgs(String sql, Object[] args) {
if (args == null) {
return sql;
}
for (Object o : args) {
TypeSerializer typeSerializer = Sprinkles.sInstance.getTypeSerializer(o.getClass());
String sqlObject = typeSerializer.toSql(o);
sql = sql.replaceFirst("\\?", sqlObject);
}
return sql;
}
示例4: registerType
import se.emilsjolander.sprinkles.typeserializers.TypeSerializer; //导入依赖的package包/类
public <T> void registerType(Class<T> clazz, TypeSerializer<T> serializer) {
typeSerializers.put(clazz, serializer);
}
示例5: getTypeSerializer
import se.emilsjolander.sprinkles.typeserializers.TypeSerializer; //导入依赖的package包/类
TypeSerializer getTypeSerializer(Class<?> type) {
if (!typeSerializers.containsKey(type)) {
throw new NoTypeSerializerFoundException(type);
}
return typeSerializers.get(type);
}