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:org.nekorp.workflow.desktop.servicio.bridge.customers.DomicilioFiscalBridge.java

private String getEmptyAsNull(String value) {
    if (StringUtils.isEmpty(value)) {
        return null;
    } else {/*from  w w w.j a v  a2s  .  co m*/
        return value;
    }
}

From source file:org.carewebframework.cal.api.documents.Document.java

public Collection<String> getTypes() {
    if (types == null) {
        types = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        CodeableConceptDt dt = reference.getType();
        List<CodingDt> codings = dt == null ? null : dt.getCoding();

        if (codings != null) {
            for (CodingDt coding : codings) {
                String type = coding.getDisplay().toString();

                if (!StringUtils.isEmpty(type)) {
                    types.add(type);/*w  ww .  j a  v  a2s  .  c o  m*/
                }
            }

        }
    }

    return types;
}

From source file:com.github.hateoas.forms.spring.AffordanceBuilderFactory.java

@Override
public AffordanceBuilder linkTo(final Class<?> controller, final Method method, final Object... parameters) {

    String pathMapping = MAPPING_DISCOVERER.getMapping(controller, method);
    MethodParameters mparameters = new MethodParameters(method);
    Map<String, ActionInputParameter> requestParams = ActionDescriptorBuilder.getRequestParams(mparameters,
            parameters);/*from  w w  w .  j  a v a  2 s.c o m*/
    final Set<String> params = requestParams.keySet();
    String query = join(params);
    String mapping = StringUtils.isEmpty(query) ? pathMapping : pathMapping + "{?" + query + "}";

    PartialUriTemplate partialUriTemplate = new PartialUriTemplate(
            AffordanceBuilder.getBuilder().build().toString() + mapping);

    Map<String, Object> values = new HashMap<String, Object>();

    Iterator<String> names = partialUriTemplate.getVariableNames().iterator();
    // there may be more or less mapping variables than arguments
    for (Object parameter : parameters) {
        if (!names.hasNext()) {
            break;
        }
        values.put(names.next(), parameter);
    }

    ActionDescriptor actionDescriptor = ActionDescriptorBuilder.createActionDescriptor(mparameters, method,
            values, parameters, requestParams);

    if (paramsOnBody && !Affordance.isSafe(actionDescriptor.getHttpMethod())) {
        partialUriTemplate = new PartialUriTemplate(
                AffordanceBuilder.getBuilder().build().toString() + pathMapping);
    }

    return new AffordanceBuilder(partialUriTemplate.expand(values),
            Collections.singletonList(actionDescriptor));
}

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

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

From source file:org.apereo.lap.dao.RiskConfidenceRepositoryImpl.java

public List<RiskConfidence> findByUserCourseDate(final String user, final String course) {

    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<RiskConfidence> criteria = builder.createQuery(RiskConfidence.class);
    Root<RiskConfidence> root = criteria.from(RiskConfidence.class);
    EntityType<RiskConfidence> type = entityManager.getMetamodel().entity(RiskConfidence.class);
    criteria.orderBy(builder.desc(root.get("dateCreated")));

    List<RiskConfidence> lastRiskConfidences = entityManager.createQuery(criteria).setFirstResult(0)
            .setMaxResults(1).getResultList();

    if (lastRiskConfidences == null || lastRiskConfidences.isEmpty()) {
        logger.warn("No risk confidence records found");
        return new ArrayList<RiskConfidence>();
    }/*w  w w  . j  a va2 s  .c  o  m*/

    RiskConfidence lastRickConfidence = lastRiskConfidences.get(0);

    builder = entityManager.getCriteriaBuilder();
    criteria = builder.createQuery(RiskConfidence.class);
    root = criteria.from(RiskConfidence.class);
    type = entityManager.getMetamodel().entity(RiskConfidence.class);

    Predicate groupPredicate = builder.equal(root.get("groupId"), lastRickConfidence.getGroupId());

    if (!StringUtils.isEmpty(user) && !StringUtils.isEmpty(course)) {
        criteria.where(groupPredicate,
                builder.equal(
                        builder.lower(
                                root.get(type.getDeclaredSingularAttribute("alternativeId", String.class))),
                        user.toLowerCase()),
                builder.equal(
                        builder.lower(root.get(type.getDeclaredSingularAttribute("courseId", String.class))),
                        course.toLowerCase()));
    } else if (!StringUtils.isEmpty(user)) {
        criteria.where(groupPredicate,
                builder.equal(
                        builder.lower(
                                root.get(type.getDeclaredSingularAttribute("alternativeId", String.class))),
                        user.toLowerCase()));
    } else if (!StringUtils.isEmpty(course)) {
        criteria.where(groupPredicate,
                builder.equal(
                        builder.lower(root.get(type.getDeclaredSingularAttribute("courseId", String.class))),
                        course.toLowerCase()));
    } else {
        criteria.where(groupPredicate);
    }

    return entityManager.createQuery(criteria).getResultList();
}

From source file:io.fabric8.spring.cloud.kubernetes.config.SecretsPropertySource.java

