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

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

Introduction

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

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters.

null s are handled without exceptions.

Usage

From source file:models.base.ViewModel.java

@Override
public boolean equals(Object obj) {
    if (obj instanceof ViewModel) {
        return StringUtils.equals(this.type, ((ViewModel) obj).type);
    }//from   www .  j  av a  2s . com

    return super.equals(obj);
}

From source file:com.mirth.connect.plugins.datatypes.ncpdp.NCPDPReference.java

public String getCodeByName(String description, String version) {
    if (StringUtils.equals(version, VERSION_D0)) {
        for (String key : NCPDPD0map.keySet()) {
            if (NCPDPD0map.get(key).equals(description)) {
                return key;
            }/*from  w  w w. ja v  a  2  s  . c  o m*/
        }
    } else {
        for (String key : NCPDP51map.keySet()) {
            if (NCPDP51map.get(key).equals(description)) {
                return key;
            }
        }
    }

    return description;
}

From source file:io.wcm.testing.mock.aem.MockComponentManagerTest.java

@Test
public void testGetComponent() {
    Component component = underTest.getComponent("/apps/app1/components/c1");

    assertNotNull(component);/*from  w w w . j  a v a 2  s.  c  om*/
    assertEquals("/apps/app1/components/c1", component.getPath());
    assertEquals("c1", component.getName());
    assertEquals("myTitle", component.getTitle());
    assertEquals("myDescription", component.getDescription());
    assertEquals("myTitle", component.getProperties().get(JcrConstants.JCR_TITLE, String.class));
    assertTrue(StringUtils.isEmpty(component.getResourceType())
            || StringUtils.equals(JcrConstants.NT_UNSTRUCTURED, component.getResourceType()));
    assertTrue(component.isAccessible());
    assertNotNull(component.adaptTo(Resource.class));
    assertEquals("myGroup", component.getComponentGroup());
    assertTrue(component.noDecoration());
    assertEquals("myTag", component.getHtmlTagAttributes().get(NameConstants.PN_TAG_NAME));
    assertEquals("myValue2", component.getHtmlTagAttributes().get("prop2"));
}

From source file:controllers.modules.SetCoverBuilder.java

@Override
public String getRoute() {
    DocumentSetCoverModel setCoverVM = this.findViewModel(DocumentSetCoverModel.class,
            new DocumentSetCoverModel());
    DocumentCorpusModel corpusVM = this.findViewModel(DocumentCorpusModel.class,
            Lists.<ViewModel>newArrayList(setCoverVM));

    if (corpusVM instanceof DocumentSetCoverModel) {
        DocumentSetCoverModel tmpVM = (DocumentSetCoverModel) corpusVM;
        if (tmpVM.baseCorpus != null && setCoverVM.id != null
                && StringUtils.equals(tmpVM.baseCorpus.id, setCoverVM.id)) {
            corpusVM = new DocumentCorpusModel();
            setCoverVM = tmpVM;//  www. java  2  s. c om
        }
    } else if (corpusVM == null) {
        corpusVM = this.findViewModel(DocumentCorpusModel.class);
        setCoverVM = new DocumentSetCoverModel();
    }

    return controllers.modules.routes.SetCoverBuilder
            .modulePage(corpusVM.getIdentifier(), setCoverVM.getIdentifier(), false).url();
}

From source file:com.glaf.dts.util.XmlReader.java

