Available Methods
- isBlank ( )
- isEmpty ( )
- isNotBlank ( )
- isNotEmpty ( )
- equals ( )
- join ( )
- EMPTY
- split ( )
- trimToNull ( )
- equalsIgnoreCase ( )
- contains ( )
- replace ( )
- trimToEmpty ( )
- isNumeric ( )
- capitalize ( )
- defaultString ( )
- startsWith ( )
- substringAfter ( )
- trim ( )
- isNoneBlank ( )
- containsIgnoreCase ( )
- substringBefore ( )
- substringAfterLast ( )
- removeEnd ( )
- repeat ( )
- leftPad ( )
- lowerCase ( )
- countMatches ( )
- substring ( )
- isNoneEmpty ( )
- endsWith ( )
- startsWithIgnoreCase ( )
- stripEnd ( )
- replaceEach ( )
- abbreviate ( )
- defaultIfBlank ( )
- splitByWholeSeparator ( )
- uncapitalize ( )
- strip ( )
- rightPad ( )
- substringBeforeLast ( )
- defaultIfEmpty ( )
- substringBetween ( )
- length ( )
- removeStart ( )
- remove ( )
- isAnyEmpty ( )
- replaceChars ( )
- indexOf ( )
- isAnyBlank ( )
- joinWith ( )
- containsAny ( )
- replaceOnce ( )
- endsWithIgnoreCase ( )
- splitByWholeSeparatorPreserveAllTokens ( )
- splitPreserveAllTokens ( )
- startsWithAny ( )
- deleteWhitespace ( )
- appendIfMissing ( )
- compare ( )
- normalizeSpace ( )
- stripStart ( )
- replaceAll ( )
- lastIndexOf ( )
- equalsAnyIgnoreCase ( )
- stripToNull ( )
- upperCase ( )
- splitByCharacterTypeCamelCase ( )
- left ( )
- reverse ( )
- isAlphanumeric ( )
- center ( )
- isAsciiPrintable ( )
- chomp ( )
- getLevenshteinDistance ( )
- indexOfIgnoreCase ( )
- chop ( )
- equalsAny ( )
- isAllLowerCase ( )
- ordinalIndexOf ( )
- replacePattern ( )
- removeEndIgnoreCase ( )
- containsNone ( )
- isAllBlank ( )
- truncate ( )
- isAllEmpty ( )
- difference ( )
- stripAll ( )
- right ( )
- stripAccents ( )
- containsWhitespace ( )
- endsWithAny ( )
- isWhitespace ( )
- removeStartIgnoreCase ( )
- replaceIgnoreCase ( )
- indexOfAnyBut ( )
- swapCase ( )
- substringsBetween ( )
- wrap ( )
- toCodePoints ( )
- wrapIfMissing ( )
- isAllUpperCase ( )
- isAlpha ( )
- reverseDelimited ( )
- toEncodedString ( )
- compareIgnoreCase ( )
- containsOnly ( )
- removeFirst ( )
Related Classes
- java.util.Arrays
- java.io.File
- java.util.Collections
- java.io.InputStream
- java.util.Date
- java.util.Iterator
- java.util.concurrent.TimeUnit
- java.util.regex.Pattern
- java.net.URL
- java.io.FileInputStream
- java.text.SimpleDateFormat
- java.util.Locale
- java.lang.reflect.Method
- java.util.regex.Matcher
- java.util.Properties
- java.util.UUID
- java.util.stream.Collectors
- java.util.LinkedHashMap
- java.util.Objects
- java.nio.charset.Charset
- java.net.URI
- java.util.Map.Entry
- java.nio.file.Files
- java.util.Optional
- java.nio.charset.StandardCharsets
Java Code Examples for org.apache.commons.lang3.StringUtils#wrapIfMissing()
The following examples show how to use
org.apache.commons.lang3.StringUtils#wrapIfMissing() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryDescriptor.java From bird-java with MIT License | 5 votes |
public static QueryDescriptor parseClass(Class<?> tClass) { Map<String, String> fieldMap = new HashMap<>(16); if (tClass == null) return null; Class tempClass = tClass; StringBuilder sb = new StringBuilder(); while (tempClass != null && !StringUtils.equals(tempClass.getName(), OBJECT_CLASS_NAME)) { Field[] tempFields = tempClass.getDeclaredFields(); for (Field field : tempFields) { if(EXCLUDE_FIELD_NAMES.contains(field.getName()))continue; TableField tableField = field.getAnnotation(TableField.class); if (tableField != null && !tableField.exist()) continue; String fieldName = StringUtils.wrapIfMissing(field.getName(), '`'); String dbFieldName = getDbFieldName(field); fieldMap.putIfAbsent(fieldName, dbFieldName); } tempClass = tempClass.getSuperclass(); } for (Map.Entry<String, String> entry : fieldMap.entrySet()) { sb.append(entry.getValue()); sb.append(" AS "); sb.append(entry.getKey()); sb.append(","); } String select = StringUtils.stripEnd(sb.toString(), ","); String from = ""; TableName tableName = tClass.getAnnotation(TableName.class); if (tableName != null) { from = tableName.value(); } return new QueryDescriptor(select, from, fieldMap); }
Example 2
Source File: QueryDescriptor.java From bird-java with MIT License | 5 votes |
public static String getDbFieldName(Field field) { TableField tableField = field.getAnnotation(TableField.class); String dbFieldName = tableField == null ? field.getName() : tableField.value(); if (StringUtils.startsWith(dbFieldName, "{") && StringUtils.endsWith(dbFieldName, "}")) { dbFieldName = StringUtils.removeStart(dbFieldName, "{"); dbFieldName = StringUtils.removeEnd(dbFieldName, "}"); } else { dbFieldName = StringUtils.wrapIfMissing(dbFieldName, '`'); } return dbFieldName; }
Example 3
Source File: QueryDescriptor.java From bird-java with MIT License | 5 votes |
String getDbFieldName(String field) { String emptyField = "''"; String dbDelimiter = "."; if (StringUtils.isBlank(field)) return emptyField; if (field.contains(dbDelimiter)) return field; String fieldName = StringUtils.wrapIfMissing(field, '`'); return this.fieldMap.getOrDefault(fieldName, fieldName); }
Example 4
Source File: FilterGroup.java From bird-java with MIT License | 4 votes |
private String formatRules(List<FilterRule> rules, Map<String, String> fieldNameMap) { if (CollectionUtils.isEmpty(rules)) return StringUtils.EMPTY; StringBuilder sb = new StringBuilder(); boolean isStart = true; for (FilterRule rule : rules) { if (rule == null) continue; String field = StringUtils.strip(rule.getField()); String value = StringUtils.strip(rule.getValue()); if (StringUtils.isBlank(field) || StringUtils.isBlank(value)) continue; if (!isStart) { sb.append(" and "); } FilterOperate ruleOperate = FilterOperate.resolve(rule.getOperate()); if (ruleOperate == null) { ruleOperate = FilterOperate.EQUAL; } String dbFieldName = this.getDbFieldName(fieldNameMap, field); if (ruleOperate == FilterOperate.IN) { sb.append(String.format("FIND_IN_SET(%s,%s)", dbFieldName, StringUtils.wrapIfMissing(StringUtils.strip(value, ","), "'"))); } else { switch (ruleOperate) { case START_WITH: value = value + "%"; break; case END_WITH: value = "%" + value; break; case CONTAINS: value = "%" + value + "%"; break; default: break; } value = StringUtils.wrapIfMissing(value, "'"); sb.append(dbFieldName).append(" ").append(ruleOperate.getDbValue()).append(" ").append(value); } isStart = false; } String where = sb.toString(); return StringUtils.isNotBlank(where) ? "(" + where + ")" : where; }