Java Code Examples for org.apache.commons.lang3.StringUtils#compare()

The following examples show how to use org.apache.commons.lang3.StringUtils#compare() . 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: PrunedTag.java    From fess with Apache License 2.0 6 votes vote down vote up
@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    final PrunedTag other = (PrunedTag) obj;
    return StringUtils.compare(tag, other.tag) == 0 //
            && StringUtils.compare(css, other.css) == 0 //
            && StringUtils.compare(id, other.id) == 0 //
            && StringUtils.compare(attrName, other.attrName) == 0 //
            && StringUtils.compare(attrValue, other.attrValue) == 0;
}
 
Example 2
Source File: LanguageRequestListProcessor.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected Function<String, Comparator<LanguageDto>> getComparators() {
    return sort -> {
        switch (sort) {
            case DESCRIPTION:
                return (a, b) -> StringUtils.compare(a.getDescription(), b.getDescription());
            case DEFAULT:
                return (a, b) -> Boolean.compare(a.isDefaultLang(), b.isDefaultLang());
            case ACTIVE:
                return (a, b) -> Boolean.compare(a.isActive(), b.isActive());
            case CODE: // code is the default sorting field
            default:
                return (a, b) -> StringUtils.compare(a.getCode(), b.getCode());
        }
    };
}
 
Example 3
Source File: WidgetTypeListProcessor.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected Function<String, Comparator<WidgetDto>> getComparators() {
    return sort -> {
        switch (sort) {
            case USED:
                return (a, b) -> Integer.compare(a.getUsed(), b.getUsed());
            case TYPOLOGY:
                return (a, b) -> StringUtils.compare(a.getTypology(), b.getTypology());
            case GROUP:
                return (a, b) -> StringUtils.compare(a.getGroup(), b.getGroup());
            case PLUGIN_CODE:
                return (a, b) -> StringUtils.compare(a.getPluginCode(), b.getPluginCode());
            case CODE: // code is the default sorting field
            default:
                return (a, b) -> StringUtils.compare(a.getCode(), b.getCode());
        }
    };
}
 
Example 4
Source File: FileNodeUtil.java    From youran with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(FileNodeVO o1, FileNodeVO o2) {
    int dirType1 = this.getDirType(o1);
    int dirType2 = this.getDirType(o2);
    if (dirType1 == dirType2) {
        return StringUtils.compare(o1.getPath(), o2.getPath());
    } else {
        return dirType1 - dirType2;
    }
}
 
Example 5
Source File: GetHDFSFileInfo.java    From nifi with Apache License 2.0 5 votes vote down vote up
protected HDFSFileInfoRequest updateRequestDetails(ProcessContext context, ProcessSession session, FlowFile ff) {

        if (req == null) {
            return buildRequestDetails(context, session, ff);
        }
        req.fullPath = context.getProperty(FULL_PATH).evaluateAttributeExpressions(ff).getValue();

        String currValue = null;
        String oldValue = null;

        currValue = context.getProperty(DIR_FILTER).evaluateAttributeExpressions(ff).getValue();
        oldValue = req.dirFilter == null ? null : req.dirFilter.toString();
        if (StringUtils.compare(currValue, oldValue) != 0) {
            req.dirFilter = currValue == null ? null : Pattern.compile(currValue);
        }


        currValue = context.getProperty(FILE_FILTER).evaluateAttributeExpressions(ff).getValue();
        oldValue = req.fileFilter == null ? null : req.fileFilter.toString();
        if (StringUtils.compare(currValue, oldValue) != 0) {
            req.fileFilter = currValue == null ? null : Pattern.compile(currValue);
        }


        currValue = context.getProperty(FILE_EXCLUDE_FILTER).evaluateAttributeExpressions(ff).getValue();
        oldValue = req.fileExcludeFilter == null ? null : req.fileExcludeFilter.toString();
        if (StringUtils.compare(currValue, oldValue) != 0) {
            req.fileExcludeFilter = currValue == null ? null : Pattern.compile(currValue);
        }

        return req;
    }
 
Example 6
Source File: ContentModelReferencesRequestListProcessor.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Function<String, Comparator<ContentModelReference>> getComparators() {
    return sort -> {
        switch (sort) {
            case KEY_PAGE_CODE:
            default:
                return (a, b) -> StringUtils.compare(a.getPageCode(), b.getPageCode());
            case KEY_ONLINE:
                return (a, b) -> Boolean.compare(a.isOnline(), b.isOnline());
            case KEY_WIDGED_POSITION:
                return Comparator.comparingInt(ContentModelReference::getWidgetPosition);
        }
    };
}
 
Example 7
Source File: ContentModelRequestListProcessor.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Function<String, Comparator<ContentModel>> getComparators() {
    return sort -> {
        switch (sort) {
            case KEY_ID:
            default:
                return (a, b) -> Long.compare(a.getId(), b.getId());
            case KEY_CONTENT_TYPE:
                return (a, b) -> StringUtils.compare(a.getContentType(), b.getContentType());
            case KEY_DESCR:
                return (a, b) -> StringUtils.compare(a.getDescription(), b.getDescription());
        }
    };
}
 
