mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-24 11:57:59 +01:00
Port ReferenceTime interface to Kotlin
This commit is contained in:
parent
5341279d1f
commit
0c4b127c40
4 changed files with 31 additions and 50 deletions
|
@ -1,8 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Dijkstra-based WoT implementation using a flow network.
|
||||
*/
|
||||
package org.pgpainless.wot.dijkstra;
|
|
@ -1,34 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Date;
|
||||
|
||||
public interface ReferenceTime {
|
||||
|
||||
@Nonnull Date getTimestamp();
|
||||
|
||||
static ReferenceTime now() {
|
||||
final Date now = new Date();
|
||||
return new ReferenceTime() {
|
||||
@Override
|
||||
@Nonnull
|
||||
public Date getTimestamp() {
|
||||
return now;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static ReferenceTime timestamp(@Nonnull Date timestamp) {
|
||||
return new ReferenceTime() {
|
||||
@Override
|
||||
@Nonnull
|
||||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Web of Trust implementation.
|
||||
*/
|
||||
package org.pgpainless.wot.dijkstra.sq;
|
|
@ -0,0 +1,31 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.wot.dijkstra.sq
|
||||
|
||||
import java.util.*
|
||||
|
||||
interface ReferenceTime {
|
||||
|
||||
val timestamp: Date
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun now(): ReferenceTime {
|
||||
val now = Date()
|
||||
return object: ReferenceTime {
|
||||
override val timestamp: Date
|
||||
get() = now
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun timestamp(stamp: Date): ReferenceTime {
|
||||
return object: ReferenceTime {
|
||||
override val timestamp: Date
|
||||
get() = stamp
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue