本文整理了Java中java.util.Objects.requireNonNull()
方法的一些代码示例,展示了Objects.requireNonNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Objects.requireNonNull()
方法的具体详情如下:
包路径:java.util.Objects
类名称:Objects
方法名:requireNonNull
[英]Returns o if non-null, or throws NullPointerException.
[中]如果为非null,则返回o,或引发NullPointerException。
代码示例来源:origin: skylot/jadx
private ResContainer(String name, List<ResContainer> subFiles, Object data, DataType dataType) {
this.name = Objects.requireNonNull(name);
this.subFiles = Objects.requireNonNull(subFiles);
this.data = Objects.requireNonNull(data);
this.dataType = Objects.requireNonNull(dataType);
}
代码示例来源:origin: skylot/jadx
public JadxWarn(String warn) {
this.warn = Objects.requireNonNull(warn);
}
代码示例来源:origin: skylot/jadx
public ImmutableList(E[] arr) {
this.arr = Objects.requireNonNull(arr);
}
代码示例来源:origin: apache/kafka
public Builder(Map<ConfigResource, Config> configs, boolean validateOnly) {
super(ApiKeys.ALTER_CONFIGS);
this.configs = Objects.requireNonNull(configs, "configs");
this.validateOnly = validateOnly;
}
代码示例来源:origin: apache/kafka
public AlterConfigsRequest(short version, Map<ConfigResource, Config> configs, boolean validateOnly) {
super(ApiKeys.ALTER_CONFIGS, version);
this.configs = Objects.requireNonNull(configs, "configs");
this.validateOnly = validateOnly;
}
代码示例来源:origin: apache/kafka
public RequestHeader(ApiKeys apiKey, short version, String clientId, int correlation) {
this.apiKey = requireNonNull(apiKey);
this.apiVersion = version;
this.clientId = clientId;
this.correlationId = correlation;
}
代码示例来源:origin: apache/kafka
public void reauthenticating(String previousSaslMechanism, KafkaPrincipal previousKafkaPrincipal,
long reauthenticationBeginNanos) {
this.previousSaslMechanism = Objects.requireNonNull(previousSaslMechanism);
this.previousKafkaPrincipal = Objects.requireNonNull(previousKafkaPrincipal);
this.reauthenticationBeginNanos = reauthenticationBeginNanos;
}
代码示例来源:origin: apache/kafka
/**
* Create an instance of this class with the provided parameters.
*
* @param resourceType non-null resource type
* @param name resource name or null
*/
public ResourceFilter(ResourceType resourceType, String name) {
Objects.requireNonNull(resourceType);
this.resourceType = resourceType;
this.name = name;
}
代码示例来源:origin: apache/kafka
private PendingCommittedOffsetRequest(final Set<TopicPartition> requestedPartitions,
final Generation generationAtRequestTime,
final RequestFuture<Map<TopicPartition, OffsetAndMetadata>> response) {
this.requestedPartitions = Objects.requireNonNull(requestedPartitions);
this.response = Objects.requireNonNull(response);
this.requestedGeneration = generationAtRequestTime;
}
代码示例来源:origin: apache/kafka
/**
* For testing
*
* @param time
* the mandatory time to set
*/
void time(Time time) {
this.time = Objects.requireNonNull(time);
}
代码示例来源:origin: skylot/jadx
@SuppressWarnings({"unchecked", "SuspiciousArrayCast"})
public ImmutableList(Collection<E> col) {
this((E[]) Objects.requireNonNull(col).toArray());
}
代码示例来源:origin: apache/kafka
private String option(String key) {
if (!configured)
throw new IllegalStateException("Callback handler not configured");
return moduleOptions.get(Objects.requireNonNull(key));
}
代码示例来源:origin: apache/kafka
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
Map<String, ?> options) {
this.subject = Objects.requireNonNull(subject);
if (!(Objects.requireNonNull(callbackHandler) instanceof AuthenticateCallbackHandler))
throw new IllegalArgumentException(String.format("Callback handler must be castable to %s: %s",
AuthenticateCallbackHandler.class.getName(), callbackHandler.getClass().getName()));
this.callbackHandler = (AuthenticateCallbackHandler) callbackHandler;
}
代码示例来源:origin: ctripcorp/apollo
public boolean isAppNamespaceNameUnique(String appId, String namespaceName) {
Objects.requireNonNull(appId, "AppId must not be null");
Objects.requireNonNull(namespaceName, "Namespace must not be null");
return Objects.isNull(appNamespaceRepository.findByAppIdAndName(appId, namespaceName));
}
代码示例来源:origin: ctripcorp/apollo
public boolean isAppNamespaceNameUnique(String appId, String namespaceName) {
Objects.requireNonNull(appId, "AppId must not be null");
Objects.requireNonNull(namespaceName, "Namespace must not be null");
return Objects.isNull(appNamespaceRepository.findByAppIdAndName(appId, namespaceName));
}
代码示例来源:origin: apache/kafka
public OAuthBearerSaslServer(CallbackHandler callbackHandler) {
if (!(Objects.requireNonNull(callbackHandler) instanceof AuthenticateCallbackHandler))
throw new IllegalArgumentException(String.format("Callback handler must be castable to %s: %s",
AuthenticateCallbackHandler.class.getName(), callbackHandler.getClass().getName()));
this.callbackHandler = (AuthenticateCallbackHandler) callbackHandler;
}
代码示例来源:origin: apache/kafka
/**
* Extract a claim in its raw form
*
* @param claimName
* the mandatory JWT claim name
* @return the raw claim value, if it exists, otherwise null
*/
public Object rawClaim(String claimName) {
return claims().get(Objects.requireNonNull(claimName));
}
代码示例来源:origin: apache/kafka
/**
* Request an update for the partition metadata iff the given leader epoch is at newer than the last seen leader epoch
*/
public synchronized boolean updateLastSeenEpochIfNewer(TopicPartition topicPartition, int leaderEpoch) {
Objects.requireNonNull(topicPartition, "TopicPartition cannot be null");
return updateLastSeenEpoch(topicPartition, leaderEpoch, oldEpoch -> leaderEpoch > oldEpoch, true);
}
代码示例来源:origin: apache/kafka
@SuppressWarnings("unchecked")
@Override
public void configure(Map<String, ?> configs, String saslMechanism, List<AppConfigurationEntry> jaasConfigEntries) {
if (!OAuthBearerLoginModule.OAUTHBEARER_MECHANISM.equals(saslMechanism))
throw new IllegalArgumentException(String.format("Unexpected SASL mechanism: %s", saslMechanism));
if (Objects.requireNonNull(jaasConfigEntries).size() != 1 || jaasConfigEntries.get(0) == null)
throw new IllegalArgumentException(
String.format("Must supply exactly 1 non-null JAAS mechanism configuration (size was %d)",
jaasConfigEntries.size()));
this.moduleOptions = Collections.unmodifiableMap((Map<String, String>) jaasConfigEntries.get(0).getOptions());
configured = true;
}
代码示例来源:origin: JakeWharton/butterknife
@Override public void visitSelect(JCTree.JCFieldAccess jcFieldAccess) {
Symbol symbol = jcFieldAccess.sym;
if (symbol.getEnclosingElement() != null
&& symbol.getEnclosingElement().getEnclosingElement() != null
&& symbol.getEnclosingElement().getEnclosingElement().enclClass() != null) {
try {
int value = (Integer) requireNonNull(((Symbol.VarSymbol) symbol).getConstantValue());
resourceIds.put(value, new Id(value, symbol));
} catch (Exception ignored) { }
}
}
内容来源于网络,如有侵权,请联系作者删除!