當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。