scala.util.Try.get()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(375)

本文整理了Java中scala.util.Try.get()方法的一些代码示例,展示了Try.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Try.get()方法的具体详情如下:
包路径:scala.util.Try
类名称:Try
方法名:get

Try.get介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

  1. /**
  2. * Makes a prediction using MLeap API.
  3. *
  4. * @param inputFrame Input MLeap frame.
  5. * @return Prediction result.
  6. */
  7. public double predict(DefaultLeapFrame inputFrame) {
  8. DefaultLeapFrame outputFrame = transformer.transform(inputFrame).get();
  9. Try<DefaultLeapFrame> resFrame = outputFrame.select(new Set.Set1<>(outputFieldName).toSeq());
  10. DefaultLeapFrame frame = resFrame.get();
  11. Stream<?> stream = (Stream<?>)frame.productElement(1);
  12. Row row = (Row)stream.head();
  13. return (Double)row.get(0);
  14. }

代码示例来源:origin: com.typesafe.play/play_2.12

  1. @Override
  2. public boolean delete(TemporaryFile temporaryFile) {
  3. play.api.libs.Files.TemporaryFile scalaFile = asScala().create(temporaryFile.path());
  4. Try<Object> tryValue = asScala().delete(scalaFile);
  5. return (Boolean) tryValue.get();
  6. }

代码示例来源:origin: com.typesafe.play/play_2.12

  1. @Override
  2. public boolean delete(TemporaryFile temporaryFile) {
  3. play.api.libs.Files.TemporaryFile scalaFile = asScala().create(temporaryFile.path());
  4. Try<Object> tryValue = asScala().delete(scalaFile);
  5. return (Boolean) tryValue.get();
  6. }

代码示例来源:origin: com.typesafe.play/play

  1. @Override
  2. public boolean delete(TemporaryFile temporaryFile) {
  3. play.api.libs.Files.TemporaryFile scalaFile = asScala().create(temporaryFile.path());
  4. Try<Object> tryValue = asScala().delete(scalaFile);
  5. return (Boolean) tryValue.get();
  6. }

代码示例来源:origin: com.typesafe.play/play

  1. @Override
  2. public boolean delete(TemporaryFile temporaryFile) {
  3. play.api.libs.Files.TemporaryFile scalaFile = asScala().create(temporaryFile.path());
  4. Try<Object> tryValue = asScala().delete(scalaFile);
  5. return (Boolean) tryValue.get();
  6. }

代码示例来源:origin: com.typesafe.play/play_2.11

  1. @Override
  2. public boolean delete(TemporaryFile temporaryFile) {
  3. play.api.libs.Files.TemporaryFile scalaFile = asScala().create(temporaryFile.path());
  4. Try<Object> tryValue = asScala().delete(scalaFile);
  5. return (Boolean) tryValue.get();
  6. }

代码示例来源:origin: com.typesafe.play/play_2.11

  1. @Override
  2. public boolean delete(TemporaryFile temporaryFile) {
  3. play.api.libs.Files.TemporaryFile scalaFile = asScala().create(temporaryFile.path());
  4. Try<Object> tryValue = asScala().delete(scalaFile);
  5. return (Boolean) tryValue.get();
  6. }

代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client

  1. @Override
  2. public Void apply(Try<T> v1) {
  3. if (v1.isSuccess()) {
  4. fut.complete(v1.get());
  5. } else {
  6. fut.fail(v1.failed().get());
  7. }
  8. return null;
  9. }
  10. }, ec);

代码示例来源:origin: org.mule.modules/edi-module-x12

  1. private Map<String, Object> parse(X12InterchangeParser parser) {
  2. Try<Map<String, Object>> parse = parser.parse();
  3. return parse.get();
  4. }

代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client

  1. @Override
  2. public Void apply(Try<V> v1) {
  3. if (v1.isSuccess()) {
  4. code.handle(Future.succeededFuture(v1.get()));
  5. } else {
  6. code.handle(Future.failedFuture(v1.failed().get()));
  7. }
  8. return null;
  9. }
  10. };

