Use transactional database API in Bramble.

This commit is contained in:
akwizgran
2018-10-26 09:52:05 +01:00
parent 23e9b119d1
commit e846a13f50
26 changed files with 577 additions and 1309 deletions

View File

@@ -0,0 +1,33 @@
package org.briarproject.bramble.api;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.util.NoSuchElementException;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
/**
* Minimal stand-in for `java.util.Optional`. Functionality from `Optional`
* can be added as needed.
*/
@Immutable
@NotNullByDefault
public class Maybe<T> {
@Nullable
private final T value;
public Maybe(@Nullable T value) {
this.value = value;
}
public boolean isPresent() {
return value != null;
}
public T get() {
if (value == null) throw new NoSuchElementException();
return value;
}
}

View File

@@ -0,0 +1,26 @@
package org.briarproject.bramble.api;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import javax.annotation.concurrent.Immutable;
@Immutable
@NotNullByDefault
public class Pair<A, B> {
private final A first;
private final B second;
public Pair(A first, B second) {
this.first = first;
this.second = second;
}
public A getFirst() {
return first;
}
public B getSecond() {
return second;
}
}