Example usage for org.springframework.util StringUtils isEmpty

List of usage examples for org.springframework.util StringUtils isEmpty

Introduction

In this page you can find the example usage for org.springframework.util StringUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable Object str) 

Source Link

Document

Check whether the given object (possibly a String ) is empty.

Usage

From source file:io.curly.bloodhound.web.SearchController.java

@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
DeferredResult<ResponseEntity<List<Artifact>>> search(
        @RequestParam(value = "q", required = false) String query) {
    if (StringUtils.isEmpty(query)) {
        throw new BadRequestException("Query parameter 'q' is required!");
    } else {/*www . j a v a  2s.c o  m*/
        return defer(elasticQueryService.getResults(query).map(ResponseEntity::ok));
    }

}

From source file:management.limbr.ui.roles.RolesPresenter.java

@Override
public BeanItemContainer<Role> listEntities(String filter) {
    if (StringUtils.isEmpty(filter)) {
        return new BeanItemContainer<>(Role.class, repository.findAll());
    } else {/*  w  ww.j av a  2  s. c om*/
        return new BeanItemContainer<>(Role.class, repository.findByNameStartsWithIgnoreCase(filter));
    }
}

From source file:be.roots.taconic.pricingguide.domain.Pricing.java

private void init() {
    if (!initialized) {
        initialized = true;//ww  w.j  ava  2s  . c  om
        for (Line line : lines) {
            if (!StringUtils.isEmpty(line.getQuantity())) {
                quantities = true;
            }
            if (!StringUtils.isEmpty(line.getAge())) {
                age = true;
            }
            if (!StringUtils.isEmpty(line.getFemale())) {
                female = true;
            }
            if (!StringUtils.isEmpty(line.getMale())) {
                male = true;
            }
        }
        if (isQuantities()) {
            numberOfHeaderItems++;
        }
        if (isAge()) {
            numberOfHeaderItems++;
        }
        if (isFemale()) {
            numberOfHeaderItems++;
        }
        if (isMale()) {
            numberOfHeaderItems++;
        }
    }
}

From source file:org.terasoluna.gfw.functionaltest.app.DBLog.java

public void saveForced(String subTitle) {

    if (StringUtils.isEmpty(subTitle)) {
        subTitle = "";
    } else {/*from  w w  w . ja v  a2s . co  m*/
        subTitle = "-" + subTitle;
    }

    int sequenceNo = sequence.incrementAndGet();

    writeLog("SELECT * FROM logging_event ORDER BY event_id ASC", sequenceNo, subTitle, "logging_event");

    writeLog("SELECT * FROM logging_event_property ORDER BY event_id ASC, mapped_key ASC", sequenceNo, subTitle,
            "logging_event_property");

    writeLog("SELECT * FROM logging_event_exception ORDER BY event_id ASC, i ASC", sequenceNo, subTitle,
            "logging_event_exception");

}

From source file:management.limbr.ui.users.UsersPresenter.java

@Override
public BeanItemContainer<User> listEntities(String filter) {
    if (StringUtils.isEmpty(filter)) {
        return new BeanItemContainer<>(User.class, repository.findAll());
    } else {/*from  w w  w.  j ava 2  s .  c om*/
        return new BeanItemContainer<>(User.class, repository.findByUsernameStartsWithIgnoreCase(filter));
    }
}

From source file:com.ge.predix.acs.commons.policy.condition.ResourceHandler.java

/**
 * @param pathVariable//from  w  w  w. j av  a  2s  .  co m
 *            name of path parameter in the URL
 * @return path parameter value
 */
public String uriVariable(final String pathVariable) {
    if (StringUtils.isEmpty(this.resourceURITemplate) || StringUtils.isEmpty(this.resourceURI)
            || StringUtils.isEmpty(pathVariable)) {
        return "";
    }
    UriTemplate template = new UriTemplate(this.resourceURITemplate);
    Map<String, String> match = template.match(this.resourceURI);
    String pathVariableValue = match.get(pathVariable);
    return pathVariableValue != null ? pathVariableValue : "";
}

From source file:com.kenshoo.freemarker.platform.YamlPropertiesPersister.java

public void assignProperties(Properties props, Map<String, Object> map, String path) {
    for (Map.Entry<String, Object> entry : map.entrySet()) {
        String key = entry.getKey();
        if (!StringUtils.isEmpty(path))
            key = path + "." + key;
        Object val = entry.getValue();
        if (val instanceof String) {
            // see if we need to create a compound key
            props.put(key, val);
        } else if (val instanceof Map) {
            assignProperties(props, (Map<String, Object>) val, key);
        }/*from   w ww  . j av a  2  s .c  om*/
    }
}

From source file:com.payu.ratel.proxy.UnicastingInvocationHandler.java

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    String serviceAddress = fetchStrategy.fetchServiceAddress(serviceApi.getName());

    if (StringUtils.isEmpty(serviceAddress)) {
        LOGGER.error("No instance named{}", serviceApi.getName());
        throw new NoServiceInstanceFound(serviceApi);
    }/*from  ww w. ja  v  a  2  s .c o  m*/

    final Object clientProxy = clientProxyGenerator.generate(serviceApi, serviceAddress, timeout);

    LOGGER.debug("Calling {} on address {}", serviceApi.getName(), serviceAddress);

    try {
        return method.invoke(clientProxy, args);
    } catch (InvocationTargetException e) {
        // Invoked method threw a checked exception.
        // We must rethrow it. The client won't see the interceptor.
        throw e.getTargetException();
    }
}

From source file:org.ensembl.gti.seqstore.GeneHashTest.java

@Test
public void testStringHash() {

    String hash1 = SeqStoreHashUtils.hashSequence("ATGTGATAG");
    String hash2 = SeqStoreHashUtils.hashSequence("ATGTGATAG");
    String hash3 = SeqStoreHashUtils.hashSequence("ATGTGATAGC");

    assertFalse("hash1 is empty or null", StringUtils.isEmpty(hash1));
    assertFalse("hash2 is empty or null", StringUtils.isEmpty(hash2));
    assertFalse("hash3 is empty or null", StringUtils.isEmpty(hash3));

    assertEquals("hash1 does not equal hash2", hash1, hash2);
    assertNotEquals("hash1 equals hash3", hash1, hash3);

}