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:com.navercorp.pinpoint.common.server.bo.codec.strategy.impl.StringAlwaysSameValueEncodingStrategy.java

@Override
public void encodeValues(Buffer buffer, List<String> values) {
    if (CollectionUtils.isEmpty(values)) {
        throw new IllegalArgumentException("values may not be empty");
    }//w  w  w . j a  v  a  2  s .c o m

    String initialValue = values.get(0);
    for (String value : values) {
        if (!StringUtils.equals(value, initialValue)) {
            throw new IllegalArgumentException("values must be all same value");
        }
    }

    bufferHandler.put(buffer, initialValue);
}

From source file:de.micromata.genome.gwiki.model.matcher.GWikiElementMetatemplateMatcher.java

@Override
public boolean match(GWikiElementInfo ei) {
    if (ei.getMetaTemplate() == null) {
        GWikiLog.warn("Element without metatemplate: " + ei.getId());
        return false;
    }/*from ww w .  j  ava 2  s .  co m*/
    final String et = ei.getMetaTemplate().getPageId();
    return StringUtils.equals(metaTemplateId, et);
}

From source file:com.google.mr4c.config.execution.DimensionConfig.java

public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (!obj.getClass().equals(this.getClass()))
        return false;
    DimensionConfig config = (DimensionConfig) obj;
    if (!name.equals(config.name))
        return false;
    if (!StringUtils.equals(mapTo, config.mapTo))
        return false;
    if (!ObjectUtils.equals(values, config.values))
        return false;
    return true;//from w w  w.j  a  v a2s  .c  om
}

From source file:edu.sabanciuniv.sentilab.sare.controllers.aspect.tests.AspectLexiconFactoryTest.java

private boolean areLexicaEqual(AspectLexicon expectedLexicon, AspectLexicon actualLexicon) {
    if (!StringUtils.equals(expectedLexicon.getTitle(), actualLexicon.getTitle())) {
        return false;
    }//from  w w  w.jav  a 2 s.c  o  m
    if (!StringUtils.equals(expectedLexicon.getDescription(), actualLexicon.getDescription())) {
        return false;
    }
    if (Iterables.size(expectedLexicon.getExpressions()) != Iterables.size(actualLexicon.getExpressions())) {
        return false;
    }
    if (Iterables.size(expectedLexicon.getAspects()) != Iterables.size(actualLexicon.getAspects())) {
        return false;
    }

    for (AspectExpression actualExpression : actualLexicon.getExpressions()) {
        AspectExpression expectedExpression = expectedLexicon.findExpression(actualExpression.getContent());
        if (expectedExpression == null) {
            return false;
        }
    }

    for (AspectLexicon actualAspect : actualLexicon.getAspects()) {
        AspectLexicon expectedAspect = expectedLexicon.findAspect(actualAspect.getTitle());
        if (expectedAspect == null) {
            return false;
        }

        if (!areLexicaEqual(expectedAspect, actualAspect)) {
            return false;
        }
    }

    return true;
}

From source file:com.eryansky.common.orm.core.spring.data.jpa.restriction.support.EqRestriction.java

public MatchValue getMatchValue(String matchValue, Class<?> FieldType) {
    MatchValue matchValueModel = super.getMatchValue(matchValue, FieldType);
    for (int i = 0; i < matchValueModel.getValues().size(); i++) {
        Object value = matchValueModel.getValues().get(i);
        if (value instanceof String && StringUtils.equals(value.toString(), "null")) {
            matchValueModel.getValues().remove(i);
            matchValueModel.getValues().add(i, null);
        }//from  w w w  . j a v  a2 s . c  om
    }
    return matchValueModel;
}

From source file:models.PersistentObjectModel.java

@Override
public boolean equals(Object obj) {
    if (obj instanceof PersistentObjectModel) {
        if (super.equals(obj) || StringUtils.isEmpty(this.type)
                || StringUtils.isEmpty(((PersistentObjectModel) obj).type)) {
            return StringUtils.equals(this.id, ((PersistentObjectModel) obj).id);
        }/* w w w.  j  a  va2s .  co  m*/
    }

    return super.equals(obj);
}

From source file:models.IssueEvent.java