private static String getApplicationNamespace(KubernetesClient client, SecretsConfigProperties config) {
    String namespace = config.getNamespace();
    if (StringUtils.isEmpty(namespace)) {
        LOGGER.debug("Secret namespace has not been set, taking it from client (ns={})", client.getNamespace());

        namespace = client.getNamespace();
    }//from  ww w . j  a va  2  s.co m

    return namespace;
}

From source file:org.spring.data.gemfire.cache.execute.RegionFunctions.java

protected Region getRegion(final FunctionContext context, final String regionNamePath) {
    Region region = (context instanceof RegionFunctionContext ? ((RegionFunctionContext) context).getDataSet()
            : null);/*from   w  ww  . j  a  v a 2 s. com*/

    if (region == null && !StringUtils.isEmpty(regionNamePath)) {
        region = CacheFactory.getAnyInstance().getRegion(regionNamePath);
    }

    if (region == null && context.getArguments() instanceof String) {
        region = CacheFactory.getAnyInstance().getRegion(context.getArguments().toString());
    }

    return region;
}

From source file:com.krypc.hl.pr.controller.PatientRecordController.java

@RequestMapping(value = "/deployChaincode", method = { RequestMethod.POST, RequestMethod.GET })
public ResponseWrapper deployChaincode(HttpServletRequest request, HttpServletResponse response) {
    logger.info("PatientRecordController---deployChaincode()--STARTS");
    ResponseWrapper wrapper = new ResponseWrapper();
    String data = request.getParameter("data");
    try {//from  w  w w .j a  v a2 s.  c  om
        if (data != null && !data.isEmpty()) {
            JSONObject deploymentData = (JSONObject) new JSONParser().parse(data);
            String path = ((String) deploymentData.get("path"));
            String user = ((String) deploymentData.get("user"));
            if (!StringUtils.isEmpty(path) && !StringUtils.isEmpty(user)) {
                DeployRequest deployrequest = new DeployRequest();
                deployrequest.setChaincodePath(path);//comment for devmode : uncomment for production
                //deployrequest.setChaincodePath("");//uncomment for devmode : comment for production
                deployrequest.setArgs(new ArrayList<>(Arrays.asList("init")));
                Member member = peerMembershipServicesAPI.getChain().getMember(user);
                if (!member.isEnrolled()) {
                    RegistrationRequest registrationRequest = new RegistrationRequest();
                    registrationRequest.setEnrollmentID(user);
                    registrationRequest.setAffiliation("bank_a");
                    member = peerMembershipServicesAPI.getChain().registerAndEnroll(registrationRequest);
                }
                deployrequest.setChaincodeName("PatientRecord");//uncomment for devmode : comment for production
                //deployrequest.setChaincodeName("");//comment for devmode : uncomment for production
                deployrequest.setChaincodeLanguage(ChaincodeLanguage.JAVA);
                deployrequest.setConfidential(false);
                ChainCodeResponse chaincoderesponse = member.deploy(deployrequest);
                utils.storeChaincodeName(chaincoderesponse);
                wrapper.resultObject = chaincoderesponse;
            } else {
                wrapper.setError(ERROR_CODES.MANDATORY_FIELDS_MISSING);
            }
        } else {
            wrapper.setError(ERROR_CODES.MANDATORY_FIELDS_MISSING);
        }
    } catch (Exception e) {
        wrapper.setError(ERROR_CODES.INTERNAL_ERROR);
        logger.error("PatientRecordController---deployChaincode()--ERROR " + e);
    }
    logger.info("PatientRecordController---deployChaincode()--ENDS");
    return wrapper;
}

From source file:com.biz.report.service.impl.RepReportServiceImpl.java

public List<Report2DataSet> readDataForPieChart(String reps, String year, String months) {
    if (!StringUtils.isEmpty(reps) && reps.contains("[")) {
        reps = reps.substring(1, reps.length() - 1);
    }/*w  w  w. j  a  v a  2s .  c om*/
    if (!StringUtils.isEmpty(months) && months.contains("[")) {
        months = months.substring(1, months.length() - 1);
    }
    List list = repReportDao.readByMonth(reps, months, year);
    List<Report2> reportList = new MappingEngine().getPieChartReport(list);
    List<Report2DataSet> dataSets = new ArrayList<Report2DataSet>();
    for (Report2 r : reportList) {
        dataSets.add(new Report2DataSet(r.getTypeName(), r.getAmount()));
    }
    return dataSets;
}

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

/**
 * Reads a String value from a unit (and falls back to a default if needed)
 * /*w w  w.j  a va2 s  . c om*/
 * @param unit
 *            the unit (cell or string value) to read from
 * @param field
 *            the field definition (contains a default value)
 */
@Override
protected String getStringValueWithDefault(String unit, XlsField field) {
    String result = unit;
    if (StringUtils.isEmpty(result) && !StringUtils.isEmpty(field.defaultValue())) {
        result = field.defaultValue();
    }
    return result;
}