代码示例来源:origin: vert-x3/vertx-mysql-postgresql-client

  1. @Override
  2. public Void apply(Try<T> v1) {
  3. if (v1.isSuccess()) {
  4. fut.complete();
  5. } else {
  6. fut.fail(v1.failed().get());
  7. }
  8. return null;
  9. }
  10. }, ec);

代码示例来源:origin: org.talend.components/processing-runtime

  1. private List<Object> getInputFields(IndexedRecord inputRecord, String columnName) {
  2. // Adapt non-avpath syntax to avpath.
  3. // TODO: This should probably not be automatic, use the actual syntax.
  4. if (!columnName.startsWith("."))
  5. columnName = "." + columnName;
  6. Try<scala.collection.immutable.List<Evaluator.Ctx>> result = wandou.avpath.package$.MODULE$.select(inputRecord,
  7. columnName);
  8. List<Object> values = new ArrayList<Object>();
  9. if (result.isSuccess()) {
  10. for (Evaluator.Ctx ctx : JavaConversions.asJavaCollection(result.get())) {
  11. values.add(ctx.value());
  12. }
  13. } else {
  14. // Evaluating the expression failed, and we can handle the exception.
  15. Throwable t = result.failed().get();
  16. throw ProcessingErrorCode.createAvpathSyntaxError(t, columnName, -1);
  17. }
  18. return values;
  19. }

代码示例来源:origin: uber/hudi

  1. public GenericRecord fromAvroBinary(byte[] avroBinary) {
  2. initSchema();
  3. initInjection();
  4. return recordInjection.invert(avroBinary).get();
  5. }
  6. }

代码示例来源:origin: com.uber.hoodie/hoodie-utilities

  1. public GenericRecord fromAvroBinary(byte[] avroBinary) throws IOException {
  2. initSchema();
  3. initInjection();
  4. return recordInjection.invert(avroBinary).get();
  5. }
  6. }

代码示例来源:origin: code-not-found/spring-kafka

  1. @SuppressWarnings("unchecked")
  2. @Override
  3. public T deserialize(String topic, byte[] data) {
  4. LOGGER.debug("data to deserialize='{}'", DatatypeConverter.printHexBinary(data));
  5. try {
  6. // get the schema
  7. Schema schema = targetType.newInstance().getSchema();
  8. Injection<GenericRecord, byte[]> genericRecordInjection = GenericAvroCodecs.toBinary(schema);
  9. GenericRecord genericRecord = genericRecordInjection.invert((byte[]) data).get();
  10. T result = (T) SpecificData.get().deepCopy(schema, genericRecord);
  11. LOGGER.debug("data='{}'", result);
  12. return result;
  13. } catch (Exception e) {
  14. throw new SerializationException(
  15. "Can't deserialize data [" + Arrays.toString(data) + "] from topic [" + topic + "]", e);
  16. }
  17. }
  18. }

代码示例来源:origin: com.lightbend.akka/akka-stream-alpakka-file

  1. @Override
  2. public void preStart() {
  3. chunkCallback =
  4. createAsyncCallback(
  5. (tryInteger) -> {
  6. if (tryInteger.isSuccess()) {
  7. int readBytes = tryInteger.get();
  8. if (readBytes > 0) {
  9. buffer.flip();
  10. push(out, ByteString.fromByteBuffer(buffer));
  11. position += readBytes;
  12. buffer.clear();
  13. } else {
  14. // hit end, try again in a while
  15. scheduleOnce("poll", pollingInterval);
  16. }
  17. } else {
  18. failStage(tryInteger.failed().get());
  19. }
  20. });
  21. }

