Here are the examples of the java api org.apache.commons.lang3.Validate.notNull() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1485 Examples
19
Source : Metrics2.java
with GNU General Public License v3.0
from YiC200333
with GNU General Public License v3.0
from YiC200333
public void addCustomChart(CustomChart chart) {
Validate.notNull(chart, "Chart cannot be null", new Object[0]);
this.charts.add(chart);
}
19
Source : ReflectionUtil.java
with Apache License 2.0
from xuwujing
with Apache License 2.0
from xuwujing
public static Clreplaced<?> getUserClreplaced(Object instance) {
Validate.notNull(instance, "Instance must not be null");
Clreplaced<?> clazz = instance.getClreplaced();
if ((clazz != null) && clazz.getName().contains(CGLIB_CLreplaced_SEPARATOR)) {
Clreplaced<?> superClreplaced = clazz.getSuperclreplaced();
if ((superClreplaced != null) && !Object.clreplaced.equals(superClreplaced)) {
return superClreplaced;
}
}
return clazz;
}
19
Source : ClassUtil.java
with Apache License 2.0
from xuminwlt
with Apache License 2.0
from xuminwlt
/**
* 获取CGLib处理过后的实体的原Clreplaced.
*/
public static Clreplaced<?> unwrapCglib(Object instance) {
Validate.notNull(instance, "Instance must not be null");
Clreplaced<?> clazz = instance.getClreplaced();
if ((clazz != null) && clazz.getName().contains(CGLIB_CLreplaced_SEPARATOR)) {
Clreplaced<?> superClreplaced = clazz.getSuperclreplaced();
if ((superClreplaced != null) && !Object.clreplaced.equals(superClreplaced)) {
return superClreplaced;
}
}
return clazz;
}
19
Source : FileUtil.java
with Apache License 2.0
from xuminwlt
with Apache License 2.0
from xuminwlt
/**
* 确保目录存在, 如不存在则创建
*/
public static void makesureDirExists(File file) throws IOException {
Validate.notNull(file);
if (file.exists()) {
if (!file.isDirectory()) {
throw new IOException("There is a file exists " + file);
}
} else {
file.mkdirs();
}
}
19
Source : FileUtil.java
with Apache License 2.0
from xuminwlt
with Apache License 2.0
from xuminwlt
// /// 文件操作 /////
/**
* 复制文件或目录
*
* @param from 如果为null,或者是不存在的文件或目录,抛出异常.
* @param to 如果为null,或者from是目录而to是已存在文件,或相反
*/
public static void copy(@NotNull File from, @NotNull File to) throws IOException {
Validate.notNull(from);
Validate.notNull(to);
if (from.isDirectory()) {
copyDir(from, to);
} else {
copyFile(from, to);
}
}
19
Source : EventListenerSupport.java
with GNU General Public License v2.0
from xgdsmileboy
with GNU General Public License v2.0
from xgdsmileboy
// **********************************************************************************************************************
// Other Methods
// **********************************************************************************************************************
/**
* Registers an event listener.
*
* @param listener the event listener (may not be <code>null</code>).
*
* @throws NullPointerException if <code>listener</code> is
* <code>null</code>.
*/
public void addListener(final L listener) {
Validate.notNull(listener, "Listener object cannot be null.");
listeners.add(listener);
}
19
Source : EventListenerSupport.java
with GNU General Public License v2.0
from xgdsmileboy
with GNU General Public License v2.0
from xgdsmileboy
/**
* Unregisters an event listener.
*
* @param listener the event listener (may not be <code>null</code>).
*
* @throws NullPointerException if <code>listener</code> is
* <code>null</code>.
*/
public void removeListener(final L listener) {
Validate.notNull(listener, "Listener object cannot be null.");
listeners.remove(listener);
}
19
Source : AbstractChannel.java
with Apache License 2.0
from WeBankFinTech
with Apache License 2.0
from WeBankFinTech
public void push(final T t) {
Validate.notNull(t, "push domain cannot be empty in channel");
this.doPush(t);
this.statPush(1L, t.getByteSize());
}
19
Source : AbstractChannel.java
with Apache License 2.0
from WeBankFinTech
with Apache License 2.0
from WeBankFinTech
public void pushTerminate(final T t) {
Validate.notNull(t, "push domain cannot be empty in channel");
this.doPush(t);
}
19
Source : Node3D.java
with Apache License 2.0
from UnknownDomainGames
with Apache License 2.0
from UnknownDomainGames
public void addChild(Node3D node) {
Validate.notNull(node);
getChildren().add(node);
node.setParent(this);
}
19
Source : StreamUtils.java
with Apache License 2.0
from thubbo
with Apache License 2.0
from thubbo
public static int drain(InputStream in) throws IOException {
Validate.notNull(in, "No InputStream specified");
byte[] buffer = new byte[4096];
int bytesRead = 1;
int byteCount;
for (byteCount = 0; (bytesRead = in.read(buffer)) != -1; byteCount += bytesRead) {
;
}
return byteCount;
}
19
Source : StreamUtils.java
with Apache License 2.0
from thubbo
with Apache License 2.0
from thubbo
public static int copy(InputStream in, OutputStream out) throws IOException {
Validate.notNull(in, "No InputStream specified");
Validate.notNull(out, "No OutputStream specified");
int byteCount = 0;
byte[] buffer = new byte[4096];
int bytesRead;
for (boolean var4 = true; (bytesRead = in.read(buffer)) != -1; byteCount += bytesRead) {
out.write(buffer, 0, bytesRead);
}
out.flush();
return byteCount;
}
19
Source : StreamUtils.java
with Apache License 2.0
from thubbo
with Apache License 2.0
from thubbo
public static InputStream nonClosing(InputStream in) {
Validate.notNull(in, "No InputStream specified");
return new StreamUtils.NonClosingInputStream(in);
}
19
Source : StreamUtils.java
with Apache License 2.0
from thubbo
with Apache License 2.0
from thubbo
public static void copy(byte[] in, OutputStream out) throws IOException {
Validate.notNull(in, "No input byte array specified");
Validate.notNull(out, "No OutputStream specified");
out.write(in);
}
19
Source : StreamUtils.java
with Apache License 2.0
from thubbo
with Apache License 2.0
from thubbo
public static OutputStream nonClosing(OutputStream out) {
Validate.notNull(out, "No OutputStream specified");
return new StreamUtils.NonClosingOutputStream(out);
}
19
Source : StreamUtils.java
with Apache License 2.0
from thubbo
with Apache License 2.0
from thubbo
public static long copyRange(InputStream in, OutputStream out, long start, long end) throws IOException {
Validate.notNull(in, "No InputStream specified");
Validate.notNull(out, "No OutputStream specified");
long skipped = in.skip(start);
if (skipped < start) {
throw new IOException("Skipped only " + skipped + " bytes out of " + start + " required");
} else {
long bytesToCopy = end - start + 1L;
byte[] buffer = new byte[4096];
while (bytesToCopy > 0L) {
int bytesRead = in.read(buffer);
if (bytesRead == -1) {
break;
}
if ((long) bytesRead <= bytesToCopy) {
out.write(buffer, 0, bytesRead);
bytesToCopy -= (long) bytesRead;
} else {
out.write(buffer, 0, (int) bytesToCopy);
bytesToCopy = 0L;
}
}
return end - start + 1L - bytesToCopy;
}
}
19
Source : RegistrySimple.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* Register an object on this registry.
*/
public void putObject(K key, V value) {
Validate.notNull(key);
Validate.notNull(value);
this.values = null;
if (this.registryObjects.containsKey(key)) {
LOGGER.debug("Adding duplicate key \'{}\' to registry", new Object[] { key });
}
this.registryObjects.put(key, value);
}
19
Source : RegistryNamespacedDefaultedByKey.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
/**
* validates that this registry's key is non-null
*/
public void validateKey() {
Validate.notNull(this.defaultValue, "Missing default of DefaultedMappedRegistry: " + this.defaultValueKey, new Object[0]);
}
19
Source : NonNullList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public E set(int p_set_1_, E p_set_2_) {
Validate.notNull(p_set_2_);
return this.field_191198_a.set(p_set_1_, p_set_2_);
}
19
Source : NonNullList.java
with GNU General Public License v3.0
from sudofox
with GNU General Public License v3.0
from sudofox
public void add(int p_add_1_, E p_add_2_) {
Validate.notNull(p_add_2_);
this.field_191198_a.add(p_add_1_, p_add_2_);
}
19
Source : AbstractReportServiceBean.java
with GNU Affero General Public License v3.0
from StadtBern
with GNU Affero General Public License v3.0
from StadtBern
protected void validateDateParams(Object datumVon, Object datumBis) {
Validate.notNull(datumVon, VALIDIERUNG_DATUM_VON);
Validate.notNull(datumBis, VALIDIERUNG_DATUM_BIS);
}
19
Source : CommandServicePostProcessor.java
with Apache License 2.0
from sleroy
with Apache License 2.0
from sleroy
/**
* Gets the handled command type.
*
* @param bean the bean
*
* @param beanName
* @return the handled command type
*/
private Clreplaced<?> getCommandServiceType(final Object bean, final String beanName) {
Validate.notNull(bean);
Clreplaced<?> userClreplaced = getUserClreplaced(bean);
final Type[] genericInterfaces = userClreplaced.getGenericInterfaces();
final ParameterizedType type = retrieveParameterizedInterfaceType(genericInterfaces, CommandServiceSpec.clreplaced);
if (type == null) {
return this.commandServiceProvider.guessLambdaType(bean, beanName);
}
return (Clreplaced<?>) type.getActualTypeArguments()[0];
}
19
Source : Reflections.java
with MIT License
from Senssic
with MIT License
from Senssic
public static Clreplaced<?> getUserClreplaced(Object instance) {
Validate.notNull(instance, "Instance must not be null");
Clreplaced clazz = instance.getClreplaced();
if ((clazz != null) && clazz.getName().contains(CGLIB_CLreplaced_SEPARATOR)) {
Clreplaced<?> superClreplaced = clazz.getSuperclreplaced();
if ((superClreplaced != null) && !Object.clreplaced.equals(superClreplaced)) {
return superClreplaced;
}
}
return clazz;
}
19
Source : FileAction.java
with GNU General Public License v3.0
from sdadas
with GNU General Public License v3.0
from sdadas
public static Builder builder(Consumer<List<FileItem>> runnable) {
Validate.notNull(runnable);
return new Builder(runnable);
}
19
Source : FileAction.java
with GNU General Public License v3.0
from sdadas
with GNU General Public License v3.0
from sdadas
public static Builder builder(BiConsumer<List<FileItem>, Progress> runnable) {
Validate.notNull(runnable);
return new Builder(runnable);
}
19
Source : ReflectionUtils.java
with Apache License 2.0
from rheem-ecosystem
with Apache License 2.0
from rheem-ecosystem
/**
* Identifies and returns the JAR file declaring the {@link Clreplaced} of the given {@code object} or {@code null} if
* no such file could be determined.
*/
public static String getDeclaringJar(Object object) {
Validate.notNull(object);
return getDeclaringJar(object.getClreplaced());
}
19
Source : BlockPortalShape.java
with Apache License 2.0
from qouteall
with Apache License 2.0
from qouteall
public void calcAnchor() {
anchor = area.stream().min(Comparator.<BlockPos>comparingInt(Vector3i::getX).<BlockPos>thenComparingInt(Vector3i::getY).<BlockPos>thenComparingInt(Vector3i::getZ)).get();
Validate.notNull(anchor);
}
19
Source : BlockPortalShape.java
with Apache License 2.0
from qouteall
with Apache License 2.0
from qouteall
public void calcAnchor() {
anchor = area.stream().min(Comparator.<BlockPos>comparingInt(Vec3i::getX).<BlockPos>thenComparingInt(Vec3i::getY).<BlockPos>thenComparingInt(Vec3i::getZ)).get();
Validate.notNull(anchor);
}
19
Source : AbstractMX.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Writes the message doreplacedent content into a file in XML format, encoding content in UTF-8 (headers not included).
*
* @param stream a non null stream to write
* @throws IOException if the stream cannot be written
* @since 7.7
*/
public void write(final OutputStream stream) throws IOException {
Validate.notNull(stream, "the stream to write cannot be null");
stream.write(message().getBytes("UTF-8"));
}
19
Source : SwiftMessageComparator.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Compare the two given messages. Message parameters cannot be null.
*
* <p>This implementation calls the specific comparator methods for
* blocks 1 and 2, and the generic tag list block comparator for other
* blocks
*
* @see #compareB1(SwiftBlock1, SwiftBlock1)
* @see #compareB2(SwiftBlock2, SwiftBlock2)
* @see #compareTagListBlock(SwiftTagListBlock, SwiftTagListBlock)
*/
public int compare(final SwiftMessage left, final SwiftMessage right) {
Validate.notNull(left);
Validate.notNull(right);
final boolean b1 = compareB1(left.getBlock1(), right.getBlock1());
final boolean b2 = compareB2(left.getBlock2(), right.getBlock2());
final boolean b3 = compareTagListBlock(left.getBlock3(), right.getBlock3());
final boolean b4 = compareTagListBlock(left.getBlock4(), right.getBlock4());
final boolean b5 = this.ignoreTrailer || compareTagListBlock(left.getBlock5(), right.getBlock5());
log.finest("b1=" + b1 + ", b2=" + b2 + ", b3=" + b3 + ", b4=" + b4 + ", b5=" + b5);
return (b1 && b2 && b3 && b4 && b5) ? 0 : 1;
}
19
Source : UnparsedTextList.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* removes an unparsed text
* @param text the text value to remove (uses equals)
* @throws IllegalArgumentException if parameter text is null
*/
public void removeText(final String text) {
// sanity check
Validate.notNull(text, "parameter 'text' cannot be null");
// remove the text (if it exists)
final int pos = this.texts.indexOf(text);
if (pos != -1) {
this.texts.remove(pos);
}
}
19
Source : UnparsedTextList.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* get an unparsed text
* @param index the unparsed text number
* @return the requested text
* @throws IllegalArgumentException if parameter index is null
* @throws IndexOutOfBoundsException if parameter index is out of bounds
*/
public String getText(final Integer index) {
// sanity check
Validate.notNull(index, WRITER_MESSAGE);
return ((String) this.texts.get(index.intValue()));
}
19
Source : UnparsedTextList.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* adds a new unparsed text
* @param text the unparsed text to append
* @throws IllegalArgumentException if parameter text is null
*/
public void addText(final String text) {
// sanity check
Validate.notNull(text, "parameter 'text' cannot be null");
// append the text
this.texts.add(text);
}
19
Source : UnparsedTextList.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* removes an unparsed text
* @param index the index of the text to remove
* @throws IllegalArgumentException if parameter index is null
* @throws IndexOutOfBoundsException if parameter index is out of bounds
*/
public void removeText(final Integer index) {
// sanity check
Validate.notNull(index, WRITER_MESSAGE);
// remove the text
this.texts.remove(index.intValue());
}
19
Source : UnparsedTextList.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* get an unparsed text as a parsed swift message
* @param index the unparsed text number
* @return the text at position index parsed into a SwiftMessage object
* @throws IllegalArgumentException if parameter index is null
* @throws IndexOutOfBoundsException if parameter index is out of bounds
*/
public SwiftMessage getTextAsMessage(final Integer index) {
// sanity check
Validate.notNull(index, WRITER_MESSAGE);
// create a conversion clreplaced
final ConversionService cService = new ConversionService();
return (cService.getMessageFromFIN((String) this.texts.get(index.intValue())));
}
19
Source : Tag.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Set the tag name
* @param name the name of the tag to be set
* @throws IllegalArgumentException if parameter name is null
*/
public void setName(String name) {
// sanity check
Validate.notNull(name, "parameter 'name' cannot be null");
this.name = name;
}
19
Source : MtSwiftMessage.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* The SwiftMessage is serialized to its FIN raw format to set the internal raw message attribute.
* And the header attributes are set with data from the parameter SwiftMessage.
* Notice that the SwiftMessage is not stored as internal attribute.
*/
public void updateFromModel(final SwiftMessage model) {
Validate.notNull(model, "the model message cannot be null");
final String fin = (new ConversionService()).getFIN(model);
Validate.notNull(fin, "the raw message could not be created from the SwiftMessage parameter");
setMessage(fin);
updateAttributes(model);
}
19
Source : MtSwiftMessage.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Updates the the attributes with the raw message and its metadata from the given raw (FIN) message content.
*
* @param fin the new message content
* @see #updateFromMessage()
*/
public void updateFromFIN(final String fin) {
Validate.notNull(fin, "the raw message parameter cannot be null");
setMessage(fin);
setFileFormat(FileFormat.FIN);
updateFromMessage();
}
19
Source : SequenceUtils.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
public static MT564.SequenceB1 resolveMT564GetSequenceB1_sru2020(final MT564 mt) {
Validate.notNull(mt);
final MT564.SequenceB1 result = MT564.SequenceB1.newInstance();
// we just get the first subblock
result.clear().append(mt.getSequenceB().getSubBlock(MT564.SequenceB1.START_END_16RS));
return result;
}
19
Source : AbstractMT.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Add all tags to the end of the block4
* @param tags a list of tags to add
* @return this same object for chained calls
* @since 7.6
*/
public AbstractMT append(final Tag... tags) {
Validate.notNull(tags);
if (tags.length > 0) {
for (final Tag t : tags) {
b4().append(t);
}
}
return this;
}
19
Source : AbstractMT.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Add all tags from block to the end of the block4
* @param block a block to append
* @return this same object for chained calls
* @since 7.6
*/
public AbstractMT append(final SwiftTagListBlock block) {
Validate.notNull(block);
if (!block.isEmpty())
b4().addTags(block.getTags());
return this;
}
19
Source : AbstractMT.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Writes the message into a given output stream with its message content in the FIN format,
* encoding content in UTF-8.
*
* @param stream a non null stream to write
* @throws IOException if the stream cannot be written
* @since 7.7
*/
public void write(OutputStream stream) throws IOException {
Validate.notNull(stream, "the stream to write cannot be null");
Validate.notNull(this.m, "the message to write cannot be null");
stream.write(message().getBytes("UTF-8"));
}
19
Source : AbstractMT.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Returns the message content in XML format.<br>
* The XML created is the internal format defined and used by Prowide Core.<br>
* Notice: it is neither a standard nor the MX version of this MT.
*
* @since 7.7
*/
public String xml() {
Validate.notNull(this.m, "the message cannot be null");
return this.m.toXml();
}
19
Source : AmountResolver.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
/**
* Gets the amount of the given field by reading it's components pattern.
* The first index of 'N', number, is returned as amount.
*
* <em>See the returns notes</em>
*
* @param f the field where to extract the amount, must not be null
*
* @return a BigDecimal with the number found in the first numeric component or null if there is
* no numeric component in the field. It may also return null if Field.getComponent(index,Number.clreplaced) fails
* for that component
*
* @see Field#getComponentAs(int, Clreplaced)
* @since 7.8
*/
public static BigDecimal amount(final Field f) {
Validate.notNull(f);
final int i = StringUtils.indexOf(f.componentsPattern(), 'N');
if (i >= 0) {
return amount(f, i + 1);
}
return null;
}
19
Source : RJEWriter.java
with Apache License 2.0
from prowide
with Apache License 2.0
from prowide
private void _write(final String msg, final Writer writer) throws IOException {
Validate.notNull(writer, WRITER_MESSAGE);
Validate.notNull(msg, MESSAGE_TO_WRITE_CONDITION);
if (count > 0) {
writer.write(FINWriterVisitor.SWIFT_EOL);
writer.write(splitChar);
writer.write(FINWriterVisitor.SWIFT_EOL);
}
writer.write(msg);
count++;
}
19
Source : SortOption.java
with Apache License 2.0
from picturesafe
with Apache License 2.0
from picturesafe
/**
* Sets the mode for sorting by array or multi-valued fields.
* @param arrayMode Mode for sorting by array or multi-valued fields
* @return SortOption
*/
public SortOption arrayMode(ArrayMode arrayMode) {
Validate.notNull(arrayMode, "Parameter 'arrayMode' may not be null!");
this.arrayMode = arrayMode;
return this;
}
19
Source : OperationExpression.java
with Apache License 2.0
from picturesafe
with Apache License 2.0
from picturesafe
private static void enqueueOperands(Queue<Expression> queue, Collection<Expression> operands) {
Validate.notNull(queue, "The argument 'queue' must not be null!");
if (operands != null) {
for (Expression operand : operands) {
if (!(operand instanceof EmptyExpression)) {
queue.add(operand);
}
}
}
}
19
Source : DocumentBuilder.java
with Apache License 2.0
from picturesafe
with Apache License 2.0
from picturesafe
public static DoreplacedentBuilder id(Object id, IdFormat idFormat) {
Validate.notNull(id, "Parameter 'id' may not be null!");
Validate.notNull(id, "Parameter 'idFormat' may not be null!");
return new DoreplacedentBuilder(idFormat.format(id));
}
19
Source : Crawler.java
with Apache License 2.0
from peterbencze
with Apache License 2.0
from peterbencze
/**
* Feeds a crawl request to the crawler. The crawler should be running, otherwise the request
* has to be added as a crawl seed instead.
*
* @param request the crawl request
*/
protected final void crawl(final CrawlRequest request) {
Validate.validState(!isStopped.get(), "The crawler is not started. Maybe you meant to add this request as a crawl seed?");
Validate.notNull(request, "The request parameter cannot be null.");
crawlFrontier.feedRequest(request, false);
}
19
Source : Crawler.java
with Apache License 2.0
from peterbencze
with Apache License 2.0
from peterbencze
/**
* Registers an operation which is invoked when the specific event occurs and the provided
* pattern matches the request URL.
*
* @param <T> the type of the input to the operation
* @param eventClreplaced the runtime clreplaced of the event for which the callback should be invoked
* @param callback the pattern matching callback to invoke
*/
protected final <T extends CrawlEvent> void registerCustomCallback(final Clreplaced<T> eventClreplaced, final PatternMatchingCallback<T> callback) {
Validate.notNull(eventClreplaced, "The eventClreplaced parameter cannot be null.");
Validate.notNull(callback, "The callback parameter cannot be null.");
callbackManager.addCustomCallback(eventClreplaced, callback);
}
See More Examples