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:com.developmentsprint.spring.breaker.interceptor.AopAllianceInvoker.java

public CircuitBreakerAttribute getCircuitBreakerAttribute() {
    DefaultCircuitBreakerAttribute cbAttr;
    if (circuitBreakerAttribute instanceof DefaultCircuitBreakerAttribute) {
        cbAttr = (DefaultCircuitBreakerAttribute) circuitBreakerAttribute;
    } else {/*from  w  w w  .j a v a2 s  .  c o  m*/
        cbAttr = new DefaultCircuitBreakerAttribute(circuitBreakerAttribute);
    }
    if (StringUtils.isEmpty(cbAttr.getName())) {
        StringBuilder args = new StringBuilder();
        if (arguments != null && arguments.length > 0) {
            for (Object arg : arguments) {
                args.append(arg.getClass().getName()).append(", ");
            }
            args.setLength(args.length() - 2);
        }
        String fullSignature = targetClass.getName() + "." + method.getName() + "(" + args + ")";
        cbAttr.setName(fullSignature);
    }
    return cbAttr;
}

From source file:io.syndesis.inspector.JsonSchemaInspector.java

@Override
public boolean supports(final String kind, final String type, final String specification,
        final Optional<byte[]> exemplar) {
    return "json-schema".equals(kind) && !StringUtils.isEmpty(specification);
}

From source file:com.ocs.dynamo.importer.impl.BaseImporter.java

@SuppressWarnings("unchecked")
private Object getFieldValue(PropertyDescriptor d, U unit, XlsField field) {
    Object obj = null;/*from  w  ww.j a v  a2 s  . c  o  m*/
    if (String.class.equals(d.getPropertyType())) {
        String value = getStringValueWithDefault(unit, field);
        if (value != null) {
            value = value.trim();
        }
        obj = StringUtils.isEmpty(value) ? null : value;
    } else if (d.getPropertyType().isEnum()) {
        String value = getStringValueWithDefault(unit, field);
        if (value != null) {
            value = value.trim();
            try {
                obj = Enum.valueOf(d.getPropertyType().asSubclass(Enum.class), value.toUpperCase());
            } catch (IllegalArgumentException ex) {
                throw new OCSImportException(
                        "Value " + value + " cannot be translated to a valid enumeration value", ex);
            }
        }

    } else if (Number.class.isAssignableFrom(d.getPropertyType())) {
        // numeric field

        Double value = getNumericValueWithDefault(unit, field);
        if (value != null) {

            // if the field represents a percentage but it is
            // received as a
            // fraction, we multiply it by 100
            if (field.percentage()) {
                if (isPercentageCorrectionSupported()) {
                    value = PERCENTAGE_FACTOR * value;
                }
            }

            // illegal negative value
            if (field.cannotBeNegative() && value < 0.0) {
                throw new OCSImportException(
                        "Negative value " + value + " found for field '" + d.getName() + "'");
            }

            if (Integer.class.equals(d.getPropertyType())) {
                obj = new Integer(value.intValue());
            } else if (BigDecimal.class.equals(d.getPropertyType())) {
                obj = BigDecimal.valueOf(value.doubleValue());
            } else {
                // by default, use a double
                obj = value;
            }
        }
    } else if (Boolean.class.isAssignableFrom(d.getPropertyType())) {
        return getBooleanValueWithDefault(unit, field);
    }
    return obj;
}

From source file:org.trustedanalytics.kafka.adminapi.api.ApiController.java

@RequestMapping(method = RequestMethod.POST, value = "/topics", consumes = "application/json")
@ResponseStatus(HttpStatus.CREATED)/*from  w  w w  .j a  v a 2s  .co  m*/
public void createTopic(@RequestBody TopicDescription topicDescription) {
    LOG.info("createTopic invoked: {}", topicDescription);

    if (StringUtils.isEmpty(topicDescription.getTopic())) {
        throw new InvalidTopicException("Missing mandatory topic name");
    }
    Topic.validate(topicDescription.getTopic());

    if (topicDescription.getPartitions() <= 0) {
        throw new InvalidTopicException("Number of partitions must be larger than 0");
    }

    kafkaService.createTopic(topicDescription);
}

From source file:de.dlopes.stocks.facilitator.services.impl.FinanznachrichtenOrderbuchExtractorImpl.java

