Skip to content

Commit

Permalink
Update DataRange.java
Browse files Browse the repository at this point in the history
  • Loading branch information
youfanx committed Apr 8, 2024
1 parent befb580 commit a5faaf4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rxlib/src/main/java/org/rx/bean/DataRange.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -12,6 +14,12 @@
@NoArgsConstructor
public class DataRange<T extends Comparable<T>> implements Serializable {
private static final long serialVersionUID = 2698228026798507997L;

public static <T extends Comparable<T>> DataRange<T> of(String expr, Class<T> 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;

Expand Down

0 comments on commit a5faaf4

Please sign in to comment.