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;

}

java deepcopy_Java JsonNode.deepCopy方法代码示例相关推荐

  1. java kryo_Kryo框架使用方法代码示例

    Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...

  2. java readtimeout_Java HttpURLConnection.getReadTimeout方法代码示例

    import java.net.HttpURLConnection; //导入方法依赖的package包/类 /** * 得到响应对象 * * @param urlConnection * @retu ...

  3. java invalidate_Java Component.invalidate方法代码示例

    import java.awt.Component; //导入方法依赖的package包/类 /** Installs the component we will embed to display t ...

  4. java hasmoreelements_Java IOException.hasMoreElements方法代码示例

    import java.io.IOException; //导入方法依赖的package包/类 /** * fileName���� ���� package �������� ������ ���� ...

  5. java methode_Java Method.getTypeParameters方法代码示例

    import java.lang.reflect.Method; //导入方法依赖的package包/类 private void validateRuleMethod(MethodRuleDefin ...

  6. java setmethod_Java Operation.setJavaMethod方法代码示例

    import com.sun.tools.internal.ws.processor.model.Operation; //导入方法依赖的package包/类 private void createJ ...

  7. java cancel_Java RunnableFuture.cancel方法代码示例

    import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类 @Test public void testSnapshotAsyncC ...

  8. java getevent_Java ActionEvent.getWhen方法代码示例

    import java.awt.event.ActionEvent; //导入方法依赖的package包/类 @Override final public void actionPerformed(A ...

  9. java setlayout_Java JLabel.setLayout方法代码示例

    import javax.swing.JLabel; //导入方法依赖的package包/类 private void initTitlePanel(){ preYear = new JLabel(& ...

最新文章

  1. Android Bitmap开发之旅--基本操作
  2. vue生命周期(列表详解)
  3. 2018年11月12日
  4. java去掉图片边框颜色_sharp 去除图片边框
  5. 233网校计算机二级c语言,[233网校]2018年全国计算机二级Office高级应用精讲班_计算机二级视频教程...
  6. Windows网络服务---DHCP服务
  7. hdu--1077--Catching Fish
  8. Idea安装Eslint插件详解 提示:Plugin NativeScript was not installed解决
  9. qq for android 4.6能视频吗,安卓qq4.6使用评测
  10. Jquery(十)jqueryUI常用功能实战
  11. 学术会议论文查重吗_会议论文查重吗
  12. 金融衍生品软件产品设计必备知识——上海黄金交易所产品概览
  13. 聚名企服商标注册流程及资料(2022新版新手教程)
  14. 【Docker】Linux各系统安装Docker,Docker-compose方式汇总
  15. 移动端设置overflow-x:hiden后scrollTop失效并一直为0
  16. c语言编程实现简单三子棋游戏
  17. 杨永智:创业者需具备的六大基因 五大攻略(下)
  18. 点到超平面的距离公式推导
  19. LeetCode4寻找两个有序数组的中位数(二分查找+分治)
  20. 【JavaScript】获取网页元素

热门文章

  1. 使用Fiddler后谷歌浏览器访问https不安全
  2. C++ 有参构造函数和无参构造函数的实现
  3. 影响神经网络训练速度的因素使得神经网络训练速度加快的方法
  4. linux下查看用户的权限,linux 疑问 如何查看用户所在组,及权限
  5. 【Win10】屏幕常亮解决方案
  6. mysql主键时间戳_mysql 时间戳的用法
  7. django读取mysql里原有数据_django整合原有的mysql数据库
  8. Flutter学习(五)
  9. VPS使用ProxySU搭建节点服务器
  10. 使用jQuery制作轮播图