當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。