本文整理了Java中se.jguru.nazgul.core.algorithms.api.Validate
类的一些代码示例,展示了Validate
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate
类的具体详情如下:
包路径:se.jguru.nazgul.core.algorithms.api.Validate
类名称:Validate
[英]Simple argument validator, inspired by the commons-lang.
[中]简单的参数验证器,灵感来自commons-lang。
代码示例来源:origin: se.jguru.nazgul.core.reflection.api/nazgul-core-reflection-api
/**
* Assigns the type of this DependencyData instance.
*
* @param type The type of this DependencyData. Cannot be null or empty.
*/
public void setType(final String type) {
Validate.notEmpty(type, "type");
this.type = type;
}
代码示例来源:origin: se.jguru.nazgul.core.xmlbinding.spi.jaxb/nazgul-core-xmlbinding-spi-jaxb
/**
* Compound constructor using the provided NamespacePrefixResolver instance to delegate all
* possible calls dealing with XML namespace URI to prefix mappings.
*
* @param namespacePrefixResolver The NamespacePrefixResolver delegate to which all NamespacePrefixResolver
* calls are delegated internally.
*/
public JaxbNamespacePrefixResolver(@NotNull final NamespacePrefixResolver namespacePrefixResolver) {
Validate.notNull(namespacePrefixResolver, "namespacePrefixResolver");
this.namespacePrefixResolver = namespacePrefixResolver;
}
代码示例来源:origin: se.jguru.nazgul.core.xmlbinding.spi.jaxb/nazgul-core-xmlbinding-spi-jaxb
/**
* Adds a mapping between the supplied namespace and the given xmlSchemaSnippet.
*
* @param namespace The non-null namespace which should be mapped.
* @param xmlSchemaSnippet The non-empty xml Schema snippet which should be mapped.
*/
public void addNamespace2SchemaEntry(@NotNull final String namespace,
@NotNull @Size(min = 1) final String xmlSchemaSnippet) {
// Check sanity
Validate.notNull(namespace, "namespace");
Validate.notEmpty(xmlSchemaSnippet, "xmlSchemaSnippet");
Validate.isTrue(!namespace2SchemaSnippetMap.containsKey(namespace),
"Cannot overwrite namespace [" + namespace + "]. Known namespaces: "
+ namespace2SchemaSnippetMap.keySet()
.stream()
.reduce((l, r) -> l + ", " + r)
.orElse("<none>"));
// Add the mapping.
namespace2SchemaSnippetMap.put(namespace, xmlSchemaSnippet);
}
代码示例来源:origin: se.jguru.nazgul.core.algorithms.api/nazgul-core-algorithms-api
/**
* Validates that the supplied array is not null, and throws a NullPointerException otherwise.
* If the supplied array is empty, then an IllegalArgumentException is thrown.
*
* @param anArray The Array to validate for empty-ness.
* @param argumentName The argument name of the object to validate.
* If supplied (i.e. non-{@code null}), this value is used in composing
* a better exception message.
* @param <T> The type elements within the Array.
* @return The Array submitted.
* @throws IllegalArgumentException if the submitted Array is empty.
* @throws NullPointerException if the supplied Array is null.
*/
public static <T> T[] notEmpty(final T[] anArray, final String argumentName) {
// Check sanity
notNull(anArray, argumentName);
if (anArray.length == 0) {
throw new IllegalArgumentException(getMessage("empty", argumentName));
}
// All Done
return anArray;
}
代码示例来源:origin: se.jguru.nazgul.test.persistence/nazgul-core-persistence-test
/**
* Creates a new PersistenceRedirectionClassLoader delegating all class loads to the
* provided parent, except loading of "META-INF/persistence.xml", which is redirected
* to the provided persistenceXmlRedirection.
*
* @param parent The normal classloader, used for all resource loading
* except "META-INF/persistence.xml"
* @param persistenceXmlRedirection The location to use when loading "META-INF/persistence.xml".
* An example would be "META-INF/dbprimer_persistence.xml"
*/
public PersistenceRedirectionClassLoader(@NotNull final ClassLoader parent,
@NotNull @Size(min = 1) final String persistenceXmlRedirection) {
// Check sanity
Validate.notNull(parent, "parent");
Validate.notEmpty(persistenceXmlRedirection,"persistenceXmlRedirection");
// Assign internal state
this.parent = parent;
this.persistenceXmlRedirection = persistenceXmlRedirection;
}
代码示例来源:origin: se.jguru.nazgul.core.xmlbinding.spi.jaxb/nazgul-core-xmlbinding-spi-jaxb
/**
* {@inheritDoc}
*/
@Override
public <OriginalType, TransportType> Class<OriginalType> getOriginalType(
@NotNull final Class<TransportType> transportType) throws IllegalArgumentException {
// Check sanity
Validate.notNull(transportType, "transportType");
Validate.isTrue(transportType != JaxbAnnotatedNull.class,
"Cannot acquire OriginalType for JaxbAnnotatedNull argument.");
// If the transportType is neither a Primitive nor annotated with XmlType ... complain.
boolean incorrectType = !transportType.isPrimitive()
&& !SELF_CONVERTIBLE.contains(transportType)
&& !transportType.isAnnotationPresent(XmlType.class);
if (incorrectType) {
throw new IllegalArgumentException("Supplied transportType [" + transportType.getName()
+ "] is not annotated with XmlType.");
}
// Find something in our registry?
for (Class<?> current : registry.getPossibleConversions(transportType)) {
// Is this a non-transport type?
if (!current.isAnnotationPresent(XmlType.class)) {
return (Class<OriginalType>) current;
}
}
// None found.
return null;
}
代码示例来源:origin: se.jguru.nazgul.test.persistence/nazgul-core-persistence-test
private void addParameter(final SortedMap<Integer, String> target, final int index, final String value) {
if (index >= 0) {
// Check sanity
Validate.isTrue(!target.containsKey(index),
"Key [" + index + "] already present in target map [" + target + "]");
// Add the value.
target.put(index, value);
}
}
}
代码示例来源:origin: se.jguru.nazgul.core.algorithms.api/nazgul-core-algorithms-api
/**
* Validates that the supplied object is not null, and throws a NullPointerException otherwise.
*
* @param object The object to validate for {@code null}-ness.
* @param argumentName The argument name of the object to validate. If supplied (i.e. non-{@code null}),
* this value is used in composing a better exception message.
* @return The supplied object - if it is was not null.
* @throws NullPointerException if the supplied object was null.
*/
public static <T> T notNull(final T object, final String argumentName) {
// Check sanity
if (object == null) {
throw new NullPointerException(getMessage("null", argumentName));
}
// All done.
return object;
}
代码示例来源:origin: se.jguru.nazgul.core.algorithms.api/nazgul-core-algorithms-api
Validate.notNull(pointOfOrigin, "pointOfOrigin");
Validate.notEmpty(propertyExpression, "propertyExpression");
代码示例来源:origin: se.jguru.nazgul.core.algorithms.api/nazgul-core-algorithms-api
/**
* Validates that the supplied object is not null, and throws an IllegalArgumentException otherwise.
*
* @param aString The string to validate for emptyness.
* @param argumentName The argument name of the object to validate.
* If supplied (i.e. non-{@code null}), this value is used in composing
* a better exception message.
* @return The non-empty String submitted.
* @throws IllegalArgumentException if the submitted {@code aString} is empty.
* @throws NullPointerException if the supplied {@code aString} is null.
*/
public static String notEmpty(final String aString, final String argumentName) {
// Check sanity
notNull(aString, argumentName);
if (aString.length() == 0) {
throw new IllegalArgumentException(getMessage("empty", argumentName));
}
// All done
return aString;
}
代码示例来源:origin: se.jguru.nazgul.core.reflection.api/nazgul-core-reflection-api
Validate.isTrue(char1 < BASELENGTH, ERROR_PREFIX
+ "Each byte must be < " + BASELENGTH + " [Got: " + char1 + "].");
Validate.isTrue(char2 < BASELENGTH, ERROR_PREFIX
+ "Each byte must be < " + BASELENGTH + " [Got: " + char2 + "].");
代码示例来源:origin: se.jguru.nazgul.core.xmlbinding.spi.jaxb/nazgul-core-xmlbinding-spi-jaxb
/**
* Compound default constructor, wrapping the provided value within itself.
*
* @param value The original type value to wrap.
*/
public AbstractJaxbAnnotatedTransportType(@NotNull final T value) {
this();
// Check sanity
Validate.notNull(value, "value");
// Assign internal state
this.value = value;
}
代码示例来源:origin: se.jguru.nazgul.core.cache.api/nazgul-core-cache-api
/**
* Creates a new AbstractTransactedAction with the provided message
* to be logged on rollback / transaction failure.
*
* @param rollbackErrorMessage An exception message logged if the TransactedAction failed.
*/
protected AbstractTransactedAction(@NotNull final String rollbackErrorMessage) {
this.rollbackErrorMessage = Validate.notEmpty(rollbackErrorMessage, "rollbackErrorMessage");
}
代码示例来源:origin: se.jguru.nazgul.core.algorithms.api/nazgul-core-algorithms-api
/**
* Validates that the supplied object is not null, and throws an IllegalArgumentException otherwise.
*
* @param aMap The Map to validate for emptyness.
* @param argumentName The argument name of the object to validate.
* If supplied (i.e. non-{@code null}), this value is used in composing
* a better exception message.
* @param <K> the type of keys found within the Map.
* @param <V> the type of values found within the Map.
* @param <M> the exact type of Map submitted for emptyness check.
* @return The Collection submitted.
* @throws IllegalArgumentException if the submitted Map is empty.
* @throws NullPointerException if the supplied Map is null.
*/
public static <K, V, M extends Map<K, V>> M notEmpty(final M aMap, final String argumentName) {
// Check sanity
notNull(aMap, argumentName);
if (aMap.isEmpty()) {
throw new IllegalArgumentException(getMessage("empty", argumentName));
}
// All done
return aMap;
}
代码示例来源:origin: se.jguru.nazgul.core.cache.api/nazgul-core-cache-api
/**
* Creates a read-only iterator backed by the provided delegate.
*
* @param delegate The iterator made readonly by this ReadOnlyIterator wrapper.
*/
public ReadOnlyIterator(@NotNull final Iterator<E> delegate) {
// Check sanity
Validate.notNull(delegate, "delegate");
// Assign internal state
this.delegate = delegate;
}
代码示例来源:origin: se.jguru.nazgul.core.algorithms.api/nazgul-core-algorithms-api
/**
* Creates a new PatternMatchFilter using the provided regexp pattern to match candidates.
*
* @param pattern A non-empty pattern to be used for regexp pattern in a matcher.
*/
public PatternMatchFilter(final String pattern) {
// Check sanity
Validate.notEmpty(pattern, "pattern");
regexpPattern = Pattern.compile(pattern);
}
代码示例来源:origin: se.jguru.nazgul.core.algorithms.api/nazgul-core-algorithms-api
/**
* Validates that the supplied object is not null, and throws a NullPointerException otherwise.
* If the supplied collection is empty, then an IllegalArgumentException is thrown.
*
* @param aCollection The Collection to validate for emptyness.
* @param argumentName The argument name of the object to validate.
* If supplied (i.e. non-{@code null}), this value is used in composing
* a better exception message.
* @param <C> The type of Collection to validate for emptyness.
* @param <T> The type elements within the Collection.
* @return The Collection submitted.
* @throws IllegalArgumentException if the submitted Collection is empty.
* @throws NullPointerException if the supplied Collection is null.
*/
public static <T, C extends Collection<T>> C notEmpty(final C aCollection, final String argumentName) {
// Check sanity
notNull(aCollection, argumentName);
if (aCollection.isEmpty()) {
throw new IllegalArgumentException(getMessage("empty", argumentName));
}
// All done
return aCollection;
}
代码示例来源:origin: se.jguru.nazgul.core.xmlbinding.spi.jaxb/nazgul-core-xmlbinding-spi-jaxb
/**
* Assigns the singleton TypeConverterRegistry instance used
* by all EntityWrapper instances.
*
* @param registry The TypeConverterRegistry instance to use.
* @throws IllegalArgumentException if the registry parameter was null.
*/
public static void setTransportTypeConverterRegistry(@NotNull final JaxbConverterRegistry registry)
throws IllegalArgumentException {
Validate.notNull(registry, "registry");
typeConverterRegistry = registry;
}
}
代码示例来源:origin: se.jguru.nazgul.core.clustering.api/nazgul-core-clustering-api
/**
* Compound constructor creating a ConstantIdGenerator which always returns the provided id String.
*
* @param id The constant id.
*/
public ConstantIdGenerator(@NotNull final String id) {
// Check sanity
Validate.notEmpty(id, "id");
// Assign internal state
this.id = id;
}
代码示例来源:origin: se.jguru.nazgul.core.xmlbinding.spi.jaxb/nazgul-core-xmlbinding-spi-jaxb
/**
* Compound constructor, creating a new SortedClassNameSetKey from the provided classNames Set.
*
* @param classNames A set of class names.
*/
public SortedClassNameSetKey(@NotNull final SortedSet<String> classNames) {
Validate.notNull(classNames, "classNames");
this.classNames = classNames;
syntheticKey = classNames.toString();
}
内容来源于网络,如有侵权,请联系作者删除!