添加 OptionalInt、OptionalLong、OptionalDouble 转包装类实例的方法。
parent
3a46e2e60c
commit
759ad5fcbe
|
@ -134,6 +134,21 @@ public class OptionalUtil {
|
||||||
return optionalObj.orElse(null);
|
return optionalObj.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Beta
|
||||||
|
public static Integer toInteger(OptionalInt optionalObj) {
|
||||||
|
return optionalObj.isPresent() ? optionalObj.getAsInt() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Beta
|
||||||
|
public static Long toLong(OptionalLong optionalObj) {
|
||||||
|
return optionalObj.isPresent() ? optionalObj.getAsLong() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Beta
|
||||||
|
public static Double toDouble(OptionalDouble optionalObj) {
|
||||||
|
return optionalObj.isPresent() ? optionalObj.getAsDouble() : null;
|
||||||
|
}
|
||||||
|
|
||||||
private OptionalUtil() {
|
private OptionalUtil() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue