本文整理汇总了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);
}
}
};
}
};
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
示例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))));
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}