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

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

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

Try.get介绍

暂无

代码示例

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

/**
 * Makes a prediction using MLeap API.
 *
 * @param inputFrame Input MLeap frame.
 * @return Prediction result.
 */
public double predict(DefaultLeapFrame inputFrame) {
  DefaultLeapFrame outputFrame = transformer.transform(inputFrame).get();
  Try<DefaultLeapFrame> resFrame = outputFrame.select(new Set.Set1<>(outputFieldName).toSeq());
  DefaultLeapFrame frame = resFrame.get();
  Stream<?> stream = (Stream<?>)frame.productElement(1);
  Row row = (Row)stream.head();
  return (Double)row.get(0);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

@Override
 public Void apply(Try<T> v1) {
  if (v1.isSuccess()) {
   fut.complete(v1.get());
  } else {
   fut.fail(v1.failed().get());
  }
  return null;
 }
}, ec);

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

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

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

@Override
 public Void apply(Try<V> v1) {
  if (v1.isSuccess()) {
   code.handle(Future.succeededFuture(v1.get()));
  } else {
   code.handle(Future.failedFuture(v1.failed().get()));
  }
  return null;
 }
};

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

@Override
 public Void apply(Try<T> v1) {
  if (v1.isSuccess()) {
   fut.complete();
  } else {
   fut.fail(v1.failed().get());
  }
  return null;
 }
}, ec);

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

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

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

public GenericRecord fromAvroBinary(byte[] avroBinary) {
  initSchema();
  initInjection();
  return recordInjection.invert(avroBinary).get();
 }
}

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

public GenericRecord fromAvroBinary(byte[] avroBinary) throws IOException {
  initSchema();
  initInjection();
  return recordInjection.invert(avroBinary).get();
 }
}

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

@SuppressWarnings("unchecked")
 @Override
 public T deserialize(String topic, byte[] data) {
  LOGGER.debug("data to deserialize='{}'", DatatypeConverter.printHexBinary(data));
  try {
   // get the schema
   Schema schema = targetType.newInstance().getSchema();

   Injection<GenericRecord, byte[]> genericRecordInjection = GenericAvroCodecs.toBinary(schema);
   GenericRecord genericRecord = genericRecordInjection.invert((byte[]) data).get();
   T result = (T) SpecificData.get().deepCopy(schema, genericRecord);

   LOGGER.debug("data='{}'", result);
   return result;
  } catch (Exception e) {
   throw new SerializationException(
     "Can't deserialize data [" + Arrays.toString(data) + "] from topic [" + topic + "]", e);
  }
 }
}

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

@Override
public void preStart() {
 chunkCallback =
   createAsyncCallback(
     (tryInteger) -> {
      if (tryInteger.isSuccess()) {
       int readBytes = tryInteger.get();
       if (readBytes > 0) {
        buffer.flip();
        push(out, ByteString.fromByteBuffer(buffer));
        position += readBytes;
        buffer.clear();
       } else {
        // hit end, try again in a while
        scheduleOnce("poll", pollingInterval);
       }
      } else {
       failStage(tryInteger.failed().get());
      }
     });
}

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

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

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

private static ShardBackendInfo createBackendInfo(final Object result, final String shardName, final Long cookie) {
    Preconditions.checkArgument(result instanceof PrimaryShardInfo);
    final PrimaryShardInfo info = (PrimaryShardInfo) result;

    LOG.debug("Creating backend information for {}", info);
    return new ShardBackendInfo(info.getPrimaryShardActor().resolveOne(DEAD_TIMEOUT).value().get().get(),
      toABIVersion(info.getPrimaryShardVersion()), shardName, UnsignedLong.fromLongBits(cookie),
      info.getLocalShardDataTree());
   }
}

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

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

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

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

相关文章

微信公众号

最新文章

更多