mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Refactor auto-delete code from Bramble to Briar.
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
package org.briarproject.bramble.api.autodelete;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.DAYS;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
public interface AutoDeleteConstants {
|
||||
|
||||
/**
|
||||
* The minimum valid auto-delete timer duration in milliseconds.
|
||||
*/
|
||||
long MIN_AUTO_DELETE_TIMER_MS = MINUTES.toMillis(1);
|
||||
|
||||
/**
|
||||
* The maximum valid auto-delete timer duration in milliseconds.
|
||||
*/
|
||||
long MAX_AUTO_DELETE_TIMER_MS = DAYS.toMillis(365);
|
||||
|
||||
/**
|
||||
* Placeholder value indicating that a message has no auto-delete timer.
|
||||
* This value should not be sent over the wire - send null instead.
|
||||
*/
|
||||
long NO_AUTO_DELETE_TIMER = -1;
|
||||
}
|
||||
@@ -6,11 +6,9 @@ import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
import static org.briarproject.bramble.api.autodelete.AutoDeleteConstants.MAX_AUTO_DELETE_TIMER_MS;
|
||||
import static org.briarproject.bramble.api.autodelete.AutoDeleteConstants.MIN_AUTO_DELETE_TIMER_MS;
|
||||
import static org.briarproject.bramble.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class ValidationUtils {
|
||||
|
||||
@@ -73,11 +71,4 @@ public class ValidationUtils {
|
||||
throws FormatException {
|
||||
if (l != null && (l < min || l > max)) throw new FormatException();
|
||||
}
|
||||
|
||||
public static long validateAutoDeleteTimer(@Nullable Long timer)
|
||||
throws FormatException {
|
||||
if (timer == null) return NO_AUTO_DELETE_TIMER;
|
||||
checkRange(timer, MIN_AUTO_DELETE_TIMER_MS, MAX_AUTO_DELETE_TIMER_MS);
|
||||
return timer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user