本文整理汇总了Java中org.springframework.util.Assert.isTrue方法的典型用法代码示例。如果您正苦于以下问题:Java Assert.isTrue方法的具体用法?Java Assert.isTrue怎么用?Java Assert.isTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.Assert
的用法示例。
在下文中一共展示了Assert.isTrue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TarantoolPersistentPropertyImpl
import org.springframework.util.Assert; //导入方法依赖的package包/类
public TarantoolPersistentPropertyImpl(Field field, PropertyDescriptor propertyDescriptor, TarantoolPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
super(field, propertyDescriptor, owner, simpleTypeHolder);
this.tupleIndex = Optional.ofNullable(findPropertyOrOwnerAnnotation(Tuple.class))
.map(Tuple::index)
.orElse(null);
if(tupleIndex != null) {
Assert.isTrue(tupleIndex >= 0, "Tuple index cannot be negative");
}
this.spaceName =
Optional.ofNullable(findPropertyOrOwnerAnnotation(Index.class))
.map(Index::value)
.orElse(null);
if(spaceName != null) {
Assert.hasText(spaceName, "Space index cannot be negative");
}
if(isIdProperty()) {
Assert.isTrue(tupleIndex != null, "Id property must have tuple index");
}
}
示例2: execute
import org.springframework.util.Assert; //导入方法依赖的package包/类
@Override
public Object execute(Object[] parameters) {
log.info("执行{}.{},参数为{}" , repositoryMetadata.getRepositoryInterface().getName() ,
method.getName() , parameters!=null?Arrays.toString(parameters):"") ;
Object result = null ;
try {
Object mapper = mybatisMapperMap.get(getMapperKey()) ;
Assert.isTrue(mapper!=null , repositoryMetadata.getRepositoryInterface().getName()+"对应的Mapper为null");
if(mapper!=null){
result = method.invoke(mapper , parameters) ;
}
} catch (Exception e) {
e.printStackTrace();
}
return result ;
}
示例3: readAclById
import org.springframework.util.Assert; //导入方法依赖的package包/类
@Override
public Acl readAclById(ObjectIdentity object, List<Sid> sids) throws NotFoundException {
Map<ObjectIdentity, Acl> map = readAclsById(Arrays.asList(object), sids);
Assert.isTrue(map.containsKey(object), "There should have been an Acl entry for ObjectIdentity " + object);
return (Acl) map.get(object);
}
示例4: main
import org.springframework.util.Assert; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
init();
Person person = new Person();
person.setName("ServiceComb/Authenticate");
System.out
.println("RestTemplate Consumer or POJO Consumer. You can choose whatever you like.");
String sayHiResult = restTemplate
.postForObject(
"cse://auth-provider/springmvchello/sayhi?name=Authenticate",
null,
String.class);
String sayHelloResult = restTemplate.postForObject(
"cse://auth-provider/springmvchello/sayhello",
person,
String.class);
Assert.isTrue("Hello Authenticate".equals(sayHiResult));
Assert.isTrue("Hello person ServiceComb/Authenticate".equals(sayHelloResult));
}
示例5: assertMutuallyExclusiveFileAndProperties
import org.springframework.util.Assert; //导入方法依赖的package包/类
private void assertMutuallyExclusiveFileAndProperties(File yamlFile, String properties) {
Assert.isTrue(!(yamlFile != null && properties != null), "The options 'file' and 'properties' options "
+ "are mutually exclusive.");
if (yamlFile != null) {
String extension = FilenameUtils.getExtension(yamlFile.getName());
Assert.isTrue((extension.equalsIgnoreCase("yml") || extension.equalsIgnoreCase("yaml")),
"The file should be YAML file");
}
}
示例6: loadCaches
import org.springframework.util.Assert; //导入方法依赖的package包/类
@Override
protected Collection<Cache> loadCaches() {
net.sf.ehcache.CacheManager cacheManager = getCacheManager();
Assert.notNull(cacheManager, "A backing EhCache CacheManager is required");
Status status = cacheManager.getStatus();
Assert.isTrue(Status.STATUS_ALIVE.equals(status),
"An 'alive' EhCache CacheManager is required - current cache is " + status.toString());
String[] names = cacheManager.getCacheNames();
Collection<Cache> caches = new LinkedHashSet<Cache>(names.length);
for (String name : names) {
caches.add(new EhCacheCache(cacheManager.getEhcache(name)));
}
return caches;
}
示例7: take
import org.springframework.util.Assert; //导入方法依赖的package包/类
/**
* Take an UID of the ring at the next cursor, this is a lock free operation by using atomic cursor<p>
*
* Before getting the UID, we also check whether reach the padding threshold,
* the padding buffer operation will be triggered in another thread<br>
* If there is no more available UID to be taken, the specified {@link RejectedTakeBufferHandler} will be applied<br>
*
* @return UID
* @throws IllegalStateException if the cursor moved back
*/
public long take() {
// spin get next available cursor
long currentCursor = cursor.get();
long nextCursor = cursor.updateAndGet(old -> old == tail.get() ? old : old + 1);
// check for safety consideration, it never occurs
Assert.isTrue(nextCursor >= currentCursor, "Curosr can't move back");
// trigger padding in an async-mode if reach the threshold
long currentTail = tail.get();
if (currentTail - nextCursor < paddingThreshold) {
LOGGER.info("Reach the padding threshold:{}. tail:{}, cursor:{}, rest:{}", paddingThreshold, currentTail,
nextCursor, currentTail - nextCursor);
bufferPaddingExecutor.asyncPadding();
}
// cursor catch the tail, means that there is no more available UID to take
if (nextCursor == currentCursor) {
rejectedTakeHandler.rejectTakeBuffer(this);
}
// 1. check next slot flag is CAN_TAKE_FLAG
int nextCursorIndex = calSlotIndex(nextCursor);
Assert.isTrue(flags[nextCursorIndex].get() == CAN_TAKE_FLAG, "Curosr not in can take status");
// 2. get UID from next slot
// 3. set next slot flag as CAN_PUT_FLAG.
long uid = slots[nextCursorIndex];
flags[nextCursorIndex].set(CAN_PUT_FLAG);
// Note that: Step 2,3 can not swap. If we set flag before get value of slot, the producer may overwrite the
// slot with a new UID, and this may cause the consumer take the UID twice after walk a round the ring
return uid;
}
示例8: getAuthorizedRequest
import org.springframework.util.Assert; //导入方法依赖的package包/类
private HttpEntity<Void> getAuthorizedRequest() throws IOException {
HttpHeaders headers = new HttpHeaders();
Map<String, List<String>> credentialHeaders = this.credentials.getRequestMetadata();
Assert.notNull(credentialHeaders, "No valid credential header(s) found");
for (Map.Entry<String, List<String>> entry : credentialHeaders.entrySet()) {
for (String value : entry.getValue()) {
headers.add(entry.getKey(), value);
}
}
Assert.isTrue(headers.containsKey(AUTHORIZATION_HEADER), "Authorization header required");
return new HttpEntity<>(headers);
}
示例9: disableEmoteOnly
import org.springframework.util.Assert; //导入方法依赖的package包/类
public void disableEmoteOnly() {
if (!isBotModerator()) return;
boolean enabled = (Boolean) getClient().getMessageInterface().getTwitchChat().getChannelCache().get(channel.getName()).getChannelState().get(ChannelStateEvent.ChannelState.EMOTE);
Assert.isTrue(!enabled, "Emote only mode is already disabled");
if (enabled) {
sendMessage("/emoteonlyoff");
}
}
示例10: buildUrl
import org.springframework.util.Assert; //导入方法依赖的package包/类
private static Optional<String> buildUrl(HttpServletRequest request, String path) {
Assert.notNull(request, "request is required; it must not be null");
Assert.isTrue(!StringUtils.isEmpty(path), "path is required, it must not be null or empty");
try {
URI uri = new URI(path);
if (!uri.isAbsolute()) {
return Optional.of(getBaseUrl(request, true) + path);
}
} catch (URISyntaxException e) {
// Do nothing
}
return Optional.empty();
}
开发者ID:kakawait,项目名称:cas-security-spring-boot-starter,代码行数:14,代码来源:RequestAwareCasAuthenticationEntryPoint.java
示例11: setDefaultAckDeadline
import org.springframework.util.Assert; //导入方法依赖的package包/类
/**
* Set the default acknowledgement deadline value.
*
* @param defaultAckDeadline default acknowledgement deadline value in seconds
*/
public void setDefaultAckDeadline(int defaultAckDeadline) {
Assert.isTrue(defaultAckDeadline >= 0,
"The acknowledgement deadline value can't be negative.");
this.defaultAckDeadline = defaultAckDeadline;
}
示例12: deleteGeneFile
import org.springframework.util.Assert; //导入方法依赖的package包/类
/**
* Removes {@code GeneFile} record from the database
*
* @param geneFile a {@code GeneFile} record to remove
*/
@Transactional(propagation = Propagation.REQUIRED)
public void deleteGeneFile(GeneFile geneFile) {
List<Project> projectsWhereFileInUse = projectDao.loadProjectsByBioDataItemId(geneFile.getBioDataItemId());
Assert.isTrue(projectsWhereFileInUse.isEmpty(), MessageHelper.getMessage(MessagesConstants.ERROR_FILE_IN_USE,
geneFile.getName(), geneFile.getId(), projectsWhereFileInUse.stream().map(BaseEntity::getName)
.collect(Collectors.joining(", "))));
geneFileDao.deleteGeneFile(geneFile.getId());
biologicalDataItemDao.deleteBiologicalDataItem(geneFile.getIndex().getId());
biologicalDataItemDao.deleteBiologicalDataItem(geneFile.getBioDataItemId());
}
示例13: list
import org.springframework.util.Assert; //导入方法依赖的package包/类
@Override
public List<AndroidApp> list(Integer parentId, Integer subTypeId) {
if (parentId != null) {
Assert.isTrue(parentId > -1, "Illegal params!");
}
if (subTypeId != null) {
Assert.isTrue(subTypeId > -1, "Illegal params!");
}
return appsDao.list(parentId, subTypeId);
}
示例14: testGetId
import org.springframework.util.Assert; //导入方法依赖的package包/类
@Test
public void testGetId()
{
Leaderboard ld = new Leaderboard(1, "");
Assert.isTrue(ld.getId() == 1);
}
示例15: getFile
import org.springframework.util.Assert; //导入方法依赖的package包/类
@Override
public String getFile(String appName, int instanceIndex, String filePath, int startPosition) {
Assert.isTrue(startPosition >= 0, startPosition + " is not a valid value for start position, it should be 0 or greater.");
return cc.getFile(appName, instanceIndex, filePath, startPosition, -1);
}