-
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.
LocalTime to numeric type conversions completed, all tests added.
Everything test now permits check for identity and equivalence but not identical.
- Loading branch information
Showing
13 changed files
with
608 additions
and
164 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
36 changes: 36 additions & 0 deletions
36
src/main/java/com/cedarsoftware/util/convert/AtomicIntegerConversions.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,36 @@ | ||
package com.cedarsoftware.util.convert; | ||
|
||
import java.time.LocalTime; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
/** | ||
* @author John DeRegnaucourt ([email protected]) | ||
* <br> | ||
* Copyright (c) Cedar Software LLC | ||
* <br><br> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <br><br> | ||
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a> | ||
* <br><br> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
final class AtomicIntegerConversions { | ||
|
||
private AtomicIntegerConversions() {} | ||
|
||
static AtomicInteger toAtomicInteger(Object from, Converter converter) { | ||
AtomicInteger atomicInt = (AtomicInteger) from; | ||
return new AtomicInteger(atomicInt.intValue()); | ||
} | ||
|
||
static LocalTime toLocalTime(Object from, Converter converter) { | ||
AtomicInteger atomicInteger= (AtomicInteger) from; | ||
return LongConversions.toLocalTime((long)atomicInteger.get(), converter); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/cedarsoftware/util/convert/AtomicLongConversions.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,36 @@ | ||
package com.cedarsoftware.util.convert; | ||
|
||
import java.time.LocalTime; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
/** | ||
* @author John DeRegnaucourt ([email protected]) | ||
* <br> | ||
* Copyright (c) Cedar Software LLC | ||
* <br><br> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <br><br> | ||
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a> | ||
* <br><br> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
final class AtomicLongConversions { | ||
|
||
private AtomicLongConversions() {} | ||
|
||
static AtomicLong toAtomicLong(Object from, Converter converter) { | ||
AtomicLong atomicLong = (AtomicLong) from; | ||
return new AtomicLong(atomicLong.get()); | ||
} | ||
|
||
static LocalTime toLocalTime(Object from, Converter converter) { | ||
AtomicLong atomicLong = (AtomicLong) from; | ||
return LongConversions.toLocalTime(atomicLong.get(), converter); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/cedarsoftware/util/convert/IntegerConversions.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,30 @@ | ||
package com.cedarsoftware.util.convert; | ||
|
||
import java.time.LocalTime; | ||
|
||
/** | ||
* @author John DeRegnaucourt ([email protected]) | ||
* <br> | ||
* Copyright (c) Cedar Software LLC | ||
* <br><br> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <br><br> | ||
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a> | ||
* <br><br> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
final class IntegerConversions { | ||
|
||
private IntegerConversions() {} | ||
|
||
static LocalTime toLocalTime(Object from, Converter converter) { | ||
int ms = (Integer) from; | ||
return LongConversions.toLocalTime((long)ms, converter); | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/cedarsoftware/util/convert/LongConversions.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,34 @@ | ||
package com.cedarsoftware.util.convert; | ||
|
||
import java.time.LocalTime; | ||
|
||
/** | ||
* @author John DeRegnaucourt ([email protected]) | ||
* <br> | ||
* Copyright (c) Cedar Software LLC | ||
* <br><br> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <br><br> | ||
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a> | ||
* <br><br> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
final class LongConversions { | ||
|
||
private LongConversions() {} | ||
|
||
static LocalTime toLocalTime(Object from, Converter converter) { | ||
long millis = (Long) from; | ||
try { | ||
return LocalTime.ofNanoOfDay(millis * 1_000_000); | ||
} catch (Exception e) { | ||
throw new IllegalArgumentException("Input value [" + millis + "] for conversion to LocalTime must be >= 0 && <= 86399999", e); | ||
} | ||
} | ||
} |
Oops, something went wrong.