Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {
}

ext {
rlibVersion = "10.0.alpha5"
rlibVersion = "10.0.alpha6"
}

dependencies {
Expand All @@ -39,6 +39,7 @@ dependencies {
### Fake SMTP Server

```java

var container = new FakeSMTPTestContainer()
.withSmtpPassword("pwd")
.withSmtpUser("test_user");
Expand Down Expand Up @@ -92,19 +93,15 @@ LoggerLevel.DEBUG.setEnabled(true);

logger.debug("Simple message");
logger.debug(5, (val) -> "Lazy message with 5: " + val);
logger.debug(5, "Lazy message with 5:%d"::formated);
logger.debug(5, 10D, (val1, val2) -> "Lazy message with 5: " + val1 + " and 10: " + val2);
logger.debug("", "Message with a string owner.");
logger.debug("", 5, (val) -> "Lazy message with 5: " + val);
logger.debug("", 5, 10D, (val1, val2) -> "Lazy message with 5: " + val1 + " and 10: " + val2);
logger.debug(5, 10D, "Lazy message with 5:%d and 10:%d"::formatted);

// global disable debug level
LoggerLevel.DEBUG.setEnabled(false);

// local enable debug level only for this logger instance
logger.setEnabled(LoggerLevel.DEBUG, true);

// show debug message
logger.debug("Showed");
```

### Mail Sender
Expand Down Expand Up @@ -132,10 +129,9 @@ var javaxConfig = JavaxMailSender.JavaxMailSenderConfig
var sender = new JavaxMailSender(config, javaxConfig);

sender.send("to@test.com","Test Subject","Content");

sender
.sendAsync("to@test.com","Test Subject","Content")
.thenAccept(aVoid ->System.out.println("done!"));
.thenAccept(aVoid -> System.out.println("done!"));
```

### Network API
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.version = "10.0.alpha5"
rootProject.version = "10.0.alpha6"
group = 'javasabr.rlib'

allprojects {
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/groovy/configure-java.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies {
testImplementation libs.mockito.junit.jupiter
testImplementation libs.junit.api
testImplementation libs.junit.jupiter.params
testImplementation libs.assertj.core

testCompileOnly libs.lombok
testCompileOnly libs.jspecify
Expand Down
9 changes: 5 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ angus-mail = "2.0.4"
# https://mvnrepository.com/artifact/org.testcontainers/testcontainers
testcontainers = "1.21.3"
# https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine
junit-jupiter = "5.13.4"
junit-jupiter = "6.0.1"
# https://mvnrepository.com/artifact/org.projectlombok/lombok
lombok = "1.18.38"
# https://mvnrepository.com/artifact/org.jspecify/jspecify
jspecify = "1.0.0"
# https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher
junit-platform-launcher = "1.13.4"
# https://mvnrepository.com/artifact/org.mockito/mockito-core
mockito = "5.20.0"
# https://mvnrepository.com/artifact/org.assertj/assertj-core
assertj-core = "4.0.0-M1"

[libraries]
project-reactor-core = { module = "io.projectreactor:reactor-core", version.ref = "project-reactor" }
Expand All @@ -27,7 +27,7 @@ lombok = { module = "org.projectlombok:lombok", version.ref = "lombok" }
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit-jupiter" }
junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit-jupiter" }
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit-jupiter" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform-launcher" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-jupiter" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
slf4j-ext = { module = "org.slf4j:slf4j-ext", version.ref = "slf4j" }
Expand All @@ -36,6 +36,7 @@ angus-mail = { module = "org.eclipse.angus:angus-mail", version.ref = "angus-mai
testcontainers = { module = "org.testcontainers:testcontainers", version.ref = "testcontainers" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }
assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj-core" }

[bundles]
mail = ["jakarta-mail-api", "angus-mail"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.RandomAccess;
import java.util.function.Function;
import java.util.stream.Stream;
import javasabr.rlib.collections.array.impl.DefaultArrayIterator;
Expand All @@ -16,7 +15,7 @@
/**
* @author JavaSaBr
*/
public interface Array<E> extends Iterable<E>, Serializable, Cloneable, RandomAccess {
public interface Array<E> extends Iterable<E>, Serializable, Cloneable {

static <E> Array<E> empty(Class<? super E> type) {
return new ImmutableArray<>(ClassUtils.unsafeCast(type));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public interface Dictionary<K, V> extends Iterable<V> {

Optional<V> getOptional(K key);

@Nullable
V getOrDefault(K key, V def);

<C extends Collection<K>> C keys(C container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@

public interface IntToRefDictionary<V> extends Dictionary<Integer, V> {

static <V> IntToRefEntry<V> entry(int key, @Nullable V value) {
static <V> IntToRefEntry<V> entry(int key, V value) {
return new SimpleIntToRefEntry<>(key, value);
}

static <V> IntToRefDictionary<V> empty() {
return ImmutableHashBasedIntToRefDictionary.empty();
}

static <K, V> IntToRefDictionary<V> of(int key, @Nullable V value) {
static <V> IntToRefDictionary<V> of(int key, V value) {
return ofEntries(entry(key, value));
}

static <K, V> IntToRefDictionary<V> of(int k1, @Nullable V v1, int k2, @Nullable V v2) {
static <V> IntToRefDictionary<V> of(int k1, V v1, int k2, V v2) {
return ofEntries(entry(k1, v1), entry(k2, v2));
}

@SafeVarargs
static <K, V> IntToRefDictionary<V> ofEntries(IntToRefEntry<V>... entries) {
static <V> IntToRefDictionary<V> ofEntries(IntToRefEntry<V>... entries) {
MutableIntToRefDictionary<V> mutable = DictionaryFactory.mutableIntToRefDictionary();
for (var entry : entries) {
mutable.put(entry.key(), entry.value());
Expand All @@ -42,7 +42,6 @@ static <K, V> IntToRefDictionary<V> ofEntries(IntToRefEntry<V>... entries) {

Optional<V> getOptional(int key);

@Nullable
V getOrDefault(int key, V def);

MutableIntArray keys(MutableIntArray container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@

public interface LongToRefDictionary<V> extends Dictionary<Long, V> {

static <V> LongToRefEntry<V> entry(long key, @Nullable V value) {
static <V> LongToRefEntry<V> entry(long key, V value) {
return new SimpleLongToRefEntry<>(key, value);
}

static <K, V> LongToRefDictionary<V> empty() {
static <V> LongToRefDictionary<V> empty() {
return ImmutableHashBasedLongToRefDictionary.empty();
}

static <K, V> LongToRefDictionary<V> of(long key, @Nullable V value) {
static <V> LongToRefDictionary<V> of(long key, V value) {
return ofEntries(entry(key, value));
}

static <K, V> LongToRefDictionary<V> of(long k1, @Nullable V v1, long k2, @Nullable V v2) {
static <V> LongToRefDictionary<V> of(long k1, V v1, long k2, V v2) {
return ofEntries(entry(k1, v1), entry(k2, v2));
}

@SafeVarargs
static <K, V> LongToRefDictionary<V> ofEntries(LongToRefEntry<V>... entries) {
static <V> LongToRefDictionary<V> ofEntries(LongToRefEntry<V>... entries) {
MutableLongToRefDictionary<V> mutable = DictionaryFactory.mutableLongToRefDictionary();
for (var entry : entries) {
mutable.put(entry.key(), entry.value());
Expand All @@ -42,7 +42,6 @@ static <K, V> LongToRefDictionary<V> ofEntries(LongToRefEntry<V>... entries) {

Optional<V> getOptional(long key);

@Nullable
V getOrDefault(long key, V def);

MutableLongArray keys(MutableLongArray container);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ static <V> MutableIntToRefDictionary<V> ofTypes(Class<V> valueType) {
return new DefaultMutableHashBasedIntToRefDictionary<>();
}

@Nullable
V getOrCompute(int key, Supplier<V> factory);

@Nullable
V getOrCompute(int key, IntFunction<V> factory);

@Nullable
<T> V getOrCompute(int key, T arg1, Function<T, V> factory);

/**
* @return the previous value for the key or null.
*/
@Nullable
V put(int key, @Nullable V value);
V put(int key, V value);

void putAll(IntToRefDictionary<? extends V> dictionary);

Expand All @@ -35,7 +32,7 @@ static <V> MutableIntToRefDictionary<V> ofTypes(Class<V> valueType) {
/**
* @return the optional value of the previous value for the key.
*/
Optional<V> putOptional(int key, @Nullable V value);
Optional<V> putOptional(int key, V value);

/**
* @return the previous value for the key or null.
Expand All @@ -48,5 +45,7 @@ static <V> MutableIntToRefDictionary<V> ofTypes(Class<V> valueType) {
*/
Optional<V> removeOptional(int key);

void clear();

IntToRefDictionary<V> toReadOnly();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ static <V> MutableLongToRefDictionary<V> ofTypes(Class<V> valueType) {
return new DefaultMutableHashBasedLongToRefDictionary<>();
}

@Nullable
V getOrCompute(long key, Supplier<V> factory);

@Nullable
V getOrCompute(long key, LongFunction<V> factory);

@Nullable
<T> V getOrCompute(long key, T arg1, Function<T, V> factory);

/**
* @return the previous value for the key or null.
*/
@Nullable
V put(long key, @Nullable V value);
V put(long key, V value);

void putAll(LongToRefDictionary<? extends V> dictionary);

Expand All @@ -35,7 +32,7 @@ static <V> MutableLongToRefDictionary<V> ofTypes(Class<V> valueType) {
/**
* @return the optional value of the previous value for the key.
*/
Optional<V> putOptional(long key, @Nullable V value);
Optional<V> putOptional(long key, V value);

/**
* @return the previous value for the key or null.
Expand All @@ -48,5 +45,7 @@ static <V> MutableLongToRefDictionary<V> ofTypes(Class<V> valueType) {
*/
Optional<V> removeOptional(long key);

void clear();

LongToRefDictionary<V> toReadOnly();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@ static <K, V> MutableRefToRefDictionary<K, V> ofTypes(
return new DefaultMutableHashBasedRefToRefDictionary<>();
}

@Nullable
V getOrCompute(K key, Supplier<V> factory);

@Nullable
V getOrCompute(K key, Function<K, V> factory);

@Nullable
<T> V getOrCompute(K key, T arg1, Function<T, V> factory);

/**
* @return the previous value for the key or null.
*/
@Nullable
V put(K key, @Nullable V value);
V put(K key, V value);

void putAll(RefToRefDictionary<? extends K, ? extends V> dictionary);

Expand All @@ -36,7 +33,7 @@ static <K, V> MutableRefToRefDictionary<K, V> ofTypes(
/**
* @return the optional value of the previous value for the key.
*/
Optional<V> putOptional(K key, @Nullable V value);
Optional<V> putOptional(K key, V value);

/**
* @return the previous value for the key or null.
Expand All @@ -49,5 +46,7 @@ static <K, V> MutableRefToRefDictionary<K, V> ofTypes(
*/
Optional<V> removeOptional(K key);

void clear();

RefToRefDictionary<K, V> toReadOnly();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
import java.util.function.BiConsumer;
import javasabr.rlib.collections.dictionary.impl.ImmutableHashBasedRefToRefDictionary;
import javasabr.rlib.collections.dictionary.impl.SimpleRefToRefEntry;
import org.jspecify.annotations.Nullable;

public interface RefToRefDictionary<K, V> extends Dictionary<K, V> {

static <K, V> RefToRefEntry<K, V> entry(K key, @Nullable V value) {
static <K, V> RefToRefEntry<K, V> entry(K key, V value) {
return new SimpleRefToRefEntry<>(key, value);
}

static <K, V> RefToRefDictionary<K, V> empty() {
return ImmutableHashBasedRefToRefDictionary.empty();
}

static <K, V> RefToRefDictionary<K, V> of(K key, @Nullable V value) {
static <K, V> RefToRefDictionary<K, V> of(K key, V value) {
return ofEntries(entry(key, value));
}

static <K, V> RefToRefDictionary<K, V> of(K k1, @Nullable V v1, K k2, @Nullable V v2) {
static <K, V> RefToRefDictionary<K, V> of(K k1, V v1, K k2, V v2) {
return ofEntries(entry(k1, v1), entry(k2, v2));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ protected int decrementSize() {
return size.decrementAndGet();
}

@Override
public void clear() {
Arrays.fill(entries(), null);
size.set(0);
}

@Override
protected void threshold(int threshold) {
this.threshold = threshold;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ protected int decrementSize() {
return size--;
}

@Override
public void clear() {
Arrays.fill(entries, null);
size = 0;
}

@Override
protected void threshold(int threshold) {
this.threshold = threshold;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ protected int decrementSize() {
return size--;
}

@Override
public void clear() {
Arrays.fill(entries, null);
size = 0;
}

@Override
protected void threshold(int threshold) {
this.threshold = threshold;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ protected int decrementSize() {
return size--;
}

@Override
public void clear() {
Arrays.fill(entries, null);
size = 0;
}

@Override
protected void threshold(int threshold) {
this.threshold = threshold;
Expand Down
Loading
Loading