java.util.OptionalInt#orElseThrow ( )源码实例Demo

下面列出了java.util.OptionalInt#orElseThrow ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: attic-polygene-java   文件: FreePortFinder.java
public static int findFreePort( InetAddress address )
{
    FreePortPredicate check = new FreePortPredicate( address );
    // Randomly choose MAX_PORT_CHECKS ports from the least used ranges
    Range range = LEAST_USED_RANGES.get( new Random().nextInt( LEAST_USED_RANGES.size() ) );
    OptionalInt port = rangeClosed( range.lowerBound, range.higherBound )
        .boxed()
        .collect( collectingAndThen( toList(), collected ->
        {
            collected.removeAll( BLACKLIST );
            shuffle( collected );
            return collected.stream();
        } ) )
        .limit( MAX_PORT_CHECKS )
        .mapToInt( Integer::intValue )
        .filter( check )
        .findFirst();
    return port.orElseThrow( () ->
    {
        IOException exception = new IOException( "Unable to find a free port on " + address );
        check.errors.build().forEach( exception::addSuppressed );
        return new UncheckedIOException( exception );
    } );
}
 
源代码2 项目: presto   文件: PartitionedLookupSourceFactory.java
@Override
public ListenableFuture<PartitionedConsumption<Supplier<LookupSource>>> finishProbeOperator(OptionalInt lookupJoinsCount)
{
    lock.writeLock().lock();
    try {
        if (!spillingInfo.hasSpilled()) {
            finishedProbeOperators++;
            return immediateFuture(new PartitionedConsumption<>(
                    1,
                    emptyList(),
                    i -> {
                        throw new UnsupportedOperationException();
                    },
                    i -> {}));
        }

        int operatorsCount = lookupJoinsCount
                .orElseThrow(() -> new IllegalStateException("A fixed distribution is required for JOIN when spilling is enabled"));
        checkState(finishedProbeOperators < operatorsCount, "%s probe operators finished out of %s declared", finishedProbeOperators + 1, operatorsCount);

        if (partitionedConsumptionParticipants.isEmpty()) {
            // This is the first probe to finish after anything has been spilled.
            partitionedConsumptionParticipants = OptionalInt.of(operatorsCount - finishedProbeOperators);
        }

        finishedProbeOperators++;
        if (finishedProbeOperators == operatorsCount) {
            // We can dispose partitions now since as right outer is not supported with spill
            freePartitions();
            verify(!partitionedConsumption.isDone());
            partitionedConsumption.set(new PartitionedConsumption<>(
                    partitionedConsumptionParticipants.getAsInt(),
                    spilledPartitions.keySet(),
                    this::loadSpilledLookupSource,
                    this::disposeSpilledLookupSource));
        }

        return partitionedConsumption;
    }
    finally {
        lock.writeLock().unlock();
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码4 项目: dragonwell8_jdk   文件: BasicInt.java
@Test(expectedExceptions=ObscureException.class)
public void testEmptyOrElseThrow() throws Exception {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(ObscureException::new);
}
 
源代码5 项目: TencentKona-8   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码6 项目: jdk8u-dev-jdk   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码7 项目: jdk8u60   文件: BasicInt.java
@Test(expectedExceptions=ObscureException.class)
public void testEmptyOrElseThrow() throws Exception {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(ObscureException::new);
}
 
源代码8 项目: openjdk-jdk8u   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码9 项目: drift   文件: EchoServiceHandler.java
@Override
public int echoOptionalInt(OptionalInt value)
        throws EmptyOptionalException
{
    return value.orElseThrow(EmptyOptionalException::new);
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码11 项目: openjdk-8   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码12 项目: openjdk-jdk9   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码13 项目: openjdk-jdk9   文件: BasicInt.java
@Test(expectedExceptions=ObscureException.class)
public void testEmptyOrElseThrow() throws Exception {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(ObscureException::new);
}
 
源代码14 项目: jdk8u-jdk   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码15 项目: jdk8u-dev-jdk   文件: BasicInt.java
@Test(expectedExceptions=ObscureException.class)
public void testEmptyOrElseThrow() throws Exception {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(ObscureException::new);
}
 
源代码16 项目: hottub   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码17 项目: hottub   文件: BasicInt.java
@Test(expectedExceptions=ObscureException.class)
public void testEmptyOrElseThrow() throws Exception {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(ObscureException::new);
}
 
源代码18 项目: jdk8u-jdk   文件: BasicInt.java
@Test(expectedExceptions=NullPointerException.class)
public void testEmptyOrElseThrowNull() throws Throwable {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(null);
}
 
源代码19 项目: jdk8u_jdk   文件: BasicInt.java
@Test(expectedExceptions=ObscureException.class)
public void testEmptyOrElseThrow() throws Exception {
    OptionalInt empty = OptionalInt.empty();

    int got = empty.orElseThrow(ObscureException::new);
}
 
源代码20 项目: levelup-java-examples   文件: OptionalIntExample.java
@Test(expected=IllegalStateException.class)
public void optional_int_orElseThrow() {
	
	OptionalInt optionalFramework = OptionalInt.empty();

	optionalFramework.orElseThrow(IllegalStateException::new);
}