spring common tools

一、org.springframework.util.Assert:

It concludes that an actual operating value is as expected, otherwise it throws an exception. Spring's detection of method parameters borrows this concept. The Assert class provided by Spring has many methods for asserting method parameters according to rules, which can meet the requirements of most method parameter detection. These assertion methods will throw 
IllegalArgumentException when the input parameters do not meet the requirements.

example:

public Boolean exportCrowd(QueryCrowdExport obj) {
		Assert.notNull(obj);
		Assert.notNull(obj.getCrowdId());
		Assert.notNull(obj.getExportType());
		
    	//crowdId gets the crowd record
		Crowd crowd = new Crowd();
		crowd = crowdService.queryCrowdById(obj.getCrowdId());
    	//check
    	if(ObjectUtils.isEmpty(crowd)==true) {
    		return false;
    	}
    	//Add job, update flag
    	Boolean res = false;
    	if(obj.getExportType().equals("CC")) {
    		res = jobService.addCCJob (crowd);
    		if(res==true) {
    			crowd.setCcExported(true);
    			crowdMapper.updateByPrimaryKeySelective(crowd);
    		}
    	}else if(obj.getExportType().equals("CIA")) {
    		res = jobService.addCIAJob (crowd, obj);
    		if(res==true) {
    			crowd.setCiaExported(true);
    			crowdMapper.updateByPrimaryKeySelective(crowd);
    		}
    	}	
    	return res;
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325464032&siteId=291194637