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


Java Objects.requireNonNull方法代码示例

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


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

示例1: flatMap

import java.util.Objects; //导入方法依赖的package包/类
@Override
public final <R> Stream<R> flatMap(Function<? super P_OUT, ? extends Stream<? extends R>> mapper) {
    Objects.requireNonNull(mapper);
    // We can do better than this, by polling cancellationRequested when stream is infinite
    return new StatelessOp<P_OUT, R>(this, StreamShape.REFERENCE,
                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) {
            return new Sink.ChainedReference<P_OUT, R>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(P_OUT u) {
                    try (Stream<? extends R> result = mapper.apply(u)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(downstream);
                    }
                }
            };
        }
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:ReferencePipeline.java

示例2: forEachRemaining

import java.util.Objects; //导入方法依赖的package包/类
@Override
public void forEachRemaining(T_CONS action) {
    Objects.requireNonNull(action);

    if (sliceOrigin >= fence)
        return;

    if (index >= fence)
        return;

    if (index >= sliceOrigin && (index + s.estimateSize()) <= sliceFence) {
        // The spliterator is contained within the slice
        s.forEachRemaining(action);
        index = fence;
    } else {
        // The spliterator intersects with the slice
        while (sliceOrigin > index) {
            s.tryAdvance(emptyConsumer());
            index++;
        }
        // Traverse elements up to the fence
        for (;index < fence; index++) {
            s.tryAdvance(action);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:StreamSpliterators.java

示例3: UcteNode

import java.util.Objects; //导入方法依赖的package包/类
public UcteNode(UcteNodeCode code, String geographicalName, UcteNodeStatus status, UcteNodeTypeCode typeCode,
                float voltageReference, float activeLoad, float reactiveLoad, float activePowerGeneration,
                float reactivePowerGeneration, float minimumPermissibleActivePowerGeneration,
                float maximumPermissibleActivePowerGeneration, float minimumPermissibleReactivePowerGeneration,
                float maximumPermissibleReactivePowerGeneration, float staticOfPrimaryControl,
                float nominalPowerPrimaryControl, float threePhaseShortCircuitPower, float xrRatio,
                UctePowerPlantType powerPlantType) {
    this.code = Objects.requireNonNull(code);
    this.geographicalName = geographicalName;
    this.status = Objects.requireNonNull(status);
    this.typeCode = Objects.requireNonNull(typeCode);
    this.voltageReference = voltageReference;
    this.activeLoad = activeLoad;
    this.reactiveLoad = reactiveLoad;
    this.activePowerGeneration = activePowerGeneration;
    this.reactivePowerGeneration = reactivePowerGeneration;
    this.minimumPermissibleActivePowerGeneration = minimumPermissibleActivePowerGeneration;
    this.maximumPermissibleActivePowerGeneration = maximumPermissibleActivePowerGeneration;
    this.minimumPermissibleReactivePowerGeneration = minimumPermissibleReactivePowerGeneration;
    this.maximumPermissibleReactivePowerGeneration = maximumPermissibleReactivePowerGeneration;
    this.staticOfPrimaryControl = staticOfPrimaryControl;
    this.nominalPowerPrimaryControl = nominalPowerPrimaryControl;
    this.threePhaseShortCircuitPower = threePhaseShortCircuitPower;
    this.xrRatio = xrRatio;
    this.powerPlantType = powerPlantType;
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:27,代码来源:UcteNode.java

示例4: addSuggestion

import java.util.Objects; //导入方法依赖的package包/类
/**
 * Adds an {@link org.elasticsearch.search.suggest.SuggestionBuilder} instance under a user defined name.
 * The order in which the <code>Suggestions</code> are added, is the same as in the response.
 * @throws IllegalArgumentException if two suggestions added have the same name
 */
public SuggestBuilder addSuggestion(String name, SuggestionBuilder<?> suggestion) {
    Objects.requireNonNull(name, "every suggestion needs a name");
    if (suggestions.get(name) == null) {
        suggestions.put(name, suggestion);
    } else {
        throw new IllegalArgumentException("already added another suggestion with name [" + name + "]");
    }
    return this;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:SuggestBuilder.java

示例5: RedisSessionManager

import java.util.Objects; //导入方法依赖的package包/类
public RedisSessionManager(SessionConfig sessionConfig, SessionRepository sessionRepository){
Objects.requireNonNull(sessionConfig);
Objects.requireNonNull(sessionRepository);
this.sessionConfig=sessionConfig;
      this.sessionRepository=sessionRepository;

  }
 
开发者ID:networknt,项目名称:light-session-4j,代码行数:8,代码来源:RedisSessionManager.java

示例6: DateObjectValueSource

import java.util.Objects; //导入方法依赖的package包/类
DateObjectValueSource(IndexFieldData<?> indexFieldData, MultiValueMode multiValueMode, 
                      String methodName, ToIntFunction<ReadableDateTime> function) {
    super(indexFieldData, multiValueMode);

    Objects.requireNonNull(methodName);

    this.methodName = methodName;
    this.function = function;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:DateObjectValueSource.java

示例7: createCellIfNotPresent

import java.util.Objects; //导入方法依赖的package包/类
public static XSSFCell createCellIfNotPresent(XSSFRow row, int colIndex) {
	String message = "XSSFRow must not be null!";
	Objects.requireNonNull(row, () -> message);
	XSSFCell cell = row.getCell(colIndex);
	if (Objects.isNull(cell)) {
		cell = row.createCell(colIndex);
	}
	return cell;
}
 
开发者ID:gp15237125756,项目名称:PoiExcelExport2.0,代码行数:10,代码来源:CellValueUtil.java

示例8: with

import java.util.Objects; //导入方法依赖的package包/类
/**
 * Replaces the elements in the list with values given by the supplier.
 *
 * @param replacementSupplier the supplier to use to get replacement values
 *
 * @throws IllegalStateException if no values were specified to be replaced with {@link #replace(T)}
 *                               or {@link #replace(Predicate)}
 */
public void with(Supplier<? extends T> replacementSupplier) {
  Objects.requireNonNull(replacementSupplier, "replacementSupplier");
  if (test.equals(ALWAYS_FALSE)) {
    throw new IllegalStateException("No values were specified to be replaced");
  }
  for (int i = 0; i < list.size(); i++) {
    if (test.test(list.get(i))) {
      list.set(i, replacementSupplier.get());
      if (strategy == Strategy.FIRST) {
        return;
      }
    }
  }
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:23,代码来源:ListUtils.java

示例9: putThreadContext

import java.util.Objects; //导入方法依赖的package包/类
public static void putThreadContext(AwsProxyRequest request, List<String> loggingHeaders) {
    List<String> availableLoggingHeaders = Objects.requireNonNull(loggingHeaders);
    Optional.ofNullable(request.getRequestContext())
        .map(ApiGatewayRequestContext::getIdentity)
        .map(ApiGatewayRequestIdentity::getSourceIp)
        .ifPresent(ip -> ThreadContext.put("sourceIp", ip));
    Optional.ofNullable(request.getHeaders())
        .ifPresent(headers -> availableLoggingHeaders.forEach(
            headerKey -> putIfNotNullValue(headerKey, headers.get(headerKey))));
}
 
开发者ID:visionarts,项目名称:power-jambda,代码行数:11,代码来源:LambdaLoggerHelper.java

示例10: RGA

import java.util.Objects; //导入方法依赖的package包/类
public RGA(String nodeId, String crdtId) {
    this.crdtId = Objects.requireNonNull(crdtId, "CrtdId must not be null");

    Objects.requireNonNull(nodeId, "NodeId must not be null");
    this.clock = new StrictVectorClock(nodeId);
    this.start = new Vertex<>(null, clock);
    this.vertices = HashMap.of(clock, start);
}
 
开发者ID:netopyr,项目名称:wurmloch-crdt,代码行数:9,代码来源:RGA.java

示例11: foreach

import java.util.Objects; //导入方法依赖的package包/类
@Override
public void foreach(ForeachAction<? super K, ? super V> action) {
    Objects.requireNonNull(action, "action can't be null");
    String name = topology.newName(FOREACH_NAME);

    topology.addProcessor(name, new KStreamPeek<>(action, false), this.name);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:8,代码来源:KStreamImpl.java

示例12: schedule

import java.util.Objects; //导入方法依赖的package包/类
@Override
public AutoDisposable schedule(Runnable task, long delay, TimeUnit unit) {
    Objects.requireNonNull(task, "task == null");
    ScheduledExecutorService exec = (ScheduledExecutorService)EXEC.getAcquire(this);
    WorkerTask wt = new WorkerTask(task, null);
    try {
        Future<?> f = exec.schedule((Callable<Void>)wt, delay, unit);
        wt.setFutureNoCancel(f);
        return wt;
    } catch (RejectedExecutionException ex) {
        FolyamPlugins.onError(ex);
    }
    return REJECTED;
}
 
开发者ID:akarnokd,项目名称:Reactive4JavaFlow,代码行数:15,代码来源:SingleSchedulerService.java

示例13: load

import java.util.Objects; //导入方法依赖的package包/类
public static ImportConfig load(PlatformConfig platformConfig) {
    Objects.requireNonNull(platformConfig);
    List<String> postProcessors;
    if (platformConfig.moduleExists("import")) {
        ModuleConfig config = platformConfig.getModuleConfig("import");
        postProcessors = config.getStringListProperty("postProcessors", DEFAULT_POST_PROCESSORS);
    } else {
        postProcessors = DEFAULT_POST_PROCESSORS;
    }
    return new ImportConfig(postProcessors);
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:12,代码来源:ImportConfig.java

示例14: ConvolutionKernel

import java.util.Objects; //导入方法依赖的package包/类
public ConvolutionKernel(final byte[] pixels, final int width, final int height) {
	this.pixels = Objects.requireNonNull(pixels, "pixels == null");
	this.pixelsCopy = pixels.clone();
	this.width = width;
	this.height = height;
}
 
开发者ID:macroing,项目名称:Dayflower-Path-Tracer,代码行数:7,代码来源:ConvolutionKernel.java

示例15: getExtension

import java.util.Objects; //导入方法依赖的package包/类
public static Optional<String> getExtension(final URL url) {

        Objects.requireNonNull(url, "url is null");

        final String file = url.getFile();

        if (file.contains(".")) {

            final String sub = file.substring(file.lastIndexOf('.') + 1);

            if (sub.length() == 0) {
                return Optional.empty();
            }

            if (sub.contains("?")) {
                return Optional.of(sub.substring(0, sub.indexOf('?')));
            }

            return Optional.of(sub);
        }

        return Optional.empty();
    }
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:24,代码来源:URLUtils.java


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