当前位置: 首页>>代码示例>>Java>>正文


Java Assert.isTrue方法代码示例

本文整理汇总了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");
    }
}
 
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:25,代码来源:TarantoolPersistentPropertyImpl.java

示例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 ;
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:20,代码来源:MybatisRepositoryQuery.java

示例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);
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:8,代码来源:JpaMutableAclService.java

示例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));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:AuthConsumerMain.java

示例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");
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:10,代码来源:ReleaseCommands.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:EhCacheCacheManager.java

示例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;
}
 
开发者ID:baidu,项目名称:uid-generator,代码行数:45,代码来源:RingBuffer.java

示例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);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:14,代码来源:GoogleConfigPropertySourceLocator.java

示例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");
	}
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:9,代码来源:AbstractChannelEvent.java

示例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;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:12,代码来源:PubSubAdmin.java

示例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());
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:17,代码来源:GeneFileManager.java

示例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);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:11,代码来源:AppsServiceImpl.java

示例14: testGetId

import org.springframework.util.Assert; //导入方法依赖的package包/类
@Test
public void testGetId()
{
    Leaderboard ld = new Leaderboard(1, "");
    Assert.isTrue(ld.getId() == 1);
}
 
开发者ID:Vyserion,项目名称:lodbot,代码行数:7,代码来源:LeaderboardTest.java

示例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);
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:6,代码来源:CloudFoundryClient.java


注:本文中的org.springframework.util.Assert.isTrue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。