• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ObjectMapper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.nmorel.gwtjackson.client.ObjectMapper的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper类的具体用法?Java ObjectMapper怎么用?Java ObjectMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ObjectMapper类属于com.github.nmorel.gwtjackson.client包,在下文中一共展示了ObjectMapper类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ajax

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
public static <I, O> void ajax(String protocol, String url, I model, ObjectMapper<I> inMapper,
		ObjectMapper<O> outMapper, BiConsumer<Integer, O> handler) {
	XMLHttpRequest xhr = XMLHttpRequest.create();
	xhr.setOnReadyStateChange(a -> {
		if (handler == null || xhr.getReadyState() != 4) {
			return;
		}
		O result = null;
		if (xhr.getStatus() == 200) {
			result = out(xhr.getResponseText(), outMapper);
		}
		handler.accept(xhr.getStatus(), result);
	});
	xhr.open(protocol, url);
	xhr.send(in(model, inMapper));
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:17,代码来源:Pojofy.java


示例2: socketSend

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
public static <I> void socketSend(WebSocket socket, String url, I model, ObjectMapper<I> inMapper,
		JsonObject headers) {
	JsonObject object = Json.createObject();
	object.put("url", url);
	object.put("body", in(model, inMapper));
	object.put("headers", headers);
	socket.send(object.toJson());
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:9,代码来源:Pojofy.java


示例3: buildMappers

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
private Map<TypeMirror, MethodSpec> buildMappers( TypeSpec.Builder typeBuilder, RestService restService ) {
    Set<TypeMirror> readers = new LinkedHashSet<TypeMirror>( restService.getReturnTypes() );
    readers.removeAll( restService.getBodyTypes() );

    Set<TypeMirror> writers = new LinkedHashSet<TypeMirror>( restService.getBodyTypes() );
    writers.removeAll( restService.getReturnTypes() );

    Set<TypeMirror> mappers = new LinkedHashSet<TypeMirror>( restService.getBodyTypes() );
    mappers.retainAll( restService.getReturnTypes() );

    Map<TypeMirror, MethodSpec> result = new LinkedHashMap<TypeMirror, MethodSpec>();
    result.putAll( buildMappers( restService.getPackageName(), restService
            .getBuilderSimpleClassName(), typeBuilder, readers, ObjectReader.class ) );
    result.putAll( buildMappers( restService.getPackageName(), restService
            .getBuilderSimpleClassName(), typeBuilder, writers, ObjectWriter.class ) );
    result.putAll( buildMappers( restService.getPackageName(), restService
            .getBuilderSimpleClassName(), typeBuilder, mappers, ObjectMapper.class ) );
    return result;
}
 
开发者ID:nmorel,项目名称:gwt-jackson-rest,代码行数:20,代码来源:GenRestBuilderProcessor.java


示例4: socketReceive

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
public static <O> boolean socketReceive(String url, Event e, ObjectMapper<O> outMapper, Consumer<O> handler) {
	Object me = ((MessageEvent) e).getData();
	String meString = me.toString();
	if (meString.equals("[object ArrayBuffer]")) { // websockets
		meString = socketToString((ArrayBuffer) me);
	}
	if (!meString.startsWith("{\"url\":\"" + url + "\"")) {
		return false;
	}
	JsonObject json = Json.parse(meString);
	handler.accept(out(json.getString("body"), outMapper));
	return true;
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:14,代码来源:Pojofy.java


示例5: in

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
protected static <I> String in(I model, ObjectMapper<I> inMapper) {
	if (model == null) {
		return null;
	} else if (model instanceof String || inMapper == null) {
		return (String) model;
	} else {
		return inMapper.write(model);
	}
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:10,代码来源:Pojofy.java


示例6: out

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected static <O> O out(String message, ObjectMapper<O> outMapper) {
	if (message == null) {
		return null;
	} else if (outMapper == null) { // outMapper null: string
		return (O) message;
	} else {
		return outMapper.read(message);
	}
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:11,代码来源:Pojofy.java


示例7: eventbusReceive

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
public static <O> void eventbusReceive(EventBus eventBus, String address, JsonObject headers,
		ObjectMapper<O> outMapper, Consumer<O> handler) {
	eventBus.registerHandler(address, headers, (error, m) -> {
		if (error != null) {
			throw new IllegalArgumentException(error.asString());
		}
		O output = out(m.getString("body"), outMapper);
		handler.accept(output);
	});
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:11,代码来源:Pojofy.java


示例8: addMappers

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
public static void addMappers(Map<Class<?>, ObjectMapper<?>> mappers) {
    INSTANCE.mappers.putAll(mappers);
}
 
开发者ID:spirylics,项目名称:x-gwt,代码行数:4,代码来源:XMapper.java


示例9: getMapper

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
<T> ObjectMapper<T> getMapper(T t) {
    return (ObjectMapper<T>) getMapper(t.getClass());
}
 
开发者ID:spirylics,项目名称:x-gwt,代码行数:4,代码来源:XMapper.java


示例10: eventbusPublish

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
public static <I> void eventbusPublish(EventBus eventBus, String address, I model, JsonObject headers,
		ObjectMapper<I> inMapper) {
	eventBus.publish(address, in(model, inMapper), headers);
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:5,代码来源:Pojofy.java


示例11: getSourceWriter

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx, JClassType intfType) {
    JPackage serviceIntfPkg = intfType.getPackage();
    String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
    PrintWriter printWriter = ctx.tryCreate(logger, packageName, getTypeSimpleName());
    if (printWriter == null) {
        return null;
    }

    ClassSourceFileComposerFactory composerFactory =
            new ClassSourceFileComposerFactory(packageName, getTypeSimpleName());

    String[] imports = new String[] {
            // java
            ArrayList.class.getCanonicalName(),
            Collection.class.getCanonicalName(),
            HashSet.class.getCanonicalName(),
            Iterator.class.getCanonicalName(),
            LinkedHashSet.class.getCanonicalName(),
            LinkedList.class.getCanonicalName(),
            List.class.getCanonicalName(),
            Set.class.getCanonicalName(),
            TreeSet.class.getCanonicalName(),
            // com.github.nmorel.gwtjackson
            ObjectMapper.class.getCanonicalName(),
            ObjectReader.class.getCanonicalName(),
            ObjectWriter.class.getCanonicalName(),
            // com.google.gwt
            GWT.class.getCanonicalName(),
            // org.turbogwt
            Overlays.class.getCanonicalName(),
            DeserializationContext.class.getCanonicalName(),
            Deserializer.class.getCanonicalName(),
            JsonRecordReader.class.getCanonicalName(),
            JsonObjectSerdes.class.getCanonicalName(),
            JsonRecordWriter.class.getCanonicalName(),
            Serdes.class.getCanonicalName(),
            SerializationContext.class.getCanonicalName(),
            Serializer.class.getCanonicalName()
    };

    for (String imp : imports) {
        composerFactory.addImport(imp);
    }

    composerFactory.addImplementedInterface(intfType.getErasedType().getQualifiedSourceName());

    return composerFactory.createSourceWriter(ctx, printWriter);
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:49,代码来源:JsonSerdesGenerator.java


示例12: getSourceWriter

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx, JClassType intfType) {
    JPackage serviceIntfPkg = intfType.getPackage();
    String packageName = serviceIntfPkg == null ? "" : serviceIntfPkg.getName();
    PrintWriter printWriter = ctx.tryCreate(logger, packageName, getTypeSimpleName());
    if (printWriter == null) {
        return null;
    }

    ClassSourceFileComposerFactory composerFactory =
            new ClassSourceFileComposerFactory(packageName, getTypeSimpleName());

    String[] imports = new String[]{
            // java
            ArrayList.class.getCanonicalName(),
            Collection.class.getCanonicalName(),
            HashSet.class.getCanonicalName(),
            Iterator.class.getCanonicalName(),
            LinkedHashSet.class.getCanonicalName(),
            LinkedList.class.getCanonicalName(),
            List.class.getCanonicalName(),
            Set.class.getCanonicalName(),
            TreeSet.class.getCanonicalName(),
            // com.github.nmorel.gwtjackson
            ObjectMapper.class.getCanonicalName(),
            ObjectReader.class.getCanonicalName(),
            ObjectWriter.class.getCanonicalName(),
            // com.google.gwt
            GWT.class.getCanonicalName(),
            // io.reinert.requestor
            DeserializationContext.class.getCanonicalName(),
            Deserializer.class.getCanonicalName(),
            JsonObjectSerdes.class.getCanonicalName(),
            JsonRecordReader.class.getCanonicalName(),
            JsonRecordWriter.class.getCanonicalName(),
            UnableToDeserializeException.class.getName(),
            UnableToSerializeException.class.getName(),
            Serdes.class.getCanonicalName(),
            Serializer.class.getCanonicalName(),
            SerializationContext.class.getCanonicalName()
    };

    for (String imp : imports) {
        composerFactory.addImport(imp);
    }

    composerFactory.addImplementedInterface(intfType.getErasedType().getQualifiedSourceName());

    return composerFactory.createSourceWriter(ctx, printWriter);
}
 
开发者ID:reinert,项目名称:requestor,代码行数:50,代码来源:JsonGwtJacksonGenerator.java


示例13: getMapper

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
@Override
public ObjectMapper<DataContainer> getMapper() {
    return singleton;
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:5,代码来源:Mechanism.java


示例14: newMapper

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
@Override
protected ObjectMapper<DataContainer> newMapper() {
    decorator.mapper = GWT.create( DataContainerMapper.class );
    return decorator;
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:6,代码来源:RestyGwt.java


示例15: newMapper

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
@Override
protected ObjectMapper<DataContainer> newMapper() {
    return GWT.create( DataContainerMapper.class );
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:5,代码来源:GwtJackson.java


示例16: createRootMapper

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
protected <T> ObjectMapperTester<T> createRootMapper( final ObjectMapper<T> mapper ) {
    return createMapper( mapper, JsonDeserializationContext.builder().unwrapRootValue( true ).build(), JsonSerializationContext
            .builder().wrapRootValue( true ).build() );
}
 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:5,代码来源:JsonRootNameGwtTest.java


示例17: eventbusSend

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
/**
 * Warning: the thing you send can go to anyone connected to the eventbus,
 * including other browsers that are connected. So please handle with care!
 * 
 * @param <I>
 *            input type
 * @param <O>
 *            output type
 * @param eventBus
 *            the eventbus
 * @param address
 *            the address
 * @param model
 *            the model
 * @param headers
 *            the headers
 * @param inMapper
 *            the inputmapper
 * @param outMapper
 *            the outputmapper
 * @param handler
 *            the callback handler
 */
public static <I, O> void eventbusSend(EventBus eventBus, String address, I model, JsonObject headers,
		ObjectMapper<I> inMapper, ObjectMapper<O> outMapper, Consumer<O> handler) {
	eventBus.send(address, in(model, inMapper), headers, (error, m) -> {
		if (error != null) {
			throw new IllegalArgumentException(error.asString());
		}
		handler.accept(out(m.getString("body"), outMapper));
	});
}
 
开发者ID:nielsbaloe,项目名称:vertxui,代码行数:33,代码来源:Pojofy.java


示例18: newMapper

import com.github.nmorel.gwtjackson.client.ObjectMapper; //导入依赖的package包/类
protected abstract ObjectMapper<DataContainer> newMapper(); 
开发者ID:nmorel,项目名称:gwt-jackson,代码行数:2,代码来源:Mechanism.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Parameter类代码示例发布时间:2022-05-23
下一篇:
Java ProblemHighlightFilter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap