List of usage examples for org.springframework.util Assert isTrue
public static void isTrue(boolean expression, Supplier<String> messageSupplier)
From source file:com.jaxio.celerio.output.FileMetaData.java
/** * @param pack/*from www . j a va 2 s. com*/ * @param template * @param fileRelativePath relative to the project dir. That is the dir containing ".celerio/generated.xml" * @param file */ public FileMetaData(TemplatePack pack, Template template, String fileRelativePath, File file) { Assert.notNull(fileRelativePath, "When creating a new FileMetaData, you must pass a relativePath as it is used in equals comparison"); Assert.isTrue(file.exists(), "When creating a new FileMetaData, you must be sure that the passed file exists."); this.pack = pack == null ? "" : pack.getName(); this.template = template == null ? "" : template.getName(); this.size = file.length(); this.path = fileRelativePath; this.lastMod = file.lastModified(); }
From source file:com.stehno.sanctuary.core.remote.FileSystemRemoteStore.java
@Override public void init() { Assert.isTrue(remoteDir.exists(), "Remote directory does not exist."); Assert.isTrue(remoteDir.canRead(), "Remote directory is not readable."); Assert.isTrue(remoteDir.canWrite(), "Remote directory is not writable."); try {/*w w w. j av a 2s . c o m*/ this.fileSystemManager = VFS.getManager(); this.remoteRoot = fileSystemManager.toFileObject(remoteDir); } catch (FileSystemException e) { log.fatal("Unable to retrieve filesystem manager: " + e.getMessage(), e); } if (log.isInfoEnabled()) log.info("Initialized for: " + remoteRoot); }
From source file:org.jasig.cas.ticket.support.TicketGrantingTicketExpirationPolicy.java
public void afterPropertiesSet() throws Exception { Assert.isTrue((maxTimeToLiveInMilliSeconds >= timeToKillInMilliSeconds), "maxTimeToLiveInMilliSeconds must be greater than or equal to timeToKillInMilliSeconds."); }
From source file:gemfire.practice.domain.EmailAddress.java
/** * Creates a new {@link EmailAddress} from the given {@link String} representation. * //from ww w. j a v a2 s .c o m * @param emailAddress must not be {@literal null} or empty. */ EmailAddress(String emailAddress) { Assert.isTrue(isValid(emailAddress), "Invalid email address!: " + emailAddress); value = emailAddress; }
From source file:com.trenako.utility.Utils.java
/** * Creates an immutable {@code ArrayList} with the first elements. * * @param elements the elements/*from w w w.j av a 2 s . c o m*/ * @param size the size of the new sublist * @return the {@code ArrayList} */ public static <E> List<E> newSublist(Iterable<E> elements, int size) { Assert.isTrue(size > 0, "Size must be > 0"); int i = 1; List<E> list = new ArrayList<>(); for (E el : elements) { list.add(el); if (i == size) { break; } i++; } return Collections.unmodifiableList(list); }
From source file:com.github.qwazer.markdown.confluence.gradle.plugin.ConfluenceGradleTask.java
protected static void validate(ConfluenceConfig config) { Assert.notNull(config);/*w w w. j a va 2 s .c o m*/ Assert.hasLength(config.getRestApiUrl()); Assert.hasLength(config.getSpaceKey()); Assert.notNull(config.getPages()); for (ConfluenceConfig.Page page : config.getPages()) { Assert.hasLength(page.getParentTitle()); Assert.hasLength(page.getTitle()); Assert.notNull(page.getSrcFile()); Assert.isTrue(!page.getParentTitle().equals(page.getTitle()), String.format("Page with title %s cannot be parent of itself ", page.getTitle())); } validateNoDuplicates(config.getPages()); }
From source file:au.com.onegeek.lambda.extension.provider.MattAssertionProvider.java
public void matt(String message) { logger.info("Called Matt method!"); String source = this.driver.getPageSource(); Assert.isTrue(source.contains(message), "'" + message + "' was not found to be awesome in the DOM Source"); }
From source file:org.sharetask.security.TaskCreatorPermission.java
@Override public boolean isAllowed(final Authentication authentication, final Object targetDomainObject) { boolean result; Assert.isTrue(isAuthenticated(authentication), "UserAuthentication is not authenticated!"); Assert.isTrue(targetDomainObject instanceof Long); final Long taskId = (Long) targetDomainObject; final String userName = authentication.getName(); final Task task = taskRepository.read(taskId); if (task.getCreatedBy().getUsername().equals(userName)) { result = true;/*from w w w . j a v a 2 s .c o m*/ } else { result = false; } return result; }
From source file:org.sharetask.security.TaskAssigneePermission.java
@Override public boolean isAllowed(final Authentication authentication, final Object targetDomainObject) { boolean result; Assert.isTrue(isAuthenticated(authentication), "UserAuthentication is not authenticated!"); Assert.isTrue(targetDomainObject instanceof Long); final Long taskId = (Long) targetDomainObject; final String userName = authentication.getName(); final Task task = this.taskRepository.read(taskId); if (task.getAssignee().getUsername().equals(userName)) { result = true;/*w ww . j a va 2 s. c om*/ } else { result = false; } return result; }
From source file:org.sharetask.security.TaskAssigneeOrCreatorPermission.java
@Override public boolean isAllowed(final Authentication authentication, final Object targetDomainObject) { boolean result; Assert.isTrue(isAuthenticated(authentication), "UserAuthentication is not authenticated!"); Assert.isTrue(targetDomainObject instanceof Long); final Long taskId = (Long) targetDomainObject; final String userName = authentication.getName(); final Task task = this.taskRepository.read(taskId); if (task.getAssignee() != null && task.getAssignee().getUsername().equals(userName)) { result = true;//from ww w . j av a 2 s . com } else if (task.getCreatedBy() != null && task.getCreatedBy().getUsername().equals(userName)) { result = true; } else { result = false; } return result; }