當前位置: 首頁>>代碼示例>>Java>>正文


Java OptionalInt.getAsInt方法代碼示例

本文整理匯總了Java中java.util.OptionalInt.getAsInt方法的典型用法代碼示例。如果您正苦於以下問題:Java OptionalInt.getAsInt方法的具體用法?Java OptionalInt.getAsInt怎麽用?Java OptionalInt.getAsInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.OptionalInt的用法示例。


在下文中一共展示了OptionalInt.getAsInt方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: messageReceived

import java.util.OptionalInt; //導入方法依賴的package包/類
private void messageReceived(ChannelHandlerContext context, ByteBuf response)
{
    try {
        OptionalInt sequenceId = messageEncoding.extractResponseSequenceId(response);
        if (!sequenceId.isPresent()) {
            throw new TTransportException("Could not find sequenceId in Thrift message");
        }

        RequestHandler requestHandler = pendingRequests.remove(sequenceId.getAsInt());
        if (requestHandler == null) {
            throw new TTransportException("Unknown sequence id in response: " + sequenceId.getAsInt());
        }

        requestHandler.onResponseReceived(response);
    }
    catch (Throwable t) {
        onError(context, t);
    }
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:20,代碼來源:ThriftClientHandler.java

示例2: StreamingMkvReader

import java.util.OptionalInt; //導入方法依賴的package包/類
StreamingMkvReader(boolean requirePath,
        Collection<EBMLTypeInfo> typeInfosToRead,
        ParserByteSource byteSource,
        OptionalInt maxContentBytesAtOnce) {
    this.requirePath = requirePath;
    typeInfosToRead.stream().forEach(t -> Validate.isTrue(t.getType() != EBMLTypeInfo.TYPE.MASTER));
    this.typeInfosToRead = new HashSet(typeInfosToRead);

    this.byteSource = byteSource;
    this.mkvStreamReaderCallback = new MkvStreamReaderCallback(this.requirePath, elementFilter());
    this.previousDataElement = Optional.empty();
    MkvTypeInfoProvider typeInfoProvider = new MkvTypeInfoProvider();
    try {
        typeInfoProvider.load();
    } catch (IllegalAccessException e) {
        //TODO: fix this
        throw new RuntimeException("Could not load mkv info", e);
    }
    if (maxContentBytesAtOnce.isPresent()) {
        this.parser = new EBMLParser(typeInfoProvider, mkvStreamReaderCallback, maxContentBytesAtOnce.getAsInt());
    } else {
        this.parser = new EBMLParser(typeInfoProvider, mkvStreamReaderCallback);
    }
}
 
開發者ID:aws,項目名稱:amazon-kinesis-video-streams-parser-library,代碼行數:25,代碼來源:StreamingMkvReader.java

示例3: getLocalValueIndex

import java.util.OptionalInt; //導入方法依賴的package包/類
public int getLocalValueIndex(IQueueValue<?> value) throws QueueModelException {
	OptionalInt indexOpt = IntStream.range(0, localValues.size()).filter(i -> value.equals(localValues.get(i))).findFirst();
	try {
		return indexOpt.getAsInt();
	} catch (NoSuchElementException nseEx) {
		throw new QueueModelException(nseEx);
	}
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:9,代碼來源:ExperimentConfiguration.java

示例4: checkMessageSize

import java.util.OptionalInt; //導入方法依賴的package包/類
private void checkMessageSize(OptionalInt size) {
  if (!ehloResponse.getMaxMessageSize().isPresent() || !size.isPresent()) {
    return;
  }

  long maximumSize = ehloResponse.getMaxMessageSize().get();
  if (maximumSize < size.getAsInt()) {
    throw new MessageTooLargeException(config.getConnectionId(), maximumSize);
  }
}
 
開發者ID:HubSpot,項目名稱:NioSmtpClient,代碼行數:11,代碼來源:SmtpSession.java

示例5: selectCard

import java.util.OptionalInt; //導入方法依賴的package包/類
@Override
public int selectCard(int prizeCard, IntStream hand, int maxCard) {
    OptionalInt result = hand.min();
    return result.getAsInt();
}
 
開發者ID:codetojoy,項目名稱:WarO_Java_9_Maven,代碼行數:6,代碼來源:MinCard.java

示例6: selectCard

import java.util.OptionalInt; //導入方法依賴的package包/類
@Override
public int selectCard(int prizeCard, IntStream hand, int maxCard) {
    OptionalInt result = hand.max();
    return result.getAsInt();
}
 
開發者ID:codetojoy,項目名稱:WarO_Java_9_Maven,代碼行數:6,代碼來源:MaxCard.java

示例7: findSplitArg

import java.util.OptionalInt; //導入方法依賴的package包/類
private static OptionalInt findSplitArg(Method meth) {
    OptionalInt splitIdx = OptionalInt.empty();

    Annotation[][] parameters = meth.getParameterAnnotations();

    for (int i = 0; i < parameters.length; i++) {
        Annotation[] annotations = parameters[i];

        for (int j = 0; j < annotations.length; j++) {
            if (annotations[j].annotationType().equals(RpcSplit.class)) {
                if (splitIdx.isPresent()) {
                    throw new IllegalArgumentException("Only one argument can be annotated with @" + RpcSplit.class.getSimpleName()
                        + " [method=" + meth + ']');
                }

                splitIdx = OptionalInt.of(i);
            }
        }
    }

    if (splitIdx.isPresent()) {
        Class<?> splitType = meth.getParameterTypes()[splitIdx.getAsInt()];

        // Verify parameter type.
        if (!Collection.class.equals(splitType)
            && !Set.class.equals(splitType)
            && !List.class.equals(splitType)
            && !Map.class.equals(splitType)) {
            // Allowed types info for the error message.
            String col = Collection.class.getSimpleName();
            String lst = List.class.getSimpleName();
            String set = Set.class.getSimpleName();
            String map = Map.class.getSimpleName();

            throw new IllegalArgumentException("Parameter annotated with @" + RpcSplit.class.getSimpleName() + " has unsupported "
                + "type [supported-types={" + col + ", " + lst + ", " + set + ", " + map + "}, method=" + meth + ']');
        }
    }

    return splitIdx;
}
 
開發者ID:hekate-io,項目名稱:hekate,代碼行數:42,代碼來源:RpcMethodInfo.java

示例8: toJdbc

import java.util.OptionalInt; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 *
 * @see jp.co.future.uroborosql.parameter.mapper.BindParameterMapper#toJdbc(java.lang.Object, java.sql.Connection, jp.co.future.uroborosql.parameter.mapper.BindParameterMapperManager)
 */
@Override
public Object toJdbc(final OptionalInt original, final Connection connection,
		final BindParameterMapperManager parameterMapperManager) {
	return original.isPresent() ? original.getAsInt() : null;
}
 
開發者ID:future-architect,項目名稱:uroborosql,代碼行數:11,代碼來源:OptionalIntParameterMapper.java

示例9: testEmptyGet

import java.util.OptionalInt; //導入方法依賴的package包/類
@Test(expectedExceptions=NoSuchElementException.class)
public void testEmptyGet() {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.getAsInt();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:BasicInt.java


注:本文中的java.util.OptionalInt.getAsInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。