当前位置: 首页>>代码示例>>Java>>正文


Java OptionalInt.empty方法代码示例

本文整理汇总了Java中java.util.OptionalInt.empty方法的典型用法代码示例。如果您正苦于以下问题:Java OptionalInt.empty方法的具体用法?Java OptionalInt.empty怎么用?Java OptionalInt.empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.OptionalInt的用法示例。


在下文中一共展示了OptionalInt.empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEmpty

import java.util.OptionalInt; //导入方法依赖的package包/类
@Test(groups = "unit")
public void testEmpty() {
    OptionalInt empty = OptionalInt.empty();
    OptionalInt present = OptionalInt.of(1);

    // empty
    assertTrue(empty.equals(empty));
    assertTrue(empty.equals(OptionalInt.empty()));
    assertTrue(!empty.equals(present));
    assertTrue(0 == empty.hashCode());
    assertTrue(!empty.toString().isEmpty());
    assertTrue(!empty.isPresent());
    empty.ifPresent(v -> { fail(); });
    assertEquals(2, empty.orElse(2));
    assertEquals(2, empty.orElseGet(()-> 2));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:BasicInt.java

示例2: findAffinityArg

import java.util.OptionalInt; //导入方法依赖的package包/类
private static OptionalInt findAffinityArg(Method meth) {
    OptionalInt affinityArg = OptionalInt.empty();

    if (meth.getParameterCount() > 0) {
        for (int i = 0; i < meth.getParameterCount() && !affinityArg.isPresent(); i++) {
            Annotation[] annotations = meth.getParameterAnnotations()[i];

            for (int j = 0; j < annotations.length; j++) {
                if (RpcAffinityKey.class.isAssignableFrom(annotations[j].annotationType())) {
                    affinityArg = OptionalInt.of(i);

                    break;
                }
            }
        }
    }

    return affinityArg;
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:20,代码来源:RpcMethodInfo.java

示例3: extractResponseSequenceId

import java.util.OptionalInt; //导入方法依赖的package包/类
@Override
public OptionalInt extractResponseSequenceId(ByteBuf buffer)
{
    if (buffer.readableBytes() < HEADER_SEQUENCE_ID_OFFSET + Integer.BYTES) {
        return OptionalInt.empty();
    }
    return OptionalInt.of(buffer.getInt(buffer.readerIndex() + HEADER_SEQUENCE_ID_OFFSET));
}
 
开发者ID:airlift,项目名称:drift,代码行数:9,代码来源:HeaderMessageEncoding.java

示例4: getSerializedSnapshotVersion

import java.util.OptionalInt; //导入方法依赖的package包/类
public OptionalInt getSerializedSnapshotVersion(String entityId) {
    SnapshotRecord record = retrieveSnapshotRecord(entityId);
    if (record != null) {
        return OptionalInt.of(record.getHeader().payloadVersion());
    } else {
        return OptionalInt.empty();
    }
}
 
开发者ID:goodees,项目名称:goodees,代码行数:9,代码来源:InMemorySnapshotStoreWithSerialization.java

示例5: toOptionalInt

import java.util.OptionalInt; //导入方法依赖的package包/类
private static OptionalInt toOptionalInt(final String value) {
	try {
		return OptionalInt.of(Integer.parseInt(value));
	} catch (NumberFormatException e) {
		return OptionalInt.empty();
	}
}
 
开发者ID:jenetics,项目名称:prngine,代码行数:8,代码来源:DieHarder.java

示例6: extract

import java.util.OptionalInt; //导入方法依赖的package包/类
public static OptionalInt extract(String s, String factor) {
    StringTokenizer st = new StringTokenizer(s, ".");
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        if (token.startsWith(factor)) {
            try {
                return OptionalInt.of(Integer.parseInt(token.substring(factor.length())));
            } catch (NumberFormatException ex) {
                // continue
            }
        }
    }
    return OptionalInt.empty();
}
 
开发者ID:mbuzdalov,项目名称:non-dominated-sorting,代码行数:15,代码来源:IdUtils.java

示例7: testEmptyOrElseThrowNull

import java.util.OptionalInt; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:BasicInt.java

示例8: get

import java.util.OptionalInt; //导入方法依赖的package包/类
@Encoding.Expose
OptionalInt get() {
  return present
      ? OptionalInt.of(value)
      : OptionalInt.empty();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:CompactOptionalInt.java

示例9: StreamingMkvReader

import java.util.OptionalInt; //导入方法依赖的package包/类
StreamingMkvReader(boolean requirePath,
        Collection<EBMLTypeInfo> typeInfosToRead,
        ParserByteSource byteSource) {
    this(requirePath, typeInfosToRead, byteSource, OptionalInt.empty());
}
 
开发者ID:aws,项目名称:amazon-kinesis-video-streams-parser-library,代码行数:6,代码来源:StreamingMkvReader.java

示例10: getTemporalValue

import java.util.OptionalInt; //导入方法依赖的package包/类
/**
 * Returns the temporal pattern value of this ChronoPattern.
 * A missing temporal patter value means "every" of the unit.
 *
 * For example, with a chrono scale unit of SECONDS and a missing temporal value
 * this translates to: every second.
 *
 * @return temporal pattern value, if present
 */
@NotNull
public OptionalInt getTemporalValue() {
    if (temporalValue == 0) {
        return OptionalInt.empty();
    }
    return OptionalInt.of(temporalValue);
}
 
开发者ID:BFergerson,项目名称:Chronetic,代码行数:17,代码来源:ChronoPattern.java

示例11: getMpeg4Duration

import java.util.OptionalInt; //导入方法依赖的package包/类
/**
 * Getter for property {@link #mpeg4Duration}.
 *
 * @return optional value for property {@link #mpeg4Duration}
 */
public OptionalInt getMpeg4Duration() {
  return mpeg4Duration == null ? OptionalInt.empty() : OptionalInt.of(mpeg4Duration);
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:9,代码来源:InlineQueryResultMpeg4Gif.java

示例12: getThumbHeight

import java.util.OptionalInt; //导入方法依赖的package包/类
/**
 * Getter for property {@link #thumbHeight}.
 *
 * @return optional value for property {@link #thumbHeight}
 */
public OptionalInt getThumbHeight() {
  return thumbHeight == null ? OptionalInt.empty() : OptionalInt.of(thumbHeight);
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:9,代码来源:InlineQueryResultVenue.java

示例13: getVideoDuration

import java.util.OptionalInt; //导入方法依赖的package包/类
/**
 * Getter for property {@link #videoDuration}.
 *
 * @return optional value for property {@link #videoDuration}
 */
public OptionalInt getVideoDuration() {
  return videoDuration == null ? OptionalInt.empty() : OptionalInt.of(videoDuration);
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:9,代码来源:InlineQueryResultVideo.java

示例14: getThumbWidth

import java.util.OptionalInt; //导入方法依赖的package包/类
/**
 * Getter for property {@link #thumbWidth}.
 *
 * @return optional value for property {@link #thumbWidth}
 */
public OptionalInt getThumbWidth() {
  return thumbWidth == null ? OptionalInt.empty() : OptionalInt.of(thumbWidth);
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:9,代码来源:InlineQueryResultContact.java

示例15: findLast

import java.util.OptionalInt; //导入方法依赖的package包/类
/**
 * Returns the last element of the specified stream, or {@link OptionalInt#empty} if the stream is
 * empty.
 *
 * <p>Equivalent to {@code stream.reduce((a, b) -> b)}, but may perform significantly better. This
 * method's runtime will be between O(log n) and O(n), performing better on <a
 * href="http://gee.cs.oswego.edu/dl/html/StreamParallelGuidance.html">efficiently splittable</a>
 * streams.
 *
 * @see IntStream#findFirst()
 * @throws NullPointerException if the last element of the stream is null
 */
public static OptionalInt findLast(IntStream stream) {
  // findLast(Stream) does some allocation, so we might as well box some more
  java.util.Optional<Integer> boxedLast = findLast(stream.boxed());
  return boxedLast.isPresent() ? OptionalInt.of(boxedLast.get()) : OptionalInt.empty();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:18,代码来源:Streams.java


注:本文中的java.util.OptionalInt.empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。