vertx.effect.exp.Case Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-effect Show documentation
Show all versions of vertx-effect Show documentation
When actors meet Functional Programming
package vertx.effect.exp;
import io.vertx.core.Future;
import vertx.effect.RetryPolicy;
import vertx.effect.Val;
import vertx.effect.core.AbstractVal;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Predicate;
public final class Case extends AbstractVal {
private final Val keyVal;
private Cond cond;
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
this.cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2
);
return this;
}
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final Val otherwise) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
this.cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
otherwise
);
return this;
}
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2
) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2
);
return this;
}
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final Val otherwise
) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
otherwise
);
return this;
}
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final List keyList3,
final Val consequent3) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
Val predicate3 = keyVal.map(keyList3::contains);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3
);
return this;
}
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final List keyList3,
final Val consequent3,
final Val otherwise) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
Val predicate3 = keyVal.map(keyList3::contains);
this.cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
otherwise
);
return this;
}
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final I key3,
final Val consequent3) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
Val predicate3 = keyVal.map(key3::equals);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3
);
return this;
}
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final I key3,
final Val consequent3,
final Val otherwise) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
Val predicate3 = keyVal.map(key3::equals);
this.cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
otherwise
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final I key3,
final Val consequent3,
final I key4,
final Val consequent4) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
Val predicate3 = keyVal.map(key3::equals);
Val predicate4 = keyVal.map(key4::equals);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final I key3,
final Val consequent3,
final I key4,
final Val consequent4,
final Val otherwise) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
Val predicate3 = keyVal.map(key3::equals);
Val predicate4 = keyVal.map(key4::equals);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
otherwise
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final List keyList3,
final Val consequent3,
final List keyList4,
final Val consequent4) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
Val predicate3 = keyVal.map(keyList3::contains);
Val predicate4 = keyVal.map(keyList4::contains);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final List keyList3,
final Val consequent3,
final List keyList4,
final Val consequent4,
final Val otherwise) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
Val predicate3 = keyVal.map(keyList3::contains);
Val predicate4 = keyVal.map(keyList4::contains);
this.cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
otherwise
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final List keyList3,
final Val consequent3,
final List keyList4,
final Val consequent4,
final List keyList5,
final Val consequent5) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
Val predicate3 = keyVal.map(keyList3::contains);
Val predicate4 = keyVal.map(keyList4::contains);
Val predicate5 = keyVal.map(keyList5::contains);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
predicate5,
consequent5
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final List keyList3,
final Val consequent3,
final List keyList4,
final Val consequent4,
final List keyList5,
final Val consequent5,
final Val otherwise
) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
Val predicate3 = keyVal.map(keyList3::contains);
Val predicate4 = keyVal.map(keyList4::contains);
Val predicate5 = keyVal.map(keyList5::contains);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
predicate5,
consequent5,
otherwise
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final I key3,
final Val consequent3,
final I key4,
final Val consequent4,
final I key5,
final Val consequent5) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
Val predicate3 = keyVal.map(key3::equals);
Val predicate4 = keyVal.map(key4::equals);
Val predicate5 = keyVal.map(key5::equals);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
predicate5,
consequent5
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final I key3,
final Val consequent3,
final I key4,
final Val consequent4,
final I key5,
final Val consequent5,
final Val otherwise) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
Val predicate3 = keyVal.map(key3::equals);
Val predicate4 = keyVal.map(key4::equals);
Val predicate5 = keyVal.map(key5::equals);
this.cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
predicate5,
consequent5,
otherwise
);
return this;
}
public Case(final Val keyVal) {
this.keyVal = keyVal;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final I key3,
final Val consequent3,
final I key4,
final Val consequent4,
final I key5,
final Val consequent5,
final I key6,
final Val consequent6) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
Val predicate3 = keyVal.map(key3::equals);
Val predicate4 = keyVal.map(key4::equals);
Val predicate5 = keyVal.map(key5::equals);
Val predicate6 = keyVal.map(key6::equals);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
predicate5,
consequent5,
predicate6,
consequent6
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final I key1,
final Val consequent1,
final I key2,
final Val consequent2,
final I key3,
final Val consequent3,
final I key4,
final Val consequent4,
final I key5,
final Val consequent5,
final I key6,
final Val consequent6,
final Val otherwise) {
Val predicate1 = keyVal.map(key1::equals);
Val predicate2 = keyVal.map(key2::equals);
Val predicate3 = keyVal.map(key3::equals);
Val predicate4 = keyVal.map(key4::equals);
Val predicate5 = keyVal.map(key5::equals);
Val predicate6 = keyVal.map(key6::equals);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
predicate5,
consequent5,
predicate6,
consequent6,
otherwise
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final List keyList3,
final Val consequent3,
final List keyList4,
final Val consequent4,
final List keyList5,
final Val consequent5,
final List keyList6,
final Val consequent6) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
Val predicate3 = keyVal.map(keyList3::contains);
Val predicate4 = keyVal.map(keyList4::contains);
Val predicate5 = keyVal.map(keyList5::contains);
Val predicate6 = keyVal.map(keyList6::contains);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
predicate5,
consequent5,
predicate6,
consequent6
);
return this;
}
// squid:S00107: static factory methods usually have more than 4 parameters, that's one their advantages precisely
@SuppressWarnings("squid:S00107")
public Case of(final List keyList1,
final Val consequent1,
final List keyList2,
final Val consequent2,
final List keyList3,
final Val consequent3,
final List keyList4,
final Val consequent4,
final List keyList5,
final Val consequent5,
final List keyList6,
final Val consequent6,
final Val otherwise
) {
Val predicate1 = keyVal.map(keyList1::contains);
Val predicate2 = keyVal.map(keyList2::contains);
Val predicate3 = keyVal.map(keyList3::contains);
Val predicate4 = keyVal.map(keyList4::contains);
Val predicate5 = keyVal.map(keyList5::contains);
Val predicate6 = keyVal.map(keyList6::contains);
cond = Cond.of(predicate1,
consequent1,
predicate2,
consequent2,
predicate3,
consequent3,
predicate4,
consequent4,
predicate5,
consequent5,
predicate6,
consequent6,
otherwise
);
return this;
}
@Override
public Val retry(final int attempts) {
return cond.retry(attempts);
}
@Override
public Val retry(final int attempts,
final BiFunction> retryPolicy) {
return cond.retry(attempts,
retryPolicy
);
}
@Override
public Val retry(final Predicate predicate,
final int attempts) {
return cond.retry(predicate,
attempts
);
}
@Override
public Val retry(final Predicate predicate,
final int attempts,
final RetryPolicy retryPolicy) {
return cond.retry(predicate,
attempts,
retryPolicy
);
}
@Override
public Future get() {
return cond.get();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy