本文整理了Java中org.apache.commons.lang3.Validate.notNull()
方法的一些代码示例,展示了Validate.notNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate.notNull()
方法的具体详情如下:
包路径:org.apache.commons.lang3.Validate
类名称:Validate
方法名:notNull
[英]Validate that the specified argument is not null; otherwise throwing an exception.
Validate.notNull(myObject, "The object must not be null");
The message of the exception is "The validated object is null".
[中]验证指定的参数不为null;否则将引发异常。
Validate.notNull(myObject, "The object must not be null");
异常的消息是“已验证的对象为空”。
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Validate {@code enumClass}.
* @param <E> the type of the enumeration
* @param enumClass to check
* @return {@code enumClass}
* @throws NullPointerException if {@code enumClass} is {@code null}
* @throws IllegalArgumentException if {@code enumClass} is not an enum class
* @since 3.2
*/
private static <E extends Enum<E>> Class<E> asEnum(final Class<E> enumClass) {
Validate.notNull(enumClass, ENUM_CLASS_MUST_BE_DEFINED);
Validate.isTrue(enumClass.isEnum(), S_DOES_NOT_SEEM_TO_BE_AN_ENUM_TYPE, enumClass);
return enumClass;
}
}
代码示例来源:origin: rest-assured/rest-assured
/**
* Add default filters to apply to each request.
*
* @param filter The filter to add
* @param additionalFilters An optional array of additional filters to add
*/
public static void filters(Filter filter, Filter... additionalFilters) {
Validate.notNull(filter, "Filter cannot be null");
RestAssured.filters.add(filter);
if (additionalFilters != null) {
Collections.addAll(RestAssured.filters, additionalFilters);
}
}
代码示例来源:origin: shopizer-ecommerce/shopizer
Validate.notNull(transaction,"Transaction cannot be null");
Validate.notNull((String)transaction.getTransactionDetails().get("TRANSACTIONID"), "Transaction details must contain a TRANSACTIONID");
Validate.notNull(order,"Order must not be null");
Validate.notNull(order.getCurrency(),"Order nust contain Currency object");
configurationMap.put("mode", mode);
configurationMap.put("acct1.UserName", configuration.getIntegrationKeys().get("username"));
configurationMap.put("acct1.Password", configuration.getIntegrationKeys().get("api"));
configurationMap.put("acct1.Signature", configuration.getIntegrationKeys().get("signature"));
代码示例来源:origin: shopizer-ecommerce/shopizer
throws IntegrationException {
Validate.notNull(configuration, "Configuration must not be null");
Validate.notNull(payment, "Payment must not be null");
Validate.notNull(summary, "OrderTotalSummary must not be null");
item.setAmount(amt);
lineItems.add(item);
paymentDetailsList.add(paymentDetails);
configurationMap.put("mode", mode);
configurationMap.put("acct1.UserName", configuration.getIntegrationKeys().get("username"));
configurationMap.put("acct1.Password", configuration.getIntegrationKeys().get("api"));
configurationMap.put("acct1.Signature", configuration.getIntegrationKeys().get("signature"));
代码示例来源:origin: spring-projects/spring-roo
public List<RelationInfoExtended> getRelationInfoFor(final JpaEntityMetadata entityMetadata,
final String path) {
Validate.notNull(entityMetadata, "entity metadata is required");
Validate.notBlank(path, "path is required");
List<RelationInfoExtended> infos = new ArrayList<RelationInfoExtended>();
String[] split = StringUtils.split(path, '.');
RelationInfo info = entityMetadata.getRelationInfos().get(split[0]);
Validate.notNull(info, "%s.%s not found or not a relation field",
entityMetadata.getDestination(), split[0]);
ClassOrInterfaceTypeDetails childCid = getTypeLocationService().getTypeDetails(info.childType);
JpaEntityMetadata childMetadata =
getMetadataService().get(JpaEntityMetadata.createIdentifier(childCid));
infos.add(new RelationInfoExtended(info, entityMetadata, childMetadata));
if (split.length > 1) {
infos
.addAll(getRelationInfoFor(childMetadata, StringUtils.join(split, '.', 1, split.length)));
}
return infos;
}
代码示例来源:origin: spring-projects/spring-roo
/**
* Constructor
*
* @param annotationType the type of annotation for which these are the
* metadata (required)
* @param attributeValues the given annotation's values; can be
* <code>null</code>
*/
DefaultAnnotationMetadata(final JavaType annotationType,
final List<AnnotationAttributeValue<?>> attributeValues) {
Validate.notNull(annotationType, "Annotation type required");
this.annotationType = annotationType;
attributes = new ArrayList<AnnotationAttributeValue<?>>();
attributeMap = new HashMap<JavaSymbolName, AnnotationAttributeValue<?>>();
if (attributeValues != null) {
attributes.addAll(attributeValues);
for (final AnnotationAttributeValue<?> value : attributeValues) {
attributeMap.put(value.getName(), value);
}
}
}
代码示例来源:origin: spring-projects/spring-roo
public void add(final Class<?> clazz) {
Validate.notNull(clazz, "A class to provide conversion services is required");
Validate.isTrue(fields.get(clazz) == null,
"Class '%s' is already registered for completion services", clazz);
final Map<String, Field> ffields = new HashMap<String, Field>();
for (final Field field : clazz.getFields()) {
final int modifier = field.getModifiers();
if (Modifier.isStatic(modifier) && Modifier.isPublic(modifier)) {
ffields.put(field.getName(), field);
}
}
Validate.notEmpty(ffields, "Zero public static fields accessible in '%s'", clazz);
fields.put(clazz, ffields);
}
代码示例来源:origin: jamesagnew/hapi-fhir
public RuntimeResourceDefinition getResourceDefinition(FhirVersionEnum theVersion, String theResourceName) {
Validate.notNull(theVersion, "theVersion can not be null");
validateInitialized();
if (theVersion.equals(myVersion.getVersion())) {
return getResourceDefinition(theResourceName);
}
Map<String, Class<? extends IBaseResource>> nameToType = myVersionToNameToResourceType.get(theVersion);
if (nameToType == null) {
nameToType = new HashMap<>();
Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> existing = new HashMap<>();
ModelScanner.scanVersionPropertyFile(null, nameToType, theVersion, existing);
Map<FhirVersionEnum, Map<String, Class<? extends IBaseResource>>> newVersionToNameToResourceType = new HashMap<>();
newVersionToNameToResourceType.putAll(myVersionToNameToResourceType);
newVersionToNameToResourceType.put(theVersion, nameToType);
myVersionToNameToResourceType = newVersionToNameToResourceType;
}
Class<? extends IBaseResource> resourceType = nameToType.get(theResourceName.toLowerCase());
if (resourceType == null) {
throw new DataFormatException(createUnknownResourceNameError(theResourceName, theVersion));
}
return getResourceDefinition(resourceType);
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Registers an event listener. Will not add a pre-existing listener
* object to the list if <code>allowDuplicate</code> is false.
*
* @param listener the event listener (may not be <code>null</code>).
* @param allowDuplicate the flag for determining if duplicate listener
* objects are allowed to be registered.
*
* @throws NullPointerException if <code>listener</code> is <code>null</code>.
* @since 3.5
*/
public void addListener(final L listener, final boolean allowDuplicate) {
Validate.notNull(listener, "Listener object cannot be null.");
if (allowDuplicate) {
listeners.add(listener);
} else if (!listeners.contains(listener)) {
listeners.add(listener);
}
}
代码示例来源:origin: shopizer-ecommerce/shopizer
Validate.notNull(capturableTransaction,"Transaction cannot be null");
Validate.notNull((String)capturableTransaction.getTransactionDetails().get("TRANSACTIONID"), "Transaction details must contain a TRANSACTIONID");
Validate.notNull(order,"Order must not be null");
Validate.notNull(order.getCurrency(),"Order nust contain Currency object");
configurationMap.put("mode", mode);
configurationMap.put("acct1.UserName", configuration.getIntegrationKeys().get("username"));
configurationMap.put("acct1.Password", configuration.getIntegrationKeys().get("api"));
configurationMap.put("acct1.Signature", configuration.getIntegrationKeys().get("signature"));
代码示例来源:origin: spring-projects/spring-roo
protected void bindMetadataProvider(final MetadataProvider mp) {
synchronized (lock) {
Validate.notNull(mp, "Metadata provider required");
final String mid = mp.getProvidesType();
Validate.isTrue(MetadataIdentificationUtils.isIdentifyingClass(mid),
"Metadata provider '%s' violated interface contract by returning '%s'", mp, mid);
Validate.isTrue(!providerMap.containsKey(mid),
"Metadata provider '%s' already is providing metadata for '%s'", providerMap.get(mid),
mid);
providers.add(mp);
providerMap.put(mid, mp);
}
}
代码示例来源:origin: apache/nifi
public NiFiBolt(final SiteToSiteClientConfig clientConfig, final NiFiDataPacketBuilder builder, final int tickFrequencySeconds) {
Validate.notNull(clientConfig);
Validate.notNull(builder);
Validate.isTrue(tickFrequencySeconds > 0);
this.clientConfig = clientConfig;
this.builder = builder;
this.tickFrequencySeconds = tickFrequencySeconds;
}
代码示例来源:origin: PipelineAI/pipeline
Validate.notNull(type, "type cannot be null");
List<Type> types = new ArrayList<Type>();
TreeTraverser<Type> typeTraverser = new TreeTraverser<Type>() {
types.add(t);
代码示例来源:origin: spring-projects/spring-roo
public void registerMatcher(final String addingClass,
final Matcher<? extends CustomDataAccessor> matcher) {
Validate.notNull(addingClass, "The calling class must be specified");
Validate.notNull(matcher, "The matcher must be specified");
taggerMap.put(addingClass + matcher.getCustomDataKey(), matcher);
}
代码示例来源:origin: apache/geode
/**
* Constructs an instance for controlling a local process.
*
* @param pid process id identifying the process to attach to
*
* @throws IllegalArgumentException if pid is not a positive integer
*/
MBeanProcessController(final MBeanControllerParameters arguments, final int pid) {
notNull(arguments, "Invalid arguments '" + arguments + "' specified");
isTrue(pid > 0, "Invalid pid '" + pid + "' specified");
this.pid = pid;
this.arguments = arguments;
}
代码示例来源:origin: rest-assured/rest-assured
Validate.notNull(firstArgument, "You need to supply at least one argument");
final List<Argument> arguments = new LinkedList<Argument>();
arguments.add(Argument.arg(firstArgument));
if (additionalArguments != null && additionalArguments.length > 0) {
for (Object additionalArgument : additionalArguments) {
arguments.add(Argument.arg(additionalArgument));
代码示例来源:origin: jamesagnew/hapi-fhir
public FhirContext getContext(FhirVersionEnum theVersion) {
Validate.notNull(theVersion, "theVersion must not be null");
synchronized (ourRetrievalContexts) {
FhirContext retVal = ourRetrievalContexts.get(theVersion);
if (retVal == null) {
retVal = new FhirContext(theVersion);
ourRetrievalContexts.put(theVersion, retVal);
}
return retVal;
}
}
代码示例来源:origin: Swagger2Markup/swagger2markup
/**
* Specifies parameter ordering.<br>
* By default parameter ordering == {@link OrderBy#NATURAL}.<br>
* Use {@link #withParameterOrdering(Comparator)} to set a custom ordering.
*
* @param orderBy parameter ordering
* @return this builder
*/
public Swagger2MarkupConfigBuilder withParameterOrdering(OrderBy orderBy) {
Validate.notNull(orderBy, "%s must not be null", "orderBy");
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
config.parameterOrderBy = orderBy;
return this;
}
代码示例来源:origin: shopizer-ecommerce/shopizer
Validate.notNull(delivery, "Delivery cannot be null");
Validate.notNull(delivery.getCountry(), "Delivery.country cannot be null");
Validate.notNull(packages, "packages cannot be null");
Validate.notEmpty(packages, "packages cannot be empty");
shippingOption.setOptionId(MODULE_CODE);
options.add(shippingOption);
代码示例来源:origin: spring-projects/spring-roo
private void processTypesWithTag(final Object tag, final LocatedTypeCallback callback) {
Validate.notNull(tag, "Tag required");
Validate.notNull(callback, "Callback required");
// If the cache doesn't yet contain the tag it should be added
if (!tagToMidMap.containsKey(tag)) {
tagToMidMap.put(tag, new HashSet<String>());
}
// Before processing the call any changes to the project should be
// processed and the cache updated accordingly
updateTypeCache();
for (final String locatedMid : tagToMidMap.get(tag)) {
final ClassOrInterfaceTypeDetails located = getTypeCache().getTypeDetails(locatedMid);
callback.process(located);
}
}
内容来源于网络,如有侵权,请联系作者删除!