java泛型不是计算运行时的数据类型
生活随笔
收集整理的這篇文章主要介紹了
java泛型不是计算运行时的数据类型
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
package com.ada.data.entity;import java.io.Serializable;import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.MappedSuperclass;@MappedSuperclass public class NumEntity<NUM extends Number> implements Serializable {@Id@GeneratedValue(strategy = GenerationType.AUTO)private NUM id;public NUM getId() {return id;}public void setId(NUM id) {this.id = id;}@Overridepublic int hashCode() {final int prime = 31;int result = 1;result = prime * result + ((id == null) ? 0 : id.hashCode());return result;}@Overridepublic boolean equals(Object obj) {if (this == obj)return true;if (obj == null)return false;if (getClass() != obj.getClass())return false;NumEntity other = (NumEntity) obj;if (id == null) {if (other.id != null)return false;} else if (!id.equals(other.id))return false;return true;}}
java泛型不是計算運行時的數據類型。
所以在使用BeanUtils.copyProperties(source, result);的時候id不能拷貝。
轉載于:https://my.oschina.net/cng1985/blog/653334
總結
以上是生活随笔為你收集整理的java泛型不是计算运行时的数据类型的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【自定义标签开发】01-标签简介和开发第
- 下一篇: WWDC 2013 Session笔记