List of usage examples for org.apache.commons.lang3 StringUtils isEmpty
public static boolean isEmpty(final CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
From source file:io.cloudslang.content.httpclient.build.RequestConfigBuilder.java
public RequestConfigBuilder setProxyPort(String proxyPort) { if (!StringUtils.isEmpty(proxyPort)) { this.proxyPort = proxyPort; }/*from w w w . j a v a2s. co m*/ return this; }
From source file:io.federecio.dropwizard.swagger.SwaggerView.java
protected SwaggerView(String urlPattern, String tokenType, String authHeader) { super("index.ftl", Charsets.UTF_8); if (urlPattern.equals("/")) { swaggerAssetsPath = Constants.SWAGGER_URI_PATH; } else {//from ww w . jav a 2 s. c o m swaggerAssetsPath = urlPattern + Constants.SWAGGER_URI_PATH; } if (urlPattern.equals("/")) { contextPath = ""; } else { contextPath = urlPattern; } this.tokenType = !StringUtils.isEmpty(tokenType) && (tokenType.equalsIgnoreCase("header") || tokenType.equalsIgnoreCase("query")) ? tokenType.toLowerCase() : "query"; if (StringUtils.isEmpty(authHeader)) { this.authHeader = "api_key"; } else { this.authHeader = authHeader; } }
From source file:com.glaf.activiti.tasklistener.factory.TaskListenerTypes.java
static Map<String, Class<?>> initializeTaskListenerTypes() { Map<String, Class<?>> types = new java.util.HashMap<String, Class<?>>(); String resource = SystemProperties.getString("activiti.taskListeners"); if (StringUtils.isEmpty(resource)) { resource = DEFAULT_CONFIG;/* w w w . jav a2 s.c om*/ } if (StringUtils.isNotEmpty(resource)) { InputStream taskTypesStream = PropertiesUtils.getInputStream(resource); Element listenersElement = XmlUtils.parseXmlInputStream(taskTypesStream).getDocumentElement(); Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(listenersElement, "taskListeners"); while (nodeTypeIterator.hasNext()) { Element nodeTypeElement = (Element) nodeTypeIterator.next(); String elementTag = nodeTypeElement.getAttribute("element"); String className = nodeTypeElement.getAttribute("class"); try { Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className); types.put(elementTag, clazz); } catch (Exception ex) { ex.printStackTrace(); logger.error("node '" + elementTag + "' will not be available. class '" + className + "' couldn't be loaded"); } } } String ext_resource = CustomProperties.getString("activiti.taskListeners"); if (StringUtils.isNotEmpty(ext_resource)) { InputStream typesStream = PropertiesUtils.getInputStream(resource); Element listenersElement = XmlUtils.parseXmlInputStream(typesStream).getDocumentElement(); Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(listenersElement, "taskListener"); while (nodeTypeIterator.hasNext()) { Element nodeTypeElement = (Element) nodeTypeIterator.next(); String elementTag = nodeTypeElement.getAttribute("element"); String className = nodeTypeElement.getAttribute("class"); try { Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className); types.put(elementTag, clazz); } catch (Exception ex) { ex.printStackTrace(); logger.error("node '" + elementTag + "' will not be available. class '" + className + "' couldn't be loaded"); } } } return types; }
From source file:com.adobe.acs.commons.replication.packages.automatic.model.AutomaticPackageReplicatorModel.java
public String getEventTopic() { String topic = properties.get("eventTopic", String.class); if (StringUtils.isEmpty(topic)) { return null; } else {//from w w w . j a v a 2 s.c o m return topic; } }
From source file:com.cognifide.aet.cleaner.validation.CleanerSchedulerValidator.java
private void validateSchedule(ValidationResultBuilder validationResultBuilder) { if (StringUtils.isEmpty(schedule)) { validationResultBuilder.addErrorMessage("CRON expression may not be empty"); }/*from w w w. ja va2s. c o m*/ }
From source file:com.huangyunkun.jviff.service.WebDriverManager.java
public static void setFirefoxPath(String firefoxPath) { if (!StringUtils.isEmpty(firefoxPath)) { System.setProperty("webdriver.firefox.bin", firefoxPath); }//w ww .ja v a 2 s . c om }
From source file:com.mirth.connect.client.ui.ImageCellRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { setForeground(table.getSelectionForeground()); super.setBackground(table.getSelectionBackground()); } else {/* www. ja v a 2 s . c om*/ setForeground(table.getForeground()); setBackground(table.getBackground()); } // MIRTH-2186 Java sometimes calls this method with a hard-coded null value so tablecellrenderers must explicitly check for null. // Only observed so far on Mac OSX. // http://stackoverflow.com/questions/3054775/java-swing-jtable-strange-behavior-from-getaccessiblechild-method-resulting if (value != null) { CellData data = (CellData) value; setText(data.getText()); setIcon(data.getIcon()); setHorizontalAlignment(LEFT); if (data.getIcon() == null && StringUtils.isEmpty(data.getText())) { setHorizontalAlignment(CENTER); setText("--"); } } return this; }
From source file:com.msopentech.odatajclient.engine.V4ServiceDocumentOfflineTest.java
@Test public void serviceDocumentV4Test() { AbstractServiceDocument doc = ODataClientFactory.getV4().getReader().readServiceDocument( getClass().getResourceAsStream("v4/exchange-service-document.xml"), ODataFormat.XML); assertEquals("https://outlook.office365.com/EWS/OData/$metadata", doc.getMetadataContext()); assertEquals(1, doc.getEntitySets().size()); assertEquals(1, doc.getSingletons().size()); assertEquals(0, doc.getFunctionImports().size()); assertEquals(0, doc.getRelatedServiceDocuments().size()); assertTrue(StringUtils.isEmpty(doc.getMetadataETag())); }
From source file:com.sunsprinter.diffunit.core.injection.Injector.java
protected void inject(final Class<?> currentClass, final Class<?> testClass, final Object test) throws DiffUnitInjectionException { if (currentClass != Object.class) { for (final Field field : currentClass.getDeclaredFields()) { final DiffUnitInject annotation = field.getAnnotation(DiffUnitInject.class); if (annotation != null) { final Object key = StringUtils.isEmpty(annotation.objectId()) ? field.getType() : annotation.objectId(); final boolean fieldAccessible = field.isAccessible(); try { field.setAccessible(true); field.set(test, getInjectionMap().get(key)); } catch (final Exception e) { throw new DiffUnitInjectionException(String.format( "DiffUnit unable to inject field '%s' of class '%s' on test of class '%s'. " + "Component key is '%s'. Target field type is '%s'.", field.getName(), currentClass.getName(), testClass.getName(), key, field.getType().getName()), e); } finally { field.setAccessible(fieldAccessible); }//w ww . j a v a 2 s . com } } inject(currentClass.getSuperclass(), testClass, test); } }
From source file:com.kumarvv.setl.utils.SqlRunner.java
/** * retrieves single value from datasource * * @param sql//from w ww .ja va 2 s .c o m * @param ds * @return */ public Object getSingleValue(String sql, DS ds) { if (StringUtils.isEmpty(sql)) { return null; } try (JdbcRowSet jrs = rowSetUtil.getRowSet(ds)) { jrs.setCommand(sql); jrs.execute(); if (jrs.next()) { return jrs.getObject(1); } } catch (Exception e) { return null; } return null; }