零拷贝java_java arraycopy方法

零拷贝java_java arraycopy方法importcom.fasterxml.jackson.databind.JsonNode;//导入方法依赖的package包/类/***Appliesthisschemaruletotaketherequiredcodegenerationsteps.**AJava{@linkEnum}iscreated,withconstantsforeach…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类

/**

* Applies this schema rule to take the required code generation steps.

*

* A Java {@link Enum} is created, with constants for each of the enum

* values present in the schema. The enum name is derived from the nodeName,

* and the enum type itself is created as an inner class of the owning type.

* In the rare case that no owning type exists (the enum is the root of the

* schema), then the enum becomes a public class in its own right.

*

* The actual JSON value for each enum constant is held in a property called

* “value” in the generated type. A static factory method

* fromValue(String) is added to the generated enum, and the

* methods are annotated to allow Jackson to marshal/unmarshal values

* correctly.

*

* @param nodeName

* the name of the property which is an “enum”

* @param node

* the enum node

* @param container

* the class container (class or package) to which this enum

* should be added

* @return the newly generated Java type that was created to represent the

* given enum

*/

@Override

public JType apply(String nodeName, JsonNode node, JClassContainer container, Schema schema) {

JDefinedClass _enum;

try {

_enum = createEnum(node, nodeName, container);

} catch (ClassAlreadyExistsException e) {

return e.getExistingClass();

}

schema.setJavaTypeIfEmpty(_enum);

if (node.has(“javaInterfaces”)) {

addInterfaces(_enum, node.get(“javaInterfaces”));

}

// copy our node; remove the javaType as it will throw off the TypeRule for our case

ObjectNode typeNode = (ObjectNode)node.deepCopy();

typeNode.remove(“javaType”);

// If type is specified on the enum, get a type rule for it. Otherwise, we’re a string.

// (This is different from the default of Object, which is why we don’t do this for every case.)

JType backingType = node.has(“type”) ?

ruleFactory.getTypeRule().apply(nodeName, typeNode, container, schema) :

container.owner().ref(String.class);

JFieldVar valueField = addValueField(_enum, backingType);

// override toString only if we have a sensible string to return

if(isString(backingType)){

addToString(_enum, valueField);

}

addValueMethod(_enum, valueField);

addEnumConstants(node.path(“enum”), _enum, node.path(“javaEnumNames”), backingType);

addFactoryMethod(_enum, backingType);

return _enum;

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/186803.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 微信第三方登录接口购买_微信授权登录第三方网页

    微信第三方登录接口购买_微信授权登录第三方网页随着手机微信的崛起,腾讯发布的微信联登确实很诱惑pc端的伙伴们,现在就说说在pc端用微信扫一扫实现微信第三方登陆的方式。  第一步:获取AppID AppSecret(不做解释,自己去微信公众平台申请)第二步:生成扫描二维码,获取codehttps://open.weixin.qq.com/connect/qrconnect?appid=AppID&redirect_uri=http://…

    2022年10月31日
    0
  • hashmap线程不安全问题_为什么HashMap线程不安全

    hashmap线程不安全问题_为什么HashMap线程不安全HashMap的线程不安全主要体现在下面两个方面:1.在JDK1.7中,当并发执行扩容操作时会造成环形链和数据丢失的情况。2.在JDK1.8中,在并发执行put操作时会发生数据覆盖的情况。JDK1.7在JDK1.7中,扩容数据时要进行把原数据迁移到新的位置,使用的方法://数据迁移的方法,头插法添加元素voidtransfer(Entry[]newTable,booleanrehash){intnewCapacity=newTable.length;     

    2022年10月11日
    0
  • 女生适合学习Java吗?

    女生适合学习Java吗?在这个信息爆炸的时代,互联网行业成为了高薪的代名词,Java技术因其具有卓越的通用性、高效性、平台移植性和安全性,广泛应用于PC、数据中心、游戏控制台、科学超级计算机、移动电话和互联网,作为最流行的语言,学习的人也是越来越多。在很多人看来,学习java似乎是男生的专利,难道真的只有男生才能学好Java成为优秀的java工程师吗?“女生适合学Java吗?”“女程序员就业前景好不好?”“女生学Jav

    2022年7月8日
    91
  • Spring AOP理解与研发使用

    Spring AOP理解与研发使用SpringAOP理解与研发使用:基本理论(基本术语总结+具体开发注意事项+切点正则和指示器规则)+AOP开发应用与分析

    2022年7月12日
    16
  • 用SrvAny.exe封装服务「建议收藏」

    用SrvAny.exe封装服务「建议收藏」用SrvAny.exe封装服务

    2022年5月29日
    49
  • 104规约 scada

    104规约 scada104规约的报文帧分为三类:I帧、S帧和U帧。I帧称为信息帧,长度一定大于6个字节,被称作长帧,用于传输数据;S帧称为确认帧,长度只有6个字节,被称作短帧,用于确认接收的I帧;U帧称为控制帧,长度只有6个字节,也被称作短帧,用于控制启动/停止/测试。长帧报文分为APCI和ASDU两个部分,而短帧报文只有APCI部分。APCI的6个字节是这样构成的:起动字符68H,1个字节;后面的报文长

    2022年6月20日
    69

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号