Example usage for org.springframework.util Assert state

List of usage examples for org.springframework.util Assert state

Introduction

In this page you can find the example usage for org.springframework.util Assert state.

Prototype

public static void state(boolean expression, Supplier<String> messageSupplier) 

Source Link

Document

Assert a boolean expression, throwing an IllegalStateException if the expression evaluates to false .

Usage

From source file:net.sf.gazpachoquest.services.core.impl.QuestionnaireAnswersServiceImpl.java

@Override
@Transactional/*from w  w  w.  jav a2s  . c  om*/
public Object findByQuestionCode(Questionnaire questionnaire, String questionCode) {
    Assert.state(!questionnaire.isNew(), "Persist the questionnaire before saving answers");
    Questionnaire fetched = questionnaireRepository.findOne(questionnaire.getId());
    Integer questionnairDefinitionId = fetched.getQuestionnaireDefinition().getId();
    Integer answersId = fetched.getAnswersId();
    if (fetched.getAnswersId() == null) {
        return null;
    }
    QuestionnaireAnswers answers = repository.findByOne(questionnairDefinitionId, answersId);
    return answers.getAnswer(questionCode);
}

From source file:org.spring.data.gemfire.app.main.SpringGemFireCacheServerLauncher.java

protected ConfigurableApplicationContext getApplicationContext() {
    Assert.state(applicationContext != null, "The Spring Application Context was not initialized!");
    return applicationContext;
}

From source file:example.app.service.CustomerService.java

protected ContactRepository getContactRepository() {
    Assert.state(contactRepository != null, "ContactRepository was not properly initialized");
    return contactRepository;
}

From source file:org.opennms.ng.dao.support.ResourceAttributeFilteringResourceVisitor.java

/**
 * <p>afterPropertiesSet</p>
 *
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 *//*from  w  ww .jav a  2  s.co m*/
@Override
public void afterPropertiesSet() {
    Assert.state(m_delegatedVisitor != null, "property delegatedVisitor must be set to a non-null value");
    Assert.state(m_resourceAttributeKey != null,
            "property resourceAttributeKey must be set to a non-null value");
    Assert.state(m_resourceAttributeValueMatch != null,
            "property resourceAttributeValueMatch must be set to a non-null value");
}

From source file:org.spring.data.gemfire.app.service.UserService.java

protected UserRepository getUserRepository() {
    Assert.state(userRepository != null, "A reference to the UserRepository was not properly configured!");
    return userRepository;
}

From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapJobInstanceDao.java

public JobInstance createJobInstance(String jobName, JobParameters jobParameters) {

    Assert.state(getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist");

    JobInstance jobInstance = new JobInstance(currentId++, jobParameters, jobName);
    jobInstance.incrementVersion();//from  w w  w .j  a v  a  2s .c o m
    //Removes the older jobInstances
    if (this.jobInstances.size() >= maxJobInstanceCount) {
        JobInstance toRemove = this.jobInstances.remove();
        LOGGER.info("Removing jobInstance: " + toRemove.toString());
        List<JobExecution> executions = this.jobExecutionDao.findJobExecutions(toRemove);
        for (JobExecution execution : executions) {
            //Remove job executions
            LOGGER.info("Removing JobExecution: " + execution.toString());
            this.jobExecutionDao.removeExecution(execution.getId());
            this.stepExecutionDao.removeStepExecutions(execution);
            //Remove execution contexts
            this.executionContextDao.removeExecutionContext(execution);
        }
    }
    jobInstances.add(jobInstance);
    return jobInstance;
}

From source file:org.spring.data.gemfire.app.service.GemstoneService.java

protected GemstoneDao getDatabaseGemstoneDao() {
    Assert.state(databaseGemstoneDao != null,
            "A reference to the 'Database' GemsDao was not properly configured!");
    return databaseGemstoneDao;
}

From source file:org.spring.data.gemfire.app.dao.vendor.GemFireGemstoneDao.java

protected Region<Long, String> getGemstonesRegion() {
    Assert.state(gemstones != null, "A reference to the 'Gemstones' Region was not properly configured!");
    return gemstones;
}

From source file:org.spring.data.gemfire.app.main.SpringGemFireCacheServerLauncher.java

protected Cache getCache() {
    Assert.state(cache != null, "The GemFire Cache was not initialized!");
    return cache;
}