diff --git a/rxlib/src/main/java/org/rx/bean/DataRange.java b/rxlib/src/main/java/org/rx/bean/DataRange.java index f92aa7b2..27393df6 100644 --- a/rxlib/src/main/java/org/rx/bean/DataRange.java +++ b/rxlib/src/main/java/org/rx/bean/DataRange.java @@ -3,6 +3,8 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.NonNull; +import org.rx.core.Reflects; +import org.rx.core.Strings; import java.io.Serializable; @@ -12,6 +14,12 @@ @NoArgsConstructor public class DataRange> implements Serializable { private static final long serialVersionUID = 2698228026798507997L; + + public static > DataRange of(String expr, Class type) { + String[] vals = Strings.split(expr, "-", 2); + return new DataRange<>(Reflects.changeType(vals[0], type), Reflects.changeType(vals[1], type)); + } + public T start; public T end;