本文整理汇总了Java中scala.util.Success类的典型用法代码示例。如果您正苦于以下问题:Java Success类的具体用法?Java Success怎么用?Java Success使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Success类属于scala.util包,在下文中一共展示了Success类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNow
import scala.util.Success; //导入依赖的package包/类
@Override
public T getNow(T valueIfAbsent) throws ExecutionException {
Preconditions.checkNotNull(scalaFuture);
Option<Try<T>> value = scalaFuture.value();
if (value.isDefined()) {
Try<T> tri = value.get();
if (tri instanceof Success) {
return ((Success<T>)tri).value();
} else {
throw new ExecutionException(((Failure<T>)tri).exception());
}
} else {
return valueIfAbsent;
}
}
示例2: detectValueCastFromCall
import scala.util.Success; //导入依赖的package包/类
@Override
public Try<Option<ValueCast<Level>>> detectValueCastFromCall(StaticInvokeExpr e) {
SootMethod m = e.getMethod();
BiFunction<TypeView<Level>, TypeView<Level>, Try<Option<ValueCast<Level>>>>
makeCast =
(t1, t2) -> {
Optional<ValueCast<Level>> result = Interop.asJavaStream(Vars.getAll(e.getArg(0))).findFirst().map(value -> makeValueCast(t1, t2, Option.apply(value)));
return new Success<>(Interop.asScalaOption(result));
};
if (castEquals(castHighToDyn, m)) {
return makeCast.apply(THIGH, DYN);
} else if (castEquals(castLowToDyn, m)) {
return makeCast.apply(TLOW, DYN);
} else if (castEquals(castDynToLow, m)) {
return makeCast.apply(DYN, TLOW);
} else if (castEquals(castDynToHigh, m)) {
return makeCast.apply(DYN, THIGH);
} else {
return new Success<>(Option.empty());
}
}
示例3: validate
import scala.util.Success; //导入依赖的package包/类
@Override
public Try<MySQLConnection> validate(final MySQLConnection item) {
if (!item.isConnected()) {
return new Failure<>(new ConnectionNotConnectedException(item));
}
if (item.isQuerying()) {
return new Failure<>(new ConnectionStillRunningQueryException(item.count(), false));
}
return new Success<>(item);
}
示例4: start
import scala.util.Success; //导入依赖的package包/类
@Override
public void start() throws Exception {
final Promise.DefaultPromise<String> promise = new Promise.DefaultPromise<>();
CONTEXTS.add(context);
promise.onComplete(ScalaUtils.toFunction1(v -> {
if (context != Vertx.currentContext()) {
throw new RuntimeException("Bad context");
}
CONTEXTS.add(Vertx.currentContext());
}), VertxEventLoopExecutionContext.create(vertx));
promise.complete(new Success<>("hello"));
}
示例5: testThatTaskSubmittedOnVertxEventLoopAreExecutedOnThisEventLoop
import scala.util.Success; //导入依赖的package包/类
@Test
public void testThatTaskSubmittedOnVertxEventLoopAreExecutedOnThisEventLoop(TestContext tc) {
Async async = tc.async();
vertx.runOnContext(any -> {
final Context context = Vertx.currentContext();
final Promise.DefaultPromise<String> promise = new Promise.DefaultPromise<>();
promise.onComplete(ScalaUtils.toFunction1(v -> {
tc.assertEquals(context, Vertx.currentContext());
async.complete();
}), VertxEventLoopExecutionContext.create(vertx));
promise.complete(new Success<>("hello"));
});
}
开发者ID:vert-x3,项目名称:vertx-mysql-postgresql-client,代码行数:14,代码来源:VertxEventLoopExecutionContextTest.java
示例6: testThatTaskNotSubmittedOnVertxEventLoopAreExecutedOnTheEventLoop
import scala.util.Success; //导入依赖的package包/类
@Test
public void testThatTaskNotSubmittedOnVertxEventLoopAreExecutedOnTheEventLoop(TestContext tc) {
Async async = tc.async();
final Context context = Vertx.currentContext();
tc.assertNull(context);
final Promise.DefaultPromise<String> promise = new Promise.DefaultPromise<>();
promise.onComplete(ScalaUtils.toFunction1(v -> {
tc.assertNotNull(Vertx.currentContext());
async.complete();
}), VertxEventLoopExecutionContext.create(vertx));
promise.complete(new Success<>("hello"));
}
开发者ID:vert-x3,项目名称:vertx-mysql-postgresql-client,代码行数:13,代码来源:VertxEventLoopExecutionContextTest.java
示例7: testValid
import scala.util.Success; //导入依赖的package包/类
@Test
public void testValid() {
StaticInvokeExpr callCastHighToDyn = makeCall_1("castHighToDyn");
StaticInvokeExpr callCastLowToDyn = makeCall_1("castLowToDyn");
StaticInvokeExpr callCxCastHighToDyn = makeCall_0("cxCastHighToDyn");
StaticInvokeExpr callCxCastLowToDyn = makeCall_0("cxCastLowToDyn");
StaticInvokeExpr callCxCastEnd = makeCall_0("cxCastEnd");
assertThat("makeCall_ generates wrong name" + callCastHighToDyn.getMethod().toString(),
callCastHighToDyn.getMethod().toString(),
is("<de.unifreiburg.cs.proglang.jgs.support.ACasts: java.lang.Object castHighToDyn(java.lang.Object)>"));
assertThat("makeCall_ generates wrong name" + callCxCastHighToDyn.getMethod().toString(),
callCxCastHighToDyn.getMethod().toString(),
is("<de.unifreiburg.cs.proglang.jgs.support.ACasts: void cxCastHighToDyn()>"));
Map<String,String> valueCasts = new HashMap<>();
valueCasts.put(callCastHighToDyn.getMethod().toString(), "HIGH ~> ?");
valueCasts.put(callCastLowToDyn.getMethod().toString(), "LOW ~> ?");
Map<String,String> cxCasts = new HashMap<>();
cxCasts.put(callCxCastHighToDyn.getMethod().toString(), "HIGH ~> ?");
cxCasts.put(callCxCastLowToDyn.getMethod().toString(), "LOW ~> ?");
String cxCastEnd = callCxCastEnd.getMethod().toString();
ACasts<Level> casts =
CastsFromMapping$.MODULE$.<Level>apply(parseConversionMap(types, valueCasts),
parseConversionMap(types, cxCasts),
cxCastEnd);
assertThat(String.format("wrong conversion for %s", callCxCastHighToDyn.getMethod().toString()), Interop.asJavaOptional(casts.detectValueCastFromCall(callCastHighToDyn)),
convertsBetween(THIGH, DYN));
assertThat(String.format("wrong conversion for %s", callCxCastLowToDyn.getMethod().toString()), Interop.asJavaOptional(casts.detectValueCastFromCall(callCastLowToDyn)),
convertsBetween(TLOW, DYN));
assertThat(casts.detectValueCastFromCall(callCxCastHighToDyn), is(Success.apply(Option.empty())));
}
示例8: detectContextCastStartFromCall
import scala.util.Success; //导入依赖的package包/类
@Override
public Try<Option<CxCast<Level>>> detectContextCastStartFromCall(StaticInvokeExpr e) {
SootMethod m = e.getMethod();
BiFunction<TypeView<Level>, TypeView<Level>, Try<Option<CxCast<Level>>>>
makeCast =
(t1, t2) -> new Success<>(Option.apply(makeContextCast(t1, t2)));
if (castEquals(castCxDynToHigh, m)) {
return makeCast.apply(DYN, THIGH);
} else if (castEquals(castCxHighToDyn, m)) {
return makeCast.apply(THIGH, DYN);
} else {
return new Success<>(Option.empty());
}
}