Java Code Examples for org.apache.commons.lang3.Validate#notNull()

The following examples show how to use org.apache.commons.lang3.Validate#notNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Commit.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
public Commit(String commit, String tree, CommitAction action, List<String> parent,
              String author, String authorEmail, Date date,
              String committer, String committerEmail, Date committerDate,
              String description) {

	Validate.notBlank(commit, "commit should not be null or empty");
	Validate.notBlank(tree, "tree should not be null or empty");
	Validate.notNull(author, "author should not be null");
	Validate.notNull(committer, "committer should not be null");
	Validate.notNull(description, "description should not be null");

	this.commit = commit;
	this.tree = tree;
	this.action = action;
	this.parent = parent;
	this.author = author;
	this.authorEmail = authorEmail;
	this.date = date;
	this.committer = committer;
	this.committerEmail = committerEmail;
	this.committerDate = committerDate;
	this.description = description;
}
 
Example 2
Source File: XSFunctionApplier.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public T apply(Object target) {
	Validate.notNull(target);
	if (target instanceof XSComponent) {
		return ((XSComponent) target).apply(f);
	} else if (target instanceof SchemaComponentAware) {
		final XSComponent schemaComponent = ((SchemaComponentAware) target)
				.getSchemaComponent();
		if (schemaComponent == null) {
			return null;
		} else {
			return schemaComponent.apply(f);
		}
	} else {
		return null;
	}
}
 
Example 3
Source File: MosaicSupplyChangeTransactionFactory.java    From symbol-sdk-java with Apache License 2.0 5 votes vote down vote up
private MosaicSupplyChangeTransactionFactory(
    NetworkType networkType, UnresolvedMosaicId mosaicId,
    MosaicSupplyChangeActionType action,
    BigInteger delta) {
    super(TransactionType.MOSAIC_SUPPLY_CHANGE, networkType);
    Validate.notNull(mosaicId, "UnresolvedMosaicId must not be null");
    Validate.notNull(action, "Action must not be null");
    Validate.notNull(delta, "Delta must not be null");
    this.mosaicId = mosaicId;
    this.action = action;
    this.delta = delta;
}
 
Example 4
Source File: UserDelegator.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Override
public String updateUser(@Nonnull final IUser user, final UpdateUserOptions opts)
        throws P4JavaException {

    Validate.notNull(user);
    Validate.notBlank(user.getLoginName());

    List<Map<String, Object>> resultMaps = execMapCmdList(
            USER,
            processParameters(opts, null, "-i", server),
            InputMapper.map(user));

    return parseCommandResultMapAsString(resultMaps);
}
 
Example 5
Source File: KnowledgeBaseItemAutoCompleteField.java    From inception with Apache License 2.0 5 votes vote down vote up
public KnowledgeBaseItemAutoCompleteField(String aId,
        IModel<KBHandle> aModel,
        SerializableFunction<String, List<KBHandle>> aChoiceProvider)
{
    super(aId, aModel, new TextRenderer<KBHandle>("uiLabel"));
    
    Validate.notNull(aChoiceProvider);
    choiceProvider = aChoiceProvider;
}
 
Example 6
Source File: DynamicListenerRegistration.java    From FunnyGuilds with Apache License 2.0 5 votes vote down vote up
public DynamicListenerRegistration(FunnyGuilds funnyGuilds, Collection<Listener> listeners, Supplier<Boolean> predicate) {
    Validate.notNull(listeners, "listener");
    Validate.notNull(predicate, "predicate");

    this.funnyGuilds = funnyGuilds;
    this.listeners = listeners;
    this.predicate = predicate;

    this.reload();
}
 
Example 7
Source File: Parameters.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
private static void addFileSpecIfValidFileSpec(@Nonnull final List<String> args,
                                               @Nullable final List<IFileSpec> fileSpecs) {
    Validate.notNull(args);

    if (nonNull(fileSpecs)) {
        for (IFileSpec fileSpec : fileSpecs) {
            if (fileSpec.getOpStatus() == VALID) {
                args.add(fileSpec.getAnnotatedPreferredPathString());
            }
        }
    }
}
 
Example 8
Source File: JpaAuditOperationsImpl.java    From gvnix with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Annotated entity with {@link GvNIXJpaAudit}
 * <p/>
 * 
 * @param entity
 * @return true if entity has been annotated or false if entity is already
 *         annotated
 */
public boolean annotateEntity(final JavaType entity) {
    Validate.notNull(entity, "Java type required");

    // get class details
    final ClassOrInterfaceTypeDetails cid = typeLocationService
            .getTypeDetails(entity);
    if (cid == null) {
        throw new IllegalArgumentException("Cannot locate source for '"
                .concat(entity.getFullyQualifiedTypeName()).concat("'"));
    }

    // Check for @GvNIXJpaAudit annotation
    if (MemberFindingUtils.getAnnotationOfType(cid.getAnnotations(),
            AUDIT_ANNOTATION_TYPE) == null) {
        // Add GvNIXJpaAudit annotation
        final AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(
                AUDIT_ANNOTATION_TYPE);
        final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
                cid);
        cidBuilder.addAnnotation(annotationBuilder);
        typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
        return true;
    }
    else {
        // Already annotated
        return false;
    }
}
 
Example 9
Source File: ClientDelegator.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public IClient getClient(@Nonnull IClientSummary clientSummary)
        throws ConnectionException, RequestException, AccessException {
    Validate.notNull(clientSummary);
    return getClient(clientSummary.getName());
}
 
Example 10
Source File: CraftTeam.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public void setDisplayName(String displayName) throws IllegalStateException {
    Validate.notNull(displayName, "Display name cannot be null");
    Validate.isTrue(displayName.length() <= 32, "Display name '" + displayName + "' is longer than the limit of 32 characters");
    CraftScoreboard scoreboard = checkState();

    team.setDisplayName(displayName);
}
 