代码示例来源:origin: eclipse/ditto

  1. /**
  2. * Load the configured protocol adapter provider by reflection.
  3. * Call the 1-argument constructor every subclass of {@link ProtocolAdapterProvider} should implement.
  4. *
  5. * @param actorSystem Akka actor system to perform reflection with.
  6. * @return the loaded protocol adapter provider.
  7. */
  8. public ProtocolAdapterProvider loadProtocolAdapterProvider(final ActorSystem actorSystem) {
  9. final String className = provider();
  10. final ClassTag<ProtocolAdapterProvider> tag = ClassTag$.MODULE$.apply(ProtocolAdapterProvider.class);
  11. final List<Tuple2<Class<?>, Object>> constructorArgs =
  12. Collections.singletonList(new Tuple2<>(getClass(), this));
  13. final DynamicAccess dynamicAccess = ((ExtendedActorSystem) actorSystem).dynamicAccess();
  14. final Try<ProtocolAdapterProvider> providerBox = dynamicAccess.createInstanceFor(className,
  15. JavaConverters.asScalaBuffer(constructorArgs).toList(), tag);
  16. return providerBox.get();
  17. }

代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore

  1. private static ShardBackendInfo createBackendInfo(final Object result, final String shardName, final Long cookie) {
  2. Preconditions.checkArgument(result instanceof PrimaryShardInfo);
  3. final PrimaryShardInfo info = (PrimaryShardInfo) result;
  4. LOG.debug("Creating backend information for {}", info);
  5. return new ShardBackendInfo(info.getPrimaryShardActor().resolveOne(DEAD_TIMEOUT).value().get().get(),
  6. toABIVersion(info.getPrimaryShardVersion()), shardName, UnsignedLong.fromLongBits(cookie),
  7. info.getLocalShardDataTree());
  8. }
  9. }

代码示例来源:origin: org.eclipse.ditto/ditto-services-utils-cluster

  1. /**
  2. * Loads the {@link MappingStrategy} in the passed ActorSystem this is running in by looking up the config key
  3. * {@value CONFIGKEY_DITTO_MAPPING_STRATEGY_IMPLEMENTATION}.
  4. *
  5. * @param actorSystem the ActorSystem we are running in.
  6. * @return the resolved MappingStrategy.
  7. */
  8. static MappingStrategy loadMappingStrategy(final ActorSystem actorSystem) {
  9. // load via config the class implementing MappingStrategy:
  10. final String mappingStrategyClass =
  11. actorSystem.settings().config().getString(CONFIGKEY_DITTO_MAPPING_STRATEGY_IMPLEMENTATION);
  12. final ClassTag<MappingStrategy> tag = scala.reflect.ClassTag$.MODULE$.apply(MappingStrategy.class);
  13. final List<Tuple2<Class<?>, Object>> constructorArgs = new ArrayList<>();
  14. final Try<MappingStrategy> mappingStrategy =
  15. ((ExtendedActorSystem) actorSystem).dynamicAccess().createInstanceFor(mappingStrategyClass,
  16. JavaConversions.asScalaBuffer(constructorArgs).toList(), tag);
  17. return mappingStrategy.get();
  18. }

代码示例来源:origin: eclipse/ditto

  1. /**
  2. * Loads the {@link MappingStrategy} in the passed ActorSystem this is running in by looking up the config key
  3. * {@value CONFIGKEY_DITTO_MAPPING_STRATEGY_IMPLEMENTATION}.
  4. *
  5. * @param actorSystem the ActorSystem we are running in.
  6. * @return the resolved MappingStrategy.
  7. */
  8. static MappingStrategy loadMappingStrategy(final ActorSystem actorSystem) {
  9. // load via config the class implementing MappingStrategy:
  10. final String mappingStrategyClass =
  11. actorSystem.settings().config().getString(CONFIGKEY_DITTO_MAPPING_STRATEGY_IMPLEMENTATION);
  12. final ClassTag<MappingStrategy> tag = scala.reflect.ClassTag$.MODULE$.apply(MappingStrategy.class);
  13. final List<Tuple2<Class<?>, Object>> constructorArgs = new ArrayList<>();
  14. final Try<MappingStrategy> mappingStrategy =
  15. ((ExtendedActorSystem) actorSystem).dynamicAccess().createInstanceFor(mappingStrategyClass,
  16. JavaConversions.asScalaBuffer(constructorArgs).toList(), tag);
  17. return mappingStrategy.get();
  18. }

相关文章