-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed UUID to BigInteger (and back). Had to treat the UUID strings as…
… proper hex. BigInteger conversions almost complete.
- Loading branch information
Showing
4 changed files
with
1,867 additions
and
1,763 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.util.UUID; | ||
|
||
/** | ||
* @author John DeRegnaucourt ([email protected]) | ||
|
@@ -27,19 +26,12 @@ private UUIDConversions() { | |
} | ||
|
||
static BigDecimal toBigDecimal(Object from, Converter converter) { | ||
UUID uuid = (UUID) from; | ||
BigInteger mostSignificant = BigInteger.valueOf(uuid.getMostSignificantBits()); | ||
BigInteger leastSignificant = BigInteger.valueOf(uuid.getLeastSignificantBits()); | ||
// Shift the most significant bits to the left and add the least significant bits | ||
return new BigDecimal(mostSignificant.shiftLeft(64).add(leastSignificant)); | ||
return new BigDecimal(toBigInteger(from, converter)); | ||
} | ||
|
||
static BigInteger toBigInteger(Object from, Converter converter) { | ||
UUID uuid = (UUID) from; | ||
BigInteger mostSignificant = BigInteger.valueOf(uuid.getMostSignificantBits()); | ||
BigInteger leastSignificant = BigInteger.valueOf(uuid.getLeastSignificantBits()); | ||
// Shift the most significant bits to the left and add the least significant bits | ||
return mostSignificant.shiftLeft(64).add(leastSignificant); | ||
String hex = from.toString().replace("-", ""); | ||
return new BigInteger(hex, 16); | ||
} | ||
} | ||
|
Oops, something went wrong.