@Override
public List<String> getFinanceData(String url, FinanceDataType dataType) {

    List<String> list = new ArrayList<String>();

    try {// ww w . j  a  v  a  2 s.  c  o  m

        Document doc = null;
        if (url.startsWith("file://")) {
            File input = new File(url.replaceFirst("file://", ""));
            doc = Jsoup.parse(input, "UTF-8");
        } else {
            URL input = new URL(url);
            doc = Jsoup.parse(input, 30000);
        }

        Elements elements = doc.body().select("span[id^=productid] > span");

        for (Element e : elements) {
            String text = e.text();

            // Guard: move on when the text is empty
            if (StringUtils.isEmpty(text)) {
                continue;
            }

            text = StringUtils.trimAllWhitespace(text);

            // Guard: move on when the text does not contain the ISIN or WKN
            if (!text.startsWith(dataType.name() + ":")) {
                continue;
            }

            text = text.replace(dataType.name() + ":", "");
            list.add(text);

        }

    } catch (IOException e) {
        e.printStackTrace();
    }

    return list;

}

From source file:au.com.ors.rest.dao.JobAppDAO.java

@PostConstruct
public void init() throws DAOException, ParserConfigurationException, SAXException, IOException {
    if (servletContext == null) {
        throw new DAOException(
                "Cannot autowire ServletContext to JobAppDAO when injecting JobAppDAO into JobAppController: NullPointerException");
    }// ww w .j a  v a  2 s. co  m

    // get jobposting data file path
    String dataPath = dataProperties.getProperty("data.jobapp.path");
    dataUrl = servletContext.getRealPath("/WEB-INF/db/" + dataPath);
    System.out.println("jobapp_db_path=" + dataUrl);
    if (StringUtils.isEmpty(dataUrl)) {
        throw new DAOException("Cannot find data.jobappdata.path in properties file.");
    }

    File jobPostingDataFile = new File(dataUrl);
    if (!jobPostingDataFile.exists()) {
        throw new DAOLoadingXmlFileException("Cannot load job application XML file from path " + dataUrl);
    }

    // Make an instance of the DocumentBuilderFactory
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

    DocumentBuilder db;

    db = dbf.newDocumentBuilder();
    dom = db.parse(dataUrl);

    Element root = dom.getDocumentElement();
    NodeList nodeList = root.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); ++i) {
        Node node = nodeList.item(i);
        if (!node.getNodeName().equalsIgnoreCase("JobApplication")) {
            continue;
        }

        JobApplication app = new JobApplication();
        NodeList jobAppInfoList = node.getChildNodes();

        for (int j = 0; j < jobAppInfoList.getLength(); ++j) {
            Node current = jobAppInfoList.item(j);

            // load list
            if (current.getNodeType() == Node.ELEMENT_NODE) {
                String content = current.getTextContent();
                if (current.getNodeName().equals("_appId")) {
                    app.set_appId(content);
                } else if (current.getNodeName().equals("_jobId")) {
                    app.set_jobId(content);
                } else if (current.getNodeName().equals("driverLicenseNumber")) {
                    app.setDriverLicenseNumber(content);
                } else if (current.getNodeName().equals("fullName")) {
                    app.setFullName(content);
                } else if (current.getNodeName().equals("postCode")) {
                    app.setPostCode(content);
                } else if (current.getNodeName().equals("textCoverLetter")) {
                    app.setTextCoverLetter(content);
                } else if (current.getNodeName().equals("textBriefResume")) {
                    app.setTextBriefResume(content);
                } else if (current.getNodeName().equals("status")) {
                    app.setStatus(content);
                }
            }
        }

        if (!StringUtils.isEmpty(app.get_appId())) {
            jobAppList.add(app);
        }
    }

    System.out.println(
            "================================== print all job applications ==================================");
    for (JobApplication app : jobAppList) {
        System.out.println(app.toString());
    }
    System.out.println(
            "================================== print all job applications end ==================================");
}

From source file:$.UserRepositoryImpl.java

@Override
    public UserDTO loadUserByUsername(final String username) throws Exception {
        final StringBuilder queryString = new StringBuilder();
        if (!StringUtils.isEmpty(username)) {
            queryString.append("select user from UserDTO user where user.username='").append(username).append("'");
            final QueryJpaCallback<UserDTO> query = new QueryJpaCallback<UserDTO>(queryString.toString(), false);
            List<UserDTO> list = retrieveList(query);

            if (list != null && list.size() > 0) {
                return list.get(0);
            }//from   ww w.j  av  a  2  s  .  c o m
        }
        return null;
    }

From source file:org.psikeds.resolutionengine.rules.RuleStack.java

public Rule removeRule(final String rid) {
    return (StringUtils.isEmpty(rid) ? null : this.remove(rid));
}

From source file:com.handu.open.dubbo.monitor.domain.DubboInvoke.java

public String getType() {
    if (StringUtils.isEmpty(type)) {
        return "provider";
    }
    return type;
}