public DataTransfer read(java.io.InputStream inputStream) {
    DataTransfer tableModel = new DataTransfer();
    SAXReader xmlReader = new SAXReader();
    try {//from w ww.ja va2s. c  om
        Document doc = xmlReader.read(inputStream);
        Element root = doc.getRootElement();
        Element element = root.element("entity");
        if (element != null) {
            List<?> attrs = element.attributes();
            if (attrs != null && !attrs.isEmpty()) {
                Map<String, Object> dataMap = new java.util.HashMap<String, Object>();
                Iterator<?> iter = attrs.iterator();
                while (iter.hasNext()) {
                    Attribute attr = (Attribute) iter.next();
                    dataMap.put(attr.getName(), attr.getStringValue());
                    tableModel.addProperty(attr.getName(), attr.getStringValue());
                }
                Tools.populate(tableModel, dataMap);
            }

            tableModel.setEntityName(element.attributeValue("name"));
            tableModel.setPrimaryKey(element.attributeValue("primaryKey"));
            tableModel.setTableName(element.attributeValue("table"));
            tableModel.setTitle(element.attributeValue("title"));
            tableModel.setStopWord(element.attributeValue("stopWord"));
            tableModel.setPackageName(element.attributeValue("package"));
            tableModel.setEnglishTitle(element.attributeValue("englishTitle"));
            tableModel.setFilePrefix(element.attributeValue("filePrefix"));
            tableModel.setParseType(element.attributeValue("parseType"));
            tableModel.setParseClass(element.attributeValue("parseClass"));
            tableModel.setAggregationKeys(element.attributeValue("aggregationKeys"));
            tableModel.setSplit(element.attributeValue("split"));
            if (StringUtils.equals(element.attributeValue("insertOnly"), "true")) {
                tableModel.setInsertOnly("true");
            }

            String startRow = element.attributeValue("startRow");
            if (StringUtils.isNotEmpty(startRow) && StringUtils.isNumeric(startRow)) {
                tableModel.setStartRow(Integer.parseInt(startRow));
            }

            String stopSkipRow = element.attributeValue("stopSkipRow");
            if (StringUtils.isNotEmpty(stopSkipRow) && StringUtils.isNumeric(stopSkipRow)) {
                tableModel.setStopSkipRow(Integer.parseInt(stopSkipRow));
            }

            String batchSize = element.attributeValue("batchSize");
            if (StringUtils.isNotEmpty(batchSize) && StringUtils.isNumeric(batchSize)) {
                tableModel.setBatchSize(Integer.parseInt(batchSize));
            }

            List<?> excludes = element.elements("excludes");
            if (excludes != null && excludes.size() > 0) {
                Iterator<?> iterator = excludes.iterator();
                while (iterator.hasNext()) {
                    Element elem = (Element) iterator.next();
                    tableModel.addExclude(elem.getStringValue());
                }
            }

            List<?> rows = element.elements("property");
            if (rows != null && rows.size() > 0) {
                Iterator<?> iterator = rows.iterator();
                while (iterator.hasNext()) {
                    Element elem = (Element) iterator.next();
                    ColumnDefinition field = new ColumnDefinition();
                    this.readField(elem, field);
                    tableModel.addColumn(field);
                    if (StringUtils.equalsIgnoreCase(tableModel.getPrimaryKey(), field.getColumnName())) {
                        tableModel.setIdColumn(field);
                    }
                }
            }
        }

    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }

    return tableModel;
}

From source file:com.glaf.core.config.SystemConfig.java

