本文整理汇总了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;
}
}
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:FlinkFuture.java
示例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());
}
}
开发者ID:proglang,项目名称:jgs,代码行数:22,代码来源:TestDomain.java
示例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);
}
开发者ID:outbrain,项目名称:ob1k,代码行数:13,代码来源:BasicTestingDao.java
示例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"));
}
开发者ID:vert-x3,项目名称:vertx-mysql-postgresql-client,代码行数:13,代码来源:MyVerticle.java
示例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())));
}
开发者ID:proglang,项目名称:jgs,代码行数:35,代码来源:CastsFromMappingTest.java
示例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());
}
}
开发者ID:proglang,项目名称:jgs,代码行数:15,代码来源:TestDomain.java
注:本文中的scala.util.Success类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论