org.apache.commons.lang3.StringUtils#compare ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringUtils#compare ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: entando-core   文件: WidgetTypeListProcessor.java
@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());
        }
    };
}
 
@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());
        }
    };
}
 
源代码3 项目: fess   文件: PrunedTag.java
@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;
}
 
源代码4 项目: MergeProcessor   文件: PreferenceInitializer.java
/**
 * {@inheritDoc}
 */
@Override
public int compare(Path o1, Path o2) {
	final String so1 = getVersionForEclipsePath(o1);
	final String so2 = getVersionForEclipsePath(o2);
	return StringUtils.compare(so1, so2);
}
 
源代码5 项目: youran   文件: FileNodeUtil.java
@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;
    }
}
 
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; 
}
 
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;
}
 
源代码8 项目: ontopia   文件: RoleField.java
@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;
  }
}
 
@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());
        }
    };
}
 
@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);
        }
    };
}
 
源代码11 项目: nifi   文件: GetHDFSFileInfo.java
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;
    }
 
源代码12 项目: azure-cosmosdb-java   文件: Strings.java
public static int compare(String str1, String str2) {
    return StringUtils.compare(str1, str2);
}
 
源代码13 项目: ontopia   文件: TopicIdComparator.java
@Override
public int compare(Topic t1, Topic t2) {
  return StringUtils.compare(t1.getId(), t2.getId());
}
 
源代码14 项目: ontopia   文件: AssociationField.java
@Override
public int compare(RoleField rf1, RoleField rf2) {
  return StringUtils.compare(rf1.getFieldName(), rf2.getFieldName());
}
 
源代码15 项目: ontopia   文件: AssociationType.java
@Override
public int compare(RoleField rf1, RoleField rf2) {
  return StringUtils.compare(rf1.getFieldName(), rf2.getFieldName());
}
 
@Override
protected Function<String, Comparator<AttributeInterface>> getComparators() {
    return sort -> {
        return (a, b) -> StringUtils.compare(a.getType(), b.getType());
    };
}
 
源代码17 项目: syncope   文件: UserDetails.java
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);
    // ------------------------        
}
 
 同类方法