本文整理汇总了Java中com.bluelinelabs.logansquare.LoganSquare.mapperFor方法的典型用法代码示例。如果您正苦于以下问题:Java LoganSquare.mapperFor方法的具体用法?Java LoganSquare.mapperFor怎么用?Java LoganSquare.mapperFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bluelinelabs.logansquare.LoganSquare
的用法示例。
在下文中一共展示了LoganSquare.mapperFor方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMessage
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
<Req extends Request, Resp extends Response> boolean sendMessage(Req message, Class<Resp> respCls,
Callback<Resp> callback) {
if (isClosed()) return false;
try {
final List<Req> messageList = Collections.singletonList(message);
//noinspection unchecked
final JsonMapper<Req> mapper = (JsonMapper<Req>) LoganSquare.mapperFor(message.getClass());
final String messageJson = mapper.serialize(messageList);
final String id = message.getId();
resultHandlers.put(id, new SendResultHandler<>(id, respCls, callback));
webSocket.sendMessage(RequestBody.create(WebSocket.TEXT, messageJson));
} catch (IOException e) {
faye.unconnected(e, -1, null);
disconnect();
return false;
}
return true;
}
示例2: serialize
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override
public void serialize(Object value, JsonGenerator generator, boolean writeStartAndEnd) throws IOException {
if (value == null) {
generator.writeNull();
} else if (value instanceof String) {
generator.writeString((String)value);
} else if (value instanceof Integer) {
generator.writeNumber((Integer)value);
} else if (value instanceof Long) {
generator.writeNumber((Long)value);
} else if (value instanceof Float) {
generator.writeNumber((Float)value);
} else if (value instanceof Double) {
generator.writeNumber((Double)value);
} else if (value instanceof Boolean) {
generator.writeBoolean((Boolean)value);
} else if (value instanceof List) {
LoganSquare.mapperFor(List.class).serialize((List<Object>)value, generator, writeStartAndEnd);
} else if (value instanceof Map) {
LoganSquare.mapperFor(Map.class).serialize((Map<String, Object>)value, generator, writeStartAndEnd);
} else {
Class valueClass = value.getClass();
JsonMapper jsonMapper = LoganSquare.mapperFor(valueClass);
if (jsonMapper != null) {
if (writeStartAndEnd) {
generator.writeStartObject();
}
jsonMapper.serialize(value, generator, false);
if (writeStartAndEnd) {
generator.writeEndObject();
}
}
}
}
示例3: init
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
private void init() {
if (typeConverter == null && mapper == null) {
try {
typeConverter = LoganSquare.typeConverterFor(getObjectClass());
} catch (NoSuchTypeConverterException e) {
mapper = LoganSquare.mapperFor(getObjectClass());
}
}
}
示例4: serialize
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override
public void serialize(Extension object, String fieldName, boolean writeFieldNameForObject,
JsonGenerator jsonGenerator) throws IOException {
if (object == null) return;
if (writeFieldNameForObject) {
jsonGenerator.writeFieldName(fieldName);
}
final JsonMapper<? extends Extension> mapper = LoganSquare.mapperFor(object.getClass());
//noinspection unchecked
((JsonMapper<Extension>) mapper).serialize(object, jsonGenerator, true);
}
示例5: serialize
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override
public void serialize(Object object, String fieldName, boolean writeFieldNameForObject,
JsonGenerator jsonGenerator) throws IOException {
if (writeFieldNameForObject) {
jsonGenerator.writeFieldName(fieldName);
}
//noinspection unchecked
final JsonMapper<Object> mapper = (JsonMapper<Object>) LoganSquare.mapperFor(object.getClass());
mapper.serialize(object, jsonGenerator, true);
}
示例6:
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
public SimpleGenericModel$$JsonObjectMapper(ParameterizedType type, ParameterizedType TType, SimpleArrayMap<ParameterizedType, JsonMapper> partialMappers) {
partialMappers.put(type, this);
m84ClassJsonMapper = LoganSquare.mapperFor(TType, partialMappers);
}
示例7:
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
public SimpleGenericModelWithExtends$$JsonObjectMapper(ParameterizedType type, ParameterizedType TType, SimpleArrayMap<ParameterizedType, JsonMapper> partialMappers) {
partialMappers.put(type, this);
m84ClassJsonMapper = LoganSquare.mapperFor(TType, partialMappers);
}
示例8:
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
public BaseModel$$JsonObjectMapper(ParameterizedType type, ParameterizedType TType, SimpleArrayMap<ParameterizedType, JsonMapper> partialMappers) {
partialMappers.put(type, this);
mClassJsonMapper = LoganSquare.mapperFor(TType, partialMappers);
}
示例9: mapperFor
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
protected <T> JsonMapper<T> mapperFor(@NotNull ParameterizedType<T> type) {
return LoganSquare.mapperFor(type);
}