1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-25 12:27:58 +01:00

Port ReferenceTime interface to Kotlin

This commit is contained in:
Paul Schaub 2023-06-28 20:06:36 +02:00
parent 5341279d1f
commit 0c4b127c40
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 31 additions and 50 deletions

View file

@ -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;

View file

@ -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;
}
};
}
}

View file

@ -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;

View file

@ -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
}
}
}
}