-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-5133 Introduce number utils helper
- Loading branch information
Showing
8 changed files
with
77 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
engine/src/main/java/org/hibernate/search/engine/cfg/spi/NumberUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.search.engine.cfg.spi; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
|
||
public final class NumberUtils { | ||
|
||
private NumberUtils() { | ||
} | ||
|
||
public static BigDecimal toBigDecimal(Double value) { | ||
if ( value == null ) { | ||
return null; | ||
} | ||
return BigDecimal.valueOf( value ); | ||
} | ||
|
||
public static BigInteger toBigInteger(Double value) { | ||
if ( value == null ) { | ||
return null; | ||
} | ||
return BigInteger.valueOf( value.longValue() ); | ||
} | ||
|
||
public static Byte toByte(Double value) { | ||
if ( value == null ) { | ||
return null; | ||
} | ||
return value.byteValue(); | ||
} | ||
|
||
public static Float toFloat(Double value) { | ||
if ( value == null ) { | ||
return null; | ||
} | ||
return value.floatValue(); | ||
} | ||
|
||
public static Integer toInteger(Double value) { | ||
if ( value == null ) { | ||
return null; | ||
} | ||
return value.intValue(); | ||
} | ||
|
||
public static Long toLong(Double value) { | ||
if ( value == null ) { | ||
return null; | ||
} | ||
return value.longValue(); | ||
} | ||
|
||
public static Short toShort(Double value) { | ||
if ( value == null ) { | ||
return null; | ||
} | ||
return value.shortValue(); | ||
} | ||
} |