public static String getCurrentYYYYMMDD() {
    String value = getString("curr_yyyymmdd");
    if (StringUtils.isEmpty(value) || StringUtils.equals("curr_yyyymmdd", value)
            || StringUtils.equals(CURR_YYYYMMDD, value)) {
        Date now = new Date();
        value = String.valueOf(DateUtils.getYearMonthDay(now));
    }/*w  w w . ja  va2  s .co  m*/
    return value;
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.blueprint.GWikiFormInputMacro.java

@Override
public boolean renderImpl(GWikiContext ctx, MacroAttributes attrs) {
    if (StringUtils.isEmpty(inputType) == true) {
        inputType = attrs.getDefaultValue();
    }// www . jav  a  2s .  c o  m
    if (StringUtils.equals(inputType, "text") == true) {
        ctx.append("<input type=\"text\" name=\"" + name + "\" value=\"" + WebUtils.escapeHtml(value) + "\"");
        renderStandardAttr(ctx, attrs);
        renderStandardAttr("size", ctx, attrs);
        renderStandardAttr("maxlength", ctx, attrs);
        ctx.append("/>");
    } else if (StringUtils.equals(inputType, "textarea") == true) {
        ctx.append("<textarea name=\"" + name + "\"");
        renderStandardAttr(ctx, attrs);
        renderStandardAttr("cols", ctx, attrs);
        renderStandardAttr("rows", ctx, attrs);
        renderStandardAttr("wrap", ctx, attrs);
        String v = value;
        ctx.append(">" + WebUtils.escapeHtml(v) + "</textarea>");
    } else if (StringUtils.equals(inputType, "checkbox") == true) {
        ctx.append("<input type=\"checkbox\" name=\"" + name + "\"");
        renderStandardAttr(ctx, attrs);
        if (StringUtils.equals(attrs.getArgs().getStringValue("checked"), "true") == true) {
            renderAttr(ctx, "checked", "checked");
        }
        ctx.append("/>");
    } else if (StringUtils.equals(inputType, "radio") == true) {
        ctx.append("<input type=\"radio\" name=\"" + name + "\"");
        renderStandardAttr(ctx, attrs);
        if (StringUtils.equals(attrs.getArgs().getStringValue("checked"), "true") == true) {
            renderAttr(ctx, "checked", "checked");
        }
        ctx.append("/>");
    } else if (StringUtils.equals(inputType, "select") == true) {
        ctx.append("<select name=\"" + name + "\"");
        renderStandardAttr(ctx, attrs);

        List<String> values = attrs.getArgs().getStringList("values");

        for (String v : values) {
            v = WebUtils.escapeHtml(v);
            String st = "";
            if (StringUtils.equals(v, value) == true) {
                st = " selected=\"selected\"";
            }
            ctx.append("<option " + st + "value=\"").append(v).append("\">").append(v).append("</option>");
        }
        ctx.append(">");

        ctx.append("</select>");
    } else if (StringUtils.equals(inputType, "label") == true) {
        ctx.append(WebUtils.escapeHtml(value));
    } else {
        // TODO general method to report error for macros.
        ctx.append("Unkown inputType");
    }
    return true;
}

From source file:com.cognifide.aet.executor.xmlparser.xml.utils.ValidationUtils.java

public static String validateWhitespace(String string, String warnMessage) throws ParseException {
    String fixedString = StringUtils.deleteWhitespace(string);
    if (StringUtils.isEmpty(fixedString)) {
        throw new ParseException("Provided string is empty", null);
    } else if (!StringUtils.equals(string, fixedString)) {
        LOGGER.warn(warnMessage);/*from  w  w  w. ja  va  2 s .co m*/
    }
    return fixedString;
}

From source file:com.inkubator.hrm.web.approval.ApprovalDefinitionPopupFormController.java

/**
 * END Optional Service/*from   ww w.j ava 2 s  .  c o m*/
 */
@PostConstruct
@Override
public void initialization() {
    super.initialization();
    approvalDefinitionModel = new ApprovalDefinitionModel();
    isPersistedToDB = StringUtils.equals(FacesUtil.getRequestParameter("isPersistedToDB"), "true");
    entityId = FacesUtil.getRequestParameter("entityId");

    String jsonAppDef = FacesUtil.getRequestParameter("jsonAppDef");
    if (StringUtils.isNotEmpty(jsonAppDef)) {
        try {
            isEdit = Boolean.TRUE;
            ApprovalDefinition ad = (ApprovalDefinition) JsonConverter.getClassFromJson(jsonAppDef,
                    ApprovalDefinition.class, "dd MMMM yyyy hh:mm");
            approvalDefinitionModel.setId(ad.getId());
            approvalDefinitionModel.setMinApprover(ad.getMinApprover());
            approvalDefinitionModel.setMinRejector(ad.getMinRejector());
            approvalDefinitionModel.setAllowOnBehalf(ad.getAllowOnBehalf());
            approvalDefinitionModel.setApproverType(ad.getApproverType());
            approvalDefinitionModel.setAutoApproveOnDelay(ad.getAutoApproveOnDelay());
            approvalDefinitionModel.setDelayTime(ad.getDelayTime());
            approvalDefinitionModel.setEscalateOnDelay(ad.getEscalateOnDelay());
            approvalDefinitionModel.setName(ad.getName());
            approvalDefinitionModel.setProcessType(ad.getProcessType());
            approvalDefinitionModel.setSequence(ad.getSequence());
            approvalDefinitionModel.setSmsNotification(ad.getSmsNotification());
            approvalDefinitionModel.setSpecificName(ad.getSpecificName());
            approvalDefinitionModel.setIsActive(ad.getIsActive());

            onBehalf = !ad.getAllowOnBehalf();
            onBehalfApproverTypeIndividual = onBehalf;
            onBehalfApproverTypePosition = onBehalf;

            if (ad.getApproverType().equalsIgnoreCase(HRMConstant.APPROVAL_TYPE_INDIVIDUAL)) {
                HrmUser user = hrmUserService
                        .getEntiyByPkWithDetail(ad.getHrmUserByApproverIndividual().getId());
                approvalDefinitionModel.setHrmUserByApproverIndividual(user);
                approverTypeIndividual = Boolean.FALSE;
                approverTypePosition = Boolean.TRUE;
            } else if (ad.getApproverType().equalsIgnoreCase(HRMConstant.APPROVAL_TYPE_POSITION)) {
                Jabatan jabatan = jabatanService.getEntiyByPK(ad.getJabatanByApproverPosition().getId());
                approvalDefinitionModel.setJabatanByApproverPosition(jabatan);
                approverTypeIndividual = Boolean.TRUE;
                approverTypePosition = Boolean.FALSE;
            } else if (ad.getApproverType().equalsIgnoreCase(HRMConstant.APPROVAL_TYPE_DEPARTMENT)) {
                approverTypeIndividual = Boolean.TRUE;
                approverTypePosition = Boolean.TRUE;
            }

            if (ad.getOnBehalfType() != null) {
                approvalDefinitionModel.setOnBehalfType(ad.getOnBehalfType());
                if (ad.getHrmUserByOnBehalfIndividual() != null) {
                    HrmUser user = hrmUserService
                            .getEntiyByPkWithDetail(ad.getHrmUserByOnBehalfIndividual().getId());
                    approvalDefinitionModel.setHrmUserByOnBehalfIndividual(user);
                    onBehalfApproverTypeIndividual = Boolean.FALSE;
                    onBehalfApproverTypePosition = Boolean.TRUE;
                } else if (ad.getJabatanByOnBehalfPosition() != null) {
                    Jabatan jabatan = jabatanService.getEntiyByPK(ad.getJabatanByOnBehalfPosition().getId());
                    approvalDefinitionModel.setJabatanByOnBehalfPosition(jabatan);
                    onBehalfApproverTypeIndividual = Boolean.TRUE;
                    onBehalfApproverTypePosition = Boolean.FALSE;
                }
            }

        } catch (Exception ex) {
            LOGGER.error("Error", ex);
        }

    } else {
        String appDefName = FacesUtil.getRequestParameter("appDefName");
        String specificName = FacesUtil.getRequestParameter("specificName");

        isEdit = Boolean.FALSE;
        onBehalf = Boolean.TRUE;
        onProcess = Boolean.TRUE;
        approverTypeIndividual = Boolean.TRUE;
        approverTypePosition = Boolean.TRUE;
        onBehalfApproverTypeIndividual = Boolean.TRUE;
        onBehalfApproverTypePosition = Boolean.TRUE;
        onAutoApprove = Boolean.TRUE;
        approvalDefinitionModel.setAutoApproveOnDelay(onAutoApprove);
        approvalDefinitionModel.setEscalateOnDelay(!onAutoApprove);
        approvalDefinitionModel.setMinApprover(1);
        approvalDefinitionModel.setMinRejector(1);
        approvalDefinitionModel.setName(appDefName);
        approvalDefinitionModel.setSmsNotification(Boolean.FALSE);
        if (StringUtils.isNotEmpty(specificName)) {
            approvalDefinitionModel.setSpecificName(specificName);
        }
        approvalDefinitionModel.setIsActive(Boolean.TRUE);
    }
}

From source file:io.wcm.maven.plugins.i18n.SlingI18nMap.java

private JSONObject buildI18nJson() throws JSONException {

    // get root// ww  w  .j a  v a2 s  . c o m
    JSONObject jsonDocument = getMixLanguageJsonDocument();

    // add entries
    for (Entry<String, String> entry : properties.entrySet()) {
        String key = entry.getKey();
        String escapedKey = validName(key);
        JSONObject value = getJsonI18nValue(key, entry.getValue(), !StringUtils.equals(key, escapedKey));

        jsonDocument.put(escapedKey, value);
    }

    // return result
    return jsonDocument;
}