這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)?lái)有關(guān)Spring中如何定義Range范圍對(duì)象,文章內(nèi)容豐富且以專(zhuān)業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

1 實(shí)現(xiàn)方式
1.1 范圍對(duì)象Range定義
import java.io.Serializable;
public class Range<E> implements Serializable {
private static final long serialVersionUID = 1L;
private String field;
private Comparable from;
private Comparable to;
private Boolean includeNull;
public Range(String field) {
this.field = field;
}
public Range(String field, Comparable from, Comparable to) {
this.field = field;
this.from = from;
this.to = to;
}
public Range(String field, Comparable from, Comparable to, Boolean includeNull) {
this.field = field;
this.from = from;
this.to = to;
this.includeNull = includeNull;
}
public Range(Range<E> other) {
this.field = other.getField();
this.from = other.getFrom();
this.to = other.getTo();
this.includeNull = other.getIncludeNull();
}
public String getField() {
return field;
}
public Comparable getFrom() {
return from;
}
public void setFrom(Comparable from) {
this.from = from;
}
public boolean isFromSet() {
return getFrom() != null;
}
public Comparable getTo() {
return to;
}
public void setTo(Comparable to) {
this.to = to;
}
public boolean isToSet() {
return getTo() != null;
}
public void setIncludeNull(boolean includeNull) {
this.includeNull = includeNull;
}
public Boolean getIncludeNull() {
return includeNull;
}
public boolean isIncludeNullSet() {
return includeNull != null;
}
public boolean isBetween() {
return isFromSet() && isToSet();
}
public boolean isSet() {
return isFromSet() || isToSet() || isIncludeNullSet();
}
public boolean isValid() {
if (isBetween()) {
return getFrom().compareTo(getTo()) <= 0;
}
return true;
}
}
網(wǎng)頁(yè)名稱(chēng):Spring中如何定義Range范圍對(duì)象-創(chuàng)新互聯(lián)
文章源于:http://www.chinadenli.net/article12/dhddgc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站內(nèi)鏈、網(wǎng)站收錄、網(wǎng)站排名、虛擬主機(jī)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容