Skip to content

Commit

Permalink
Handle null for Min Max and IsLeapYear (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCockx authored Nov 13, 2024
1 parent d5930e6 commit b26c67e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,35 @@
import java.time.chrono.IsoChronology;

public class IsLeapYear {
public boolean execute(Integer year) {
return execute(year.longValue());
public Boolean execute(Integer year) {
if (year == null) {
return null;
}
return isLeapYear(year.longValue());
}

public boolean execute(Long year) {
return IsoChronology.INSTANCE.isLeapYear(year);
public Boolean execute(Long year) {
if (year == null) {
return null;
}
return isLeapYear(year.longValue());
}

public boolean execute(BigInteger year) {
return execute(year.longValue());
public Boolean execute(BigInteger year) {
if (year == null) {
return null;
}
return isLeapYear(year.longValue());
}

public boolean execute(BigDecimal year) {
return execute(year.longValue());
public Boolean execute(BigDecimal year) {
if (year == null) {
return null;
}
return isLeapYear(year.longValue());
}

private boolean isLeapYear(long year) {
return IsoChronology.INSTANCE.isLeapYear(year);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,30 @@
public class Max {

public Integer execute(Integer x, Integer y) {
if (x == null || y == null) {
return null;
}
return Integer.max(x, y);
}

public Long execute(Long x, Long y) {
if (x == null || y == null) {
return null;
}
return Long.max(x, y);
}

public BigInteger execute(BigInteger x, BigInteger y) {
if (x == null || y == null) {
return null;
}
return x.max(y);
}

public BigDecimal execute(BigDecimal x, BigDecimal y) {
if (x == null || y == null) {
return null;
}
return x.max(y);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,30 @@
public class Min {

public Integer execute(Integer x, Integer y) {
if (x == null || y == null) {
return null;
}
return Integer.min(x, y);
}

public Long execute(Long x, Long y) {
if (x == null || y == null) {
return null;
}
return Long.min(x, y);
}

public BigInteger execute(BigInteger x, BigInteger y) {
if (x == null || y == null) {
return null;
}
return x.min(y);
}

public BigDecimal execute(BigDecimal x, BigDecimal y) {
if (x == null || y == null) {
return null;
}
return x.min(y);
}
}

0 comments on commit b26c67e

Please sign in to comment.