当前位置: 首页>>代码示例>>Java>>正文


Java LoganSquare.mapperFor方法代码示例

本文整理汇总了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;
}
 
开发者ID:mariotaku,项目名称:OkFaye,代码行数:19,代码来源:FayeImpl.java

示例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();
            }
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:ObjectMapper.java

示例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());
        }
    }
}
 
开发者ID:Commit451,项目名称:Regalia,代码行数:10,代码来源:RealmListLoganSquareConverter.java

示例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);
}
 
开发者ID:mariotaku,项目名称:OkFaye,代码行数:12,代码来源:Request.java

示例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);
}
 
开发者ID:mariotaku,项目名称:OkFaye,代码行数:11,代码来源:PublishRequest.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:SimpleGenericModel$$JsonObjectMapper.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:SimpleGenericModelWithExtends$$JsonObjectMapper.java

示例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);
}
 
开发者ID:xuehuayous,项目名称:Hannibai,代码行数:5,代码来源:BaseModel$$JsonObjectMapper.java

示例9: mapperFor

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
protected <T> JsonMapper<T> mapperFor(@NotNull ParameterizedType<T> type) {
    return LoganSquare.mapperFor(type);
}
 
开发者ID:mariotaku,项目名称:RestFu,代码行数:4,代码来源:LoganSquareConverterFactory.java


注:本文中的com.bluelinelabs.logansquare.LoganSquare.mapperFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。