Merge pull request #201 from ebraminio/kotlin-java

kotlin: Improve access of companions object fields/methods in Java
This commit is contained in:
Don Cross
2022-04-13 08:15:46 -04:00
committed by GitHub
6 changed files with 20 additions and 4 deletions

View File

@@ -473,6 +473,7 @@ class Time private constructor(
internal fun julianMillennia() = tt / DAYS_PER_MILLENNIUM
companion object {
@JvmStatic
private val origin = GregorianCalendar(TimeZoneUtc).also {
it.set(2000, 0, 1, 12, 0, 0)
it.set(Calendar.MILLISECOND, 0)
@@ -480,6 +481,7 @@ class Time private constructor(
private const val MILLIS_PER_DAY = 24 * 3600 * 1000
@JvmStatic
private val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").also {
it.timeZone = TimeZoneUtc
}
@@ -498,6 +500,7 @@ class Time private constructor(
*
* @param tt The number of days after the J2000 epoch.
*/
@JvmStatic
fun fromTerrestrialTime(tt: Double): Time = Time(universalTime(tt), tt)
}
}
@@ -547,6 +550,7 @@ internal data class TerseVector(var x: Double, var y: Double, var z: Double) {
}
companion object {
@JvmStatic
fun zero() = TerseVector(0.0, 0.0, 0.0)
}
}
@@ -1004,7 +1008,8 @@ class RotationMatrix(
* This matrix can be the starting point for other operations,
* such as calling a series of [RotationMatrix.combine] or [RotationMatrix.pivot].
*/
fun identity() = RotationMatrix (
@JvmStatic
fun identity() = RotationMatrix(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0

View File

@@ -3,6 +3,9 @@
# identity
[jvm]\
@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
fun [identity](identity.md)(): [RotationMatrix](../index.md)
Creates an identity rotation matrix.

View File

@@ -9,4 +9,4 @@ object [Companion](index.md)
| Name | Summary |
|---|---|
| [identity](identity.md) | [jvm]<br>fun [identity](identity.md)(): [RotationMatrix](../index.md)<br>Creates an identity rotation matrix. |
| [identity](identity.md) | [jvm]<br>@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)<br>fun [identity](identity.md)(): [RotationMatrix](../index.md)<br>Creates an identity rotation matrix. |

View File

@@ -3,6 +3,9 @@
# fromTerrestrialTime
[jvm]\
@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)
fun [fromTerrestrialTime](from-terrestrial-time.md)(tt: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)): [Time](../index.md)
Creates a Time object from a Terrestrial Time day value.

View File

@@ -9,4 +9,4 @@ object [Companion](index.md)
| Name | Summary |
|---|---|
| [fromTerrestrialTime](from-terrestrial-time.md) | [jvm]<br>fun [fromTerrestrialTime](from-terrestrial-time.md)(tt: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)): [Time](../index.md)<br>Creates a Time object from a Terrestrial Time day value. |
| [fromTerrestrialTime](from-terrestrial-time.md) | [jvm]<br>@[JvmStatic](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index.html)<br>fun [fromTerrestrialTime](from-terrestrial-time.md)(tt: [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)): [Time](../index.md)<br>Creates a Time object from a Terrestrial Time day value. |

View File

@@ -473,6 +473,7 @@ class Time private constructor(
internal fun julianMillennia() = tt / DAYS_PER_MILLENNIUM
companion object {
@JvmStatic
private val origin = GregorianCalendar(TimeZoneUtc).also {
it.set(2000, 0, 1, 12, 0, 0)
it.set(Calendar.MILLISECOND, 0)
@@ -480,6 +481,7 @@ class Time private constructor(
private const val MILLIS_PER_DAY = 24 * 3600 * 1000
@JvmStatic
private val dateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").also {
it.timeZone = TimeZoneUtc
}
@@ -498,6 +500,7 @@ class Time private constructor(
*
* @param tt The number of days after the J2000 epoch.
*/
@JvmStatic
fun fromTerrestrialTime(tt: Double): Time = Time(universalTime(tt), tt)
}
}
@@ -547,6 +550,7 @@ internal data class TerseVector(var x: Double, var y: Double, var z: Double) {
}
companion object {
@JvmStatic
fun zero() = TerseVector(0.0, 0.0, 0.0)
}
}
@@ -1004,7 +1008,8 @@ class RotationMatrix(
* This matrix can be the starting point for other operations,
* such as calling a series of [RotationMatrix.combine] or [RotationMatrix.pivot].
*/
fun identity() = RotationMatrix (
@JvmStatic
fun identity() = RotationMatrix(
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0