/**
 * Adds {@code event}./*from   w  w  w .ja  v  a 2  s.c  o  m*/
 *
 * If the last event is not older than {@link #DRAFT_TIME_IN_MILLIS}
 * miliseconds and the event is the same kind of event as the given one,
 * merge or delete both of the events if necessary to reduce hassle
 * notifications.
 *
 * Examples:
 *
 * - If an assignee was changed from A to B, then A to C, the two events
 *   are merged into the event of which assignee was changed from A to C.
 * - If an assignee was changed from A to B, then B to A, the two events
 *   will be deleted.
 *
 * Notes: This method originates from
 * {@link NotificationEvent#add(NotificationEvent)}
 *
 * @param event
 */
public static void add(IssueEvent event) {
    Date draftDate = DateTime.now().minusMillis(DRAFT_TIME_IN_MILLIS).toDate();

    IssueEvent lastEvent = IssueEvent.find.where().eq("issue.id", event.issue.id).gt("created", draftDate)
            .orderBy("id desc").setMaxRows(1).findUnique();

    if (lastEvent != null) {
        if (lastEvent.eventType == event.eventType
                && StringUtils.equals(event.senderLoginId, lastEvent.senderLoginId)) {
            // A -> B, B -> C ==> A -> C
            event.oldValue = lastEvent.oldValue;
            lastEvent.delete();

            // A -> B, B -> A ==> remove all of them
            if (StringUtils.equals(event.oldValue, event.newValue)) {
                // No need to add this event because the event just cancels the last event
                // which has just been deleted.
                return;
            }
        }
    }

    event.save();
}

From source file:com.francetelecom.clara.cloud.deployment.rules.CheckMavenReferenceRule.java

@Override
public Set<RuleValidationMessage> validate(DeployableMavenArtifactDto providedArtifact, ProcessingNode node)
        throws TechnicalException {
    Set<RuleValidationMessage> messages = new HashSet<RuleValidationMessage>();
    MavenReference expectedMavenReference = node.getSoftwareReference();

    logger.debug("Checking GAV");

    if (!StringUtils.equals(expectedMavenReference.getGroupId(), providedArtifact.getGroupId())) {
        messages.add(new RuleValidationMessage("Deployment of [" + providedArtifact.getArtifactId()
                + "] not allowed : provided groupId [" + providedArtifact.getGroupId()
                + "] does not match expected groupId [" + expectedMavenReference.getGroupId() + "]", WARNING));
    }/*from   w  ww. ja v  a2  s .  c  o  m*/
    if (!StringUtils.equals(expectedMavenReference.getArtifactId(), providedArtifact.getArtifactId())) {
        messages.add(new RuleValidationMessage("Deployment of " + providedArtifact.getArtifactId()
                + " not allowed : provided artifactId [" + providedArtifact.getArtifactId()
                + "] does not match expected artifactId [" + expectedMavenReference.getArtifactId() + "]",
                WARNING));
    }
    // Classifier null or empty ("") should be considered equals
    if ((StringUtils.isNotEmpty(expectedMavenReference.getClassifier())
            || StringUtils.isNotEmpty(providedArtifact.getClassifier()))
            && !StringUtils.equals(expectedMavenReference.getClassifier(), providedArtifact.getClassifier())) {
        messages.add(new RuleValidationMessage("Deployment of [" + providedArtifact.getArtifactId()
                + "] not allowed : provided classifier [" + providedArtifact.getClassifier()
                + "] does not match expected classifier [" + expectedMavenReference.getClassifier() + "]",
                WARNING));
    }
    if (!StringUtils.equals(expectedMavenReference.getType(), providedArtifact.getType())) {
        messages.add(new RuleValidationMessage("Deployment of [" + providedArtifact.getArtifactId()
                + "] not allowed : provided type [" + providedArtifact.getType()
                + "] does not match expected type [" + expectedMavenReference.getType() + "]", WARNING));
    }
    if (!StringUtils.startsWith(providedArtifact.getVersion(), expectedMavenReference.getVersion())) {
        messages.add(new RuleValidationMessage("Deployment of [" + providedArtifact.getArtifactId()
                + "] not allowed : provided version [" + providedArtifact.getVersion()
                + "] does not match expected version [" + expectedMavenReference.getVersion() + "]", WARNING));
    }

    return messages;
}

From source file:com.nesscomputing.migratory.validation.DbValidator.java

public ValidationResult validate(final List<MetadataInfo> metadataInfoList) {
    final ValidationResult.Builder builder = new ValidationResult.Builder();
    final Map<String, Migration> migrations = migrationManager.getMigrations();

    for (MetadataInfo metadataInfo : metadataInfoList) {
        final Migration matchingMigration = migrations.get(metadataInfo.getScriptName());
        if (matchingMigration == null) {
            builder.add(ValidationStatus.NOT_FOUND, metadataInfo, "");
        } else {//  www . j av  a 2s .c o  m
            if (!StringUtils.equals(matchingMigration.getChecksum(), metadataInfo.getChecksum())) {
                builder.add(ValidationStatus.BAD_CHECKSUM, metadataInfo, matchingMigration.getChecksum());
            }
            if (matchingMigration.getType() != metadataInfo.getType()) {
                builder.add(ValidationStatus.TYPE_MISMATCH, metadataInfo, matchingMigration.getType().name());
            }
        }
    }

    // Get the last element in the list.
    final MetadataInfo lastInfo = metadataInfoList.get(metadataInfoList.size() - 1);
    if (lastInfo.getState() == MigrationState.FAIL) {
        builder.add(ValidationStatus.FAILED_STATE, lastInfo, "");
    }

    return builder.build();
}

From source file:com.omnigon.aem.common.utils.JcrPropertyUtil.java

/**
 *
 * @param node JCR node//from   w w w .j  a  va  2  s .c  o m
 * @param propName property name
 * @param propValue property value
 * @throws RepositoryException -
 */
public static void updateProperty(final Node node, final String propName, final Long propValue)
        throws RepositoryException {
    boolean hasProperty = node.hasProperty(propName);

    if (!hasProperty && propValue != null) {
        updateLongProperty(node, propName, propValue);
    } else if (hasProperty && propValue == null) {
        updateLongProperty(node, propName, null);
    } else if (hasProperty
            && !StringUtils.equals(propValue.toString(), node.getProperty(propName).getString())) {
        updateLongProperty(node, propName, propValue);
    }
}