Example 11
Source File: FileUtil.java    From vjtools with Apache License 2.0 5 votes vote down vote up
/**
 * 复制文件或目录, not following links.
 * 
 * @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);

	copy(from.toPath(), to.toPath());
}
 
Example 12
Source File: RpcStreamConnection.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
public long putRpcPackets(@Nonnull RpcPacket[] packets) throws ConnectionException {
    Validate.notNull(packets);
    int retVal = 0;

    for (RpcPacket packet : packets) {
        if (nonNull(packet)) {
            retVal += putRpcPacket(packet);
        }
    }
    return retVal;
}
 
Example 13
Source File: FileUtil.java    From vjtools with Apache License 2.0 5 votes vote down vote up
/**
 * 文件复制. {@link Files#copy}
 * 
 * @param from 如果为null,或文件不存在或者是目录,,抛出异常
 * @param to 如果to为null,或文件存在但是一个目录,抛出异常
 */
public static void copyFile(@NotNull Path from, @NotNull Path to) throws IOException {
	Validate.isTrue(Files.exists(from), "%s is not exist or not a file", from);
	Validate.notNull(to);
	Validate.isTrue(!FileUtil.isDirExists(to), "%s is exist but it is a dir", to);
	Files.copy(from, to);
}
 
Example 14
Source File: StackExchangeApi.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IDataSet<QuestionsResponse> getQuestionsQuestionsResponseByIds(String ids, String order, String max, String min, String sort, Integer fromdate, Integer todate, String filter, String callback, String site){ 
	Validate.notNull(ids);
	if (order != null) {
		Validate.matchesPattern(order,"(desc|asc)");
	}
	
	
	if (sort != null) {
		Validate.matchesPattern(sort,"(activity|creation|votes)");
	}
	
	
	
	
	Validate.notNull(site);
	return entityClient.getQuestionsQuestionsResponseByIds(ids, order, max, min, sort, fromdate, todate, filter, callback, site);
}
 
Example 15
Source File: GitlabApi.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IData<Deployment> getV3ProjectsDeploymentsDeploymentByDeploymentId(String id, Integer deploymentId){ 
	Validate.notNull(id);
	Validate.notNull(deploymentId);
	return entityClient.getV3ProjectsDeploymentsDeploymentByDeploymentId(id, deploymentId);
}
 
Example 16
Source File: Mapping.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void addTypeInfo(MTypeInfo<T, C> typeInfo) {
	Validate.notNull(typeInfo);
	typeInfo.acceptTypeInfoVisitor(typeInfoAdder);
}
 
Example 17
Source File: StackExchangeApi.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public IDataSet<Comments> getComments(String order, String max, String min, String sort, Integer fromdate, Integer todate, String filter, String callback, String site){ 
	if (order != null) {
		Validate.matchesPattern(order,"(desc|asc)");
	}
	
	
	if (sort != null) {
		Validate.matchesPattern(sort,"(creation|votes)");
	}
	
	
	
	
	Validate.notNull(site);
	return entityClient.getComments(order, max, min, sort, fromdate, todate, filter, callback, site);
}
 
Example 18
Source File: IDestinationAccessor.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
/**
 * See {@link IDestinationAccessor#setDestinations(String...)}
 * @param destinations
 */
public default void setDestinations(@Nonnull Collection<String> destinations){
    Validate.notNull(destinations);
    setDestinations(destinations.toArray(new String[destinations.size()]));
}
 
Example 19
Source File: IsLiteralEquals.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public IsLiteralEquals(String value) {
	Validate.notNull(value);
	this.value = value;
}
 
Example 20
Source File: CollectionsUtil.java    From feilong-core with Apache License 2.0 2 votes vote down vote up
/**
 * 从 <code>objectCollection</code>中删除所有的 <code>null</code>元素 <span style="color:red">(原集合对象不变)</span>.
 * 
 * <h3>说明:</h3>
 * <blockquote>
 * 
 * <ol>
 * <li>返回剩余的集合 <span style="color:red">(原集合对象<code>objectCollection</code>不变)</span>,如果你不想修改 <code>objectCollection</code>的话,不能直接调用
 * <code>collection.removeAll(remove);</code>,这个方法非常有用.</li>
 * <li>底层实现是调用的 {@link ListUtils#removeAll(Collection, Collection)},将不是<code>removeElement</code>的元素加入到新的list返回.</li>
 * </ol>
 * 
 * </blockquote>
 * 
 * <h3>示例:</h3>
 * 
 * <blockquote>
 * 
 * <p>
 * <b>场景:</b> 从list中删除 null 元素
 * </p>
 * 
 * <pre class="code">
 * List{@code <String>} list = toList("xinge", <span style="color:red">null</span>, "feilong2", <span style=
"color:red">null</span>, "feilong2");
 * List{@code <String>} removeList = CollectionsUtil.removeAllNull(list);
 * </pre>
 * 
 * <b>返回:</b>
 * 
 * <pre class="code">
 * "xinge", "feilong2", "feilong2"
 * </pre>
 * 
 * </blockquote>
 *
 * @param <O>
 *            the generic type
 * @param objectCollection
 *            the collection from which items are removed (in the returned collection)
 * @return 从 <code>objectCollection</code>中排除掉 <code>null</code> 元素的新的 list
 * @throws NullPointerException
 *             如果 <code>objectCollection</code> 是null
 * @see ListUtils#removeAll(Collection, Collection)
 * @since Commons Collections 4
 * @since 1.11.0
 */
public static <O> List<O> removeAllNull(Collection<O> objectCollection){
    Validate.notNull(objectCollection, "objectCollection can't be null!");
    return remove(objectCollection, toArray((O) null));
}