Example 8
Source File: RoleField.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(ValueIF v1, ValueIF v2) {
  try {
    Topic p1 = v1.getPlayer(ofield, oplayer);
    Topic p2 = v2.getPlayer(ofield, oplayer);
    OccurrenceIF oc1 = entries.get(p1);
    OccurrenceIF oc2 = entries.get(p2);
    return StringUtils.compare(oc1 == null ? null : oc1.getValue(), oc2 == null ? null : oc2.getValue());
  } catch (Exception e) {
    // should not fail when comparing. bergen kommune has had an issue where this happens. we thus ignore for now.
    //        e.printStackTrace();
    return 0;
  }
}
 
Example 9
Source File: DefaultTasksService.java    From geoportal-server-harvester with Apache License 2.0 5 votes vote down vote up
private boolean updateLinkDefinition(LinkDefinition ld, EntityDefinition bd) {
  boolean updated = false;
  
  if (StringUtils.compare(ld.getAction().getRef(), bd.getRef())==0) {
    ld.setAction(bd);
    updated = true;
  }
  
  updated |= ld.getDrains()!=null? ld.getDrains().stream()
          .filter(drain -> updateLinkDefinition(drain, bd))
          .count() > 0: false;
  
  return updated;
}
 
Example 10
Source File: DefaultTasksService.java    From geoportal-server-harvester with Apache License 2.0 5 votes vote down vote up
private boolean updateTaskDefiniton(TaskDefinition td, EntityDefinition bd) {
  boolean updated = false;
  
  if (StringUtils.compare(td.getSource().getRef(), bd.getRef())==0) {
    td.setSource(bd);
    updated = true;
  }
  
  updated |= td.getDestinations().stream().filter(ld -> updateLinkDefinition(ld, bd)).count() > 0;
  
  return updated; 
}
 
Example 11
Source File: PreferenceInitializer.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int compare(Path o1, Path o2) {
	final String so1 = getVersionForEclipsePath(o1);
	final String so2 = getVersionForEclipsePath(o2);
	return StringUtils.compare(so1, so2);
}
 
Example 12
Source File: AssociationType.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(RoleField rf1, RoleField rf2) {
  return StringUtils.compare(rf1.getFieldName(), rf2.getFieldName());
}
 
Example 13
Source File: AttributeTypeRequestListProcessor.java    From entando-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected Function<String, Comparator<AttributeInterface>> getComparators() {
    return sort -> {
        return (a, b) -> StringUtils.compare(a.getType(), b.getType());
    };
}
 
Example 14
Source File: AssociationField.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(RoleField rf1, RoleField rf2) {
  return StringUtils.compare(rf1.getFieldName(), rf2.getFieldName());
}
 
Example 15
Source File: TopicIdComparator.java    From ontopia with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(Topic t1, Topic t2) {
  return StringUtils.compare(t1.getId(), t2.getId());
}
 
Example 16
Source File: UserDetails.java    From syncope with Apache License 2.0 4 votes vote down vote up
public UserDetails(
        final UserWrapper wrapper,
        final boolean templateMode,
        final boolean includeStatusPanel,
        final boolean showPasswordManagement,
        final PageReference pageRef) {
    super(wrapper, templateMode, includeStatusPanel, pageRef);

    userTO = wrapper.getInnerObject();
    // ------------------------
    // Username
    // ------------------------
    username = new AjaxTextFieldPanel("username", "username", new PropertyModel<>(userTO, "username"), false);

    if (wrapper.getPreviousUserTO() != null && StringUtils.compare(
            wrapper.getPreviousUserTO().getUsername(), wrapper.getInnerObject().getUsername()) != 0) {

        username.showExternAction(new LabelInfo("externalAction", wrapper.getPreviousUserTO().getUsername()));
    }

    if (templateMode) {
        username.enableJexlHelp();
    } else {
        username.addRequiredLabel();
    }
    add(username);
    // ------------------------

    // ------------------------
    // Password
    // ------------------------
    final Model<Integer> model = Model.of(-1);

    final Accordion accordion = new Accordion("accordionPanel", Collections.<ITab>singletonList(
            new AbstractTab(new ResourceModel("password.change", "Change password")) {

        private static final long serialVersionUID = 1037272333056449378L;

        @Override
        public Panel getPanel(final String panelId) {
            EditUserPasswordPanel panel = new EditUserPasswordPanel(panelId, wrapper, templateMode);
            panel.setEnabled(model.getObject() >= 0);
            return panel;
        }
    }), model) {

        private static final long serialVersionUID = -2898628183677758699L;

        @Override
        protected Component newTitle(final String markupId, final ITab tab, final Accordion.State state) {
            return new AjaxLink<Integer>(markupId) {

                private static final long serialVersionUID = 7021195294339489084L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    model.setObject(model.getObject() == 0 ? -1 : 0);
                    Component passwordPanel = getParent().get(PASSWORD_CONTENT_PATH);
                    passwordPanel.setEnabled(model.getObject() >= 0);
                    target.add(passwordPanel);
                }
            }.setBody(new ResourceModel("password.change", "Change password ..."));
        }
    };

    accordion.setOutputMarkupId(true);
    accordion.setVisible(showPasswordManagement);
    add(accordion);
    // ------------------------        
}
 
Example 17
Source File: Strings.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
public static int compare(String str1, String str2) {
    return StringUtils.compare(str1, str2);
}