零拷贝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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • oracle正则表达式匹配中文

    oracle正则表达式匹配中文oracle正则表达式regexp_substr、regexp_like、regexp_replace是无法像其他正则表达式一样用[\u4e00-\u9fa5]来匹配中文的。所以,我们需要用另一种方式来实现oracle正则表达式匹配中文。我们需要用到oracle的内置函数UNISTR(str):ASCIISTR语法:asciistr(str)功能:返回字符串的规则表现形式,英文和数字变

    2022年6月28日
    30
  • android Kotlin int类型和Long类型转换

    android Kotlin int类型和Long类型转换在Kotlin开发中,即使Long类型较大,int类型的数值也不会自动转换为long类型。这与Java处理数字转换的方式不同。例如;在Java中intnumber1=102;longnumber2=number1;//有效代码这里,number1类型的int值自动转换为类型long,并分配给变量number2。在Kotlin,valnumber1:Int=10…

    2022年5月28日
    124
  • windows中bat批处理的注释语句

    windows中bat批处理的注释语句转自:wh_19910525https://blog.csdn.net/wh_19910525/article/details/8125762写bat批处理也一样,都要用到注释的功能,这是为了程式的可读性在批处理中,段注释有一种比较常用的方法:gotostart=可以是多行文本,可以是命令=可以包含重定向符号和其他特殊字符=只要不包含:start这一行,就都是…

    2025年6月3日
    0
  • 50.3. Partitioning

    50.3. Partitioning

    2022年3月12日
    29
  • 通俗理解LDA主题模型

    通俗理解LDA主题模型0前言印象中,最开始听说“LDA”这个名词,是缘于rickjin在2013年3月写的一个LDA科普系列,叫LDA数学八卦,我当时一直想看来着,记得还打印过一次,但不知是因为这篇文档的前序铺垫太长(现在才意识到这些“铺垫”都是深刻理解LDA的基础,但如果没有人帮助初学者提纲挈领、把握主次、理清思路,则很容易陷入…

    2022年4月6日
    54
  • phpstrom2021 激活码【2021最新】

    (phpstrom2021 激活码)JetBrains旗下有多款编译器工具(如:IntelliJ、WebStorm、PyCharm等)在各编程领域几乎都占据了垄断地位。建立在开源IntelliJ平台之上,过去15年以来,JetBrains一直在不断发展和完善这个平台。这个平台可以针对您的开发工作流进行微调并且能够提供…

    2022年3月22日
    46

发表回复

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

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