Example usage for org.apache.commons.lang3 StringUtils trimToNull

List of usage examples for org.apache.commons.lang3 StringUtils trimToNull

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils trimToNull.

Prototype

public static String trimToNull(final String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null .

Usage

From source file:com.xylocore.cassandra.query.PagedQueryBuilder.java

/**
 * FILLIN//  ww  w.java 2  s.c  o  m
 * 
 * @param       aColumnName
 * @param       aParameterName
 * 
 * @return
 */
public PagedQueryBuilder<T> keyColumn(String aColumnName, String aParameterName) {
    Validate.notBlank(aColumnName);

    aParameterName = StringUtils.trimToNull(aParameterName);

    if (aParameterName == null) {
        aParameterName = aColumnName;
    }

    keyColumnNames.put(aColumnName, aParameterName);

    return this;
}

From source file:hoot.services.readers.review.ReviewReferencesRetriever.java

/**
 * Retrieves all other unresolved element references to reviews for a given
 * element// ww w. j  a v  a 2 s  .  co m
 * 
 * @param queryElementInfo
 *            element whose review references are to be retrieved
 * @return a list containing all features the input feature needs to be
 *         reviewed with
 */
public List<ReviewRef> getAllReferences(ElementInfo queryElementInfo) {
    logger.debug("requestingElementInfo: {}", queryElementInfo);

    long mapIdNum = MapResource.validateMap(queryElementInfo.getMapId(), connection);

    // check for query element aexistence
    Set<Long> elementIds = new HashSet<>();
    elementIds.add(queryElementInfo.getId());
    if ((StringUtils.trimToNull(queryElementInfo.getType()) == null) || !Element.allElementsExist(mapIdNum,
            Element.elementTypeFromString(queryElementInfo.getType()), elementIds, connection)) {
        ReviewUtils.handleError(new Exception("Element with ID: " + queryElementInfo + " and type: "
                + queryElementInfo.getType() + " does not exist."), "");
    }

    // select all review relation id's from current relation members where
    // member id = requesting element's member id and the element type = the requesting element type
    List<Long> allReviewRelationIds = this.getAllReviewRelations(queryElementInfo, mapIdNum);

    List<ReviewRef> references = new ArrayList<>();
    if (!allReviewRelationIds.isEmpty()) {
        // select all relation members where themember's id is not equal to the requesting element's id and the
        // member's type is not = to the requesting element's type
        List<CurrentRelationMembers> referencedMembers = new SQLQuery<>(connection,
                DbUtils.getConfiguration(mapIdNum)).select(QCurrentRelationMembers.currentRelationMembers)
                        .from(currentRelationMembers)
                        .where(currentRelationMembers.relationId.in(allReviewRelationIds))
                        .orderBy(currentRelationMembers.relationId.asc(), currentRelationMembers.memberId.asc(),
                                currentRelationMembers.sequenceId.asc())
                        .fetch();

        // return all elements corresponding to the filtered down set of relation members
        for (CurrentRelationMembers member : referencedMembers) {
            references.add(new ReviewRef(queryElementInfo.getMapId(), member.getMemberId(),
                    Element.elementTypeForElementEnum(member.getMemberType()).toString().toLowerCase(),
                    member.getRelationId()));
        }
    }

    return references;
}

From source file:alfio.controller.api.AttendeeApiController.java

@RequestMapping(value = "/{eventKey}/sponsor-scan/mine", method = RequestMethod.GET)
public ResponseEntity<List<SponsorAttendeeData>> getScannedBadges(
        @PathVariable("eventKey") String eventShortName,
        @RequestParam(value = "from", required = false) String from, Principal principal) {

    ZonedDateTime start = Optional.ofNullable(StringUtils.trimToNull(from))
            .map(EventUtil.JSON_DATETIME_FORMATTER::parse)
            .flatMap(d -> Wrappers.safeSupplier(() -> ZonedDateTime.of(LocalDateTime.from(d), ZoneOffset.UTC)))
            .orElse(SponsorScanRepository.DEFAULT_TIMESTAMP);
    return attendeeManager.retrieveScannedAttendees(eventShortName, principal.getName(), start)
            .map(ResponseEntity::ok).orElse(notFound());
}

From source file:com.xjl.pt.form.controller.LicenseController.java

/**
 * //w  ww .j  ava  2  s  .  com
 * @return
 */
@ResponseBody
@RequestMapping(value = "/queryForError/{page}/{rows}", method = RequestMethod.GET, consumes = "application/json")
public BootstrapGridTable queryForError(HttpServletRequest request, @PathVariable Integer page,
        @PathVariable Integer rows) {
    String search = StringUtils.trimToNull(request.getParameter("search"));
    List<Licence> list = licenceService.selectAllForError(search, page, rows);
    List<DictItem> itemTypeLicenceItems = this.dictItemService
            .queryByDictId("9b48ca78-6366-4598-8509-64bf26ca3832", 1, 1000);
    for (Licence licence : list) {
        //???
        licence.setLicenceStatus$name(
                DictItemTools.getDictItemNames(licence.getLicenceStatus(), itemTypeLicenceItems));
        //?
        licence.setIssuingDateStr(format.format(licence.getIssuingDate()));
        licence.setExirationDateStr(format.format(licence.getExpirationDate()));
    }
    return BootstrapGridTable.getInstance(list);
}

From source file:hudson.tasks.Ant.java

@DataBoundConstructor
public Ant(String targets, String antName, String antOpts, String buildFile, String properties) {
    this.targets = targets;
    this.antName = antName;
    this.antOpts = StringUtils.trimToNull(antOpts);
    this.buildFile = StringUtils.trimToNull(buildFile);
    this.properties = StringUtils.trimToNull(properties);
}

From source file:io.restassured.path.xml.config.XmlPathConfig.java

private XmlPathConfig(JAXBObjectMapperFactory jaxbObjectMapperFactory, XmlParserType defaultParserType,
        XmlPathObjectDeserializer defaultDeserializer, String charset, Map<String, Boolean> features,
        Map<String, String> declaredNamespaces, Map<String, Object> properties, boolean validating,
        boolean namespaceAware, boolean allowDocTypeDeclaration) {
    charset = StringUtils.trimToNull(charset);
    if (charset == null)
        throw new IllegalArgumentException("Charset cannot be empty");
    this.charset = charset;
    this.defaultDeserializer = defaultDeserializer;
    this.defaultParserType = defaultParserType;
    this.jaxbObjectMapperFactory = jaxbObjectMapperFactory;
    this.features = features;
    this.declaredNamespaces = declaredNamespaces;
    this.properties = properties;
    this.validating = validating;
    this.namespaceAware = namespaceAware;
    this.allowDocTypeDeclaration = allowDocTypeDeclaration;
}

From source file:com.qq.tars.web.controller.server.ServerController.java

@RequestMapping(value = "server/api/inactive_server_list", produces = { "application/json" })
@ResponseBody/*  w w w.  java 2  s  .  co m*/
public List<ServerConfView> inactiveServerList(@RequestParam(required = false) String application,
        @RequestParam(value = "server_name", required = false) String serverName,
        @RequestParam(value = "node_name", required = false) String nodeName,
        @RequestParam(value = "cur_page", required = false, defaultValue = "0") int curPage,
        @RequestParam(value = "page_size", required = false, defaultValue = "0") int pageSize)
        throws Exception {
    application = StringUtils.trimToNull(application);
    serverName = StringUtils.trimToNull(serverName);
    nodeName = StringUtils.trimToNull(nodeName);

    return serverService.queryInactiveServerConfs(application, serverName, nodeName, curPage, pageSize).stream()
            .map(server -> mapper.map(server, ServerConfView.class)).collect(Collectors.toList());
}

From source file:com.qq.tars.service.server.ServerService.java

public List<ServerConf> getServerConf(String treeNodeId, int curPage, int pageSize) {
    ServerConf serverConf = getServerConf4Tree(treeNodeId);

    return serverMapper.getServerConf(StringUtils.trimToNull(serverConf.getApplication()),
            StringUtils.trimToNull(serverConf.getServerName()), "Y".equals(serverConf.getEnableSet()),
            StringUtils.trimToNull(serverConf.getSetName()), StringUtils.trimToNull(serverConf.getSetArea()),
            StringUtils.trimToNull(serverConf.getSetGroup()), new RowBounds(curPage, pageSize));
}

From source file:net.lmxm.ute.resources.ResourcesUtils.java

/**
 * Gets the resource string./*from   w w  w.j  av a2 s.  c  o m*/
 * 
 * @param resourceType the resource type
 * @param suffix the suffix
 * @return the resource string
 */
private static String getResourceString(final ResourceType resourceType, final String suffix) {
    final String key = buildResourcePrefix(resourceType) + suffix;

    return StringUtils.trimToNull(RESOURCE_BUNDLE.getString(key));
}

From source file:hoot.services.review.ReviewTestUtils.java

private static void populateOsmIdMappings(final Document changesetUploadResponse, final ElementType elementType,
        Map<Long, Long> mappings, final int size) throws XPathExpressionException {
    XPath xpath = XmlDocumentBuilder.createXPath();
    mappings.clear();/*from w ww.j av  a 2 s . c o m*/

    //there aren't more than 100 elements of any type in the source file
    for (int i = 1; i < size + 1; i++) {
        final long oldId = -1 * i;
        final String newIdStr = xpath.evaluate("//osm/diffResult/" + elementType.toString().toLowerCase()
                + "[@old_id=\"" + oldId + "\"]/@new_id", changesetUploadResponse);
        if (StringUtils.trimToNull(newIdStr) != null) {
            final long newId = Long.parseLong(newIdStr);
            mappings.put(oldId, newId);
        }
    }
}