List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:com.roncoo.jui.common.dao.impl.ReportDaoImpl.java
@Override public Page<RcReport> listForPage(int currentPage, int numPerPage, String orderField, String orderDirection, RcReport rcReport) {/*ww w .j a v a 2s . c o m*/ RcReportExample example = new RcReportExample(); Criteria c = example.createCriteria(); // if (StringUtils.hasText(rcReport.getUserEmail())) { c.andUserEmailLike(SqlUtil.like(rcReport.getUserEmail())); } // ? StringBuilder orderByClause = new StringBuilder(); if (StringUtils.hasText(orderField)) { orderByClause.append(orderField).append(" ").append(orderDirection).append(", "); } example.setOrderByClause(orderByClause.append("update_time desc").toString()); int totalCount = mapper.countByExample(example); numPerPage = SqlUtil.checkPageSize(numPerPage); currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, currentPage); example.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage)); example.setPageSize(numPerPage); Page<RcReport> page = new Page<RcReport>(totalCount, SqlUtil.countTotalPage(totalCount, numPerPage), currentPage, numPerPage, mapper.selectByExample(example)); page.setOrderField(orderField); page.setOrderDirection(orderDirection); return page; }
From source file:com.ryantenney.metrics.spring.config.ReporterBeanDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { final String metricRegistryRef = element.getAttribute("metric-registry"); if (!StringUtils.hasText(metricRegistryRef)) { parserContext.getReaderContext() .error("Metric-registry id required for element '" + element.getLocalName() + "'", element); return null; }/*w w w .j a v a 2 s.c o m*/ final String type = element.getAttribute("type"); if (!StringUtils.hasText(type)) { parserContext.getReaderContext().error("Type required for element '" + element.getLocalName() + "'", element); return null; } try { for (ReporterElementParser reporterElementParser : reporterElementParserLoader) { if (type.equals(reporterElementParser.getType())) { return reporterElementParser.parseReporter(element, parserContext); } } } catch (ServiceConfigurationError ex) { parserContext.getReaderContext().error("Error loading ReporterElementParsers", element, ex); return null; } parserContext.getReaderContext().error("No ReporterElementParser found for reporter type '" + type + "'", element); return null; }
From source file:org.drools.container.spring.namespace.GridNodeDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(GridNodeBeanFactory.class); String id = element.getAttribute("id"); factory.addPropertyValue("id", id); String connectionRef = element.getAttribute(GRID_ATTRIBUTE); if (StringUtils.hasText(connectionRef)) { factory.addPropertyReference(GRID_ATTRIBUTE, connectionRef); }// w w w . j a va 2 s. c o m for (int i = 0, length = element.getChildNodes().getLength(); i < length; i++) { Node n = element.getChildNodes().item(i); if (n instanceof Element) { Element e = (Element) n; if ("socket-service".equals(e.getLocalName())) { String port = e.getAttribute(PORT_ATTRIBUTE); if (StringUtils.hasText(port)) { factory.addPropertyValue("port", port); } } } } return factory.getBeanDefinition(); }
From source file:org.pidster.mqtt.shell.config.MqttConsolePromptProvider.java
public void onApplicationEvent(ConnectionEvent event) { this.connected = event.isConnected(); this.hostname = event.getHostname(); if (StringUtils.hasText(event.getUsername())) { this.username = event.getUsername(); } else {/* ww w . j ava 2 s . com*/ this.username = "anonymous"; } }
From source file:io.pivotal.spring.xd.jdbcgpfdist.support.GreenplumDataSourceFactoryBean.java
@Override protected BasicDataSource createInstance() throws Exception { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("org.postgresql.Driver"); if (StringUtils.hasText(dbUser)) { ds.setUsername(dbUser);//w ww .ja va 2s . c o m } if (StringUtils.hasText(dbPassword)) { ds.setPassword(dbPassword); } ds.setUrl("jdbc:postgresql://" + dbHost + ":" + dbPort + "/" + dbName); return ds; }
From source file:biz.c24.io.spring.integration.config.XPathSelectorParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String evaluationType = element.getAttribute("evaluation-result-type"); String expression = element.getAttribute("xpath-statement"); String expressionRef = element.getAttribute("xpath-statement-ref"); boolean hasRef = StringUtils.hasText(expressionRef); Assert.isTrue(hasRef ^ StringUtils.hasText(expression), "Exactly one of the 'xpath-statement' or 'xpath-statement-ref' attributes is required."); if (hasRef) { builder.addConstructorArgReference(expressionRef); } else {// ww w . j av a 2s .co m builder.addConstructorArgValue(expression); } String stringTestValue = element.getAttribute("string-test-value"); if (evaluationType.equals("boolean")) { builder.getBeanDefinition() .setBeanClass(biz.c24.io.spring.integration.selector.C24BooleanTestXPathMessageSelector.class); Assert.state(!StringUtils.hasText(stringTestValue), "'string-test-value' should not be specified when 'evaluation-result-type' is boolean"); } else if (evaluationType.equals("string")) { Assert.hasText(stringTestValue, "'string-test-value' must be specified when 'evaluation-result-type' is string"); builder.addPropertyValue("valueToTestFor", stringTestValue); builder.getBeanDefinition().setBeanClass( biz.c24.io.spring.integration.selector.C24StringValueTestXPathMessageSelector.class); } else { throw new IllegalArgumentException("Unsupported value [" + evaluationType + "] for 'evaluation-result-type', expected boolean or string."); } }
From source file:csns.web.validator.DepartmentValidator.java
@Override public void validate(Object target, Errors errors) { Department department = (Department) target; Long id = department.getId(); String name = department.getName(); if (!StringUtils.hasText(name)) errors.rejectValue("name", "error.field.required"); else {//www. j a va 2 s . c o m Department d = departmentDao.getDepartmentByName(name); if (d != null && !d.getId().equals(id)) errors.rejectValue("name", "error.department.name.taken"); } String fullName = department.getFullName(); if (!StringUtils.hasText(fullName)) errors.rejectValue("fullName", "error.field.required"); else { Department d = departmentDao.getDepartmentByFullName(fullName); if (d != null && !d.getId().equals(id)) errors.rejectValue("fullName", "error.department.name.taken"); } String abbreviation = department.getAbbreviation(); if (!StringUtils.hasText(abbreviation)) errors.rejectValue("abbreviation", "error.field.required"); else if (!Pattern.matches("[a-z]+", abbreviation)) errors.rejectValue("abbreviation", "error.department.abbreviation.invalid"); else { Department d = departmentDao.getDepartment(abbreviation); if (d != null && !d.getId().equals(id)) errors.rejectValue("abbreviation", "error.department.abbreviation.taken"); } if (department.getAdministrators().size() == 0) errors.rejectValue("administrators", "error.field.required"); }
From source file:org.openmrs.module.household.model.editor.HouseholdDefinitionParentEditor.java
/** * @should set using id/*from w ww. jav a 2s . com*/ * @should set using uuid */ @Override public void setAsText(String text) throws IllegalArgumentException { HouseholdService hs = Context.getService(HouseholdService.class); if (StringUtils.hasText(text)) { try { setValue(hs.getHouseholdDefinitionParent(Integer.valueOf(text))); } catch (Exception ex) { HouseholdDefinitionParent householdDefinitionParent = hs.getHouseholdDefinitionParent(text); setValue(householdDefinitionParent); if (householdDefinitionParent == null) { log.error("Error setting text: " + text, ex); throw new IllegalArgumentException("Department not found: " + ex.getMessage()); } } } else { setValue(null); } }
From source file:com.consol.citrus.admin.converter.action.SendMessageActionConverter.java
@Override public TestAction convert(SendModel model) { TestAction action = new TestAction(getActionType(), getSourceModelClass()); action.add(property("endpoint", model)); if (model.getMessage() != null) { if (StringUtils.hasText(model.getMessage().getData())) { action.add(new Property("message.data", "message.data", "Message Data", model.getMessage().getData(), false)); }//from w w w . j av a 2 s .com if (model.getMessage().getPayload() != null) { action.add(new Property("message.payload", "message.payload", "Message Payload", PayloadElementParser.parseMessagePayload(model.getMessage().getPayload().getAnies().get(0)), false)); } if (model.getMessage().getResource() != null && StringUtils.hasText(model.getMessage().getResource().getFile())) { action.add(new Property("message.resource", "message.resource", "Message Resource", model.getMessage().getResource().getFile(), false)); } } action.add(property("fork", model, "false").options("true", "false")); action.add(property("actor", "TestActor", model)); return action; }
From source file:org.cloudfoundry.identity.uaa.login.test.ProfileActiveUtils.java
private static List<String> getBlacklist(UnlessProfileActive unlessProfileActive) { List<String> blacklist = new ArrayList<String>(); if (unlessProfileActive != null) { if (StringUtils.hasText(unlessProfileActive.value())) { blacklist.add(unlessProfileActive.value()); }//from ww w.jav a2 s. com if (unlessProfileActive.values() != null) { for (String s : unlessProfileActive.values()) { blacklist.add(s); } } } return blacklist; }