Example usage for org.springframework.util Assert isTrue

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:org.cleverbus.api.event.CompletedMsgAsynchEvent.java

/**
 * Creates new event./*from  w ww . jav a  2s  . c  o  m*/
 *
 * @param exchange the exchange
 * @param message  the message
 */
public CompletedMsgAsynchEvent(Exchange exchange, Message message) {
    super(exchange, message);

    Assert.isTrue(message.getState() == MsgStateEnum.OK, "the message must be in the state " + MsgStateEnum.OK);
}

From source file:com.bigtester.ate.tcg.chat.InMemoryChatRepository.java

public List<String> getMessages(int index) {
    if (this.messages.isEmpty()) {
        List<String> temp = Collections.<String>emptyList();
        if (null == temp)
            temp = new ArrayList<String>();
        return temp;
    }/*from w w w. j  a  va 2 s.com*/
    Assert.isTrue((index >= 0) && (index <= this.messages.size()), "Invalid message index");

    return new ArrayList<String>(); //this.messages.subList(index, this.messages.size());
}

From source file:org.cleverbus.api.event.PartlyFailedMsgAsynchEvent.java

/**
 * Creates new event./*from w  ww.j av  a2 s  .  c om*/
 *
 * @param exchange the exchange
 * @param message  the message
 */
public PartlyFailedMsgAsynchEvent(Exchange exchange, Message message) {
    super(exchange, message);

    Assert.isTrue(message.getState() == MsgStateEnum.PARTLY_FAILED,
            "the message must be in the state " + MsgStateEnum.PARTLY_FAILED);
}

From source file:example.complete.Customer.java

Customer(String firstname, String lastname, LocalDate birthday) {

    Assert.hasText(firstname, "Firstname must not be null or empty!");
    Assert.hasText(lastname, "Lastname must not be null or empty!");
    Assert.isTrue(birthday.isBefore(LocalDate.now()), "Date of birth must be in the past!");

    this.firstname = firstname;
    this.lastname = lastname;
    this.birthday = birthday;
}

From source file:demo.utils.MiniClusterUtils.java

public static void startMiniCluster() {
    if (clusterLauncher != null) {
        throw new IllegalStateException("MiniClustrer is currently running");
    }//from w  ww. j av  a 2  s.  c o  m
    File file = new File(System.getProperty("user.dir"));
    Path path = Paths.get(file.getAbsolutePath());
    Path parentPath = path.getParent();
    String[] resources = file.list();
    for (String resource : resources) {
        if (resource.equals("yaya-demo")) {
            parentPath = path;
            break;
        }
    }
    File miniClusterExe = new File(
            parentPath.toString() + "/yarn-test-cluster/build/install/yarn-test-cluster/bin/yarn-test-cluster");
    System.out.println(miniClusterExe.getAbsolutePath());
    if (!miniClusterExe.exists()) {
        logger.info("BUILDING MINI_CLUSTER");
        CommandProcessLauncher buildLauncher = new CommandProcessLauncher(
                path.toString() + "/build-mini-cluster");
        buildLauncher.launch();
    }
    Assert.isTrue(miniClusterExe.exists(), "Failed to find mini-cluster executable");
    clusterLauncher = new CommandProcessLauncher(miniClusterExe.getAbsolutePath());
    executor = Executors.newSingleThreadExecutor();
    executor.execute(new Runnable() {
        @Override
        public void run() {
            logger.info("STARTING MINI_CLUSTER");
            clusterLauncher.launch();
        }
    });
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
}

From source file:com.vaadin.spring.internal.UIID.java

public UIID(UI ui) {
    Assert.notNull(ui, "ui must not be null");
    Assert.isTrue(ui.getUIId() > -1, "UIId of ui must not be -1");
    this.uiId = ui.getUIId();
}

From source file:com.jaxio.celerio.configuration.database.IndexHolder.java

public void addIndexes(List<Index> indexes) {
    Assert.isTrue(indexes.size() > 0, "there must be at least one index");
    for (Index index : indexes) {
        addIndex(index);//from w  w  w .j  a  v  a2 s  . c om
    }
}

From source file:org.covito.kit.cache.support.EhCache.java

/**
 * Constructor//ww  w.  j  a v a  2  s  .c o m
 * 
 * @param cacheManager
 * @param cache
 */
public EhCache(Ehcache cache) {
    Assert.notNull(cache, "Ehcache must not be null");
    Status status = cache.getStatus();
    Assert.isTrue(Status.STATUS_ALIVE.equals(status),
            "An 'alive' Ehcache is required - current cache is " + status.toString());
    this.cache = cache;
}

From source file:org.grails.datastore.gorm.mongo.WithinBox.java

@Override
public void setArguments(Object[] arguments) {
    Assert.isTrue(arguments.length > 0 && arguments[0] instanceof List,
            "Only a list of elements is supported in a 'withinBox' query");

    Collection<?> argument = (Collection<?>) arguments[0];
    Assert.isTrue(argument.size() == 2, "A 'withinBox' query requires a two dimensional list of values");

    super.setArguments(arguments);
}

From source file:com.banyou.backend.service.resource.ImageService.java

public InputStream getResourceStreamByUrl(String url) {
    int index = url.indexOf(urlBase);
    Assert.isTrue(index == 0, "not my resource");
    String path = pathBase + url.substring(urlBase.length());

    try {/* w  w  w. ja v a2  s.co m*/
        return new FileInputStream(path);
    } catch (FileNotFoundException e) {
        return null;
    }
}