Java Code Examples for org.apache.commons.lang3.ObjectUtils#equals()

The following examples show how to use org.apache.commons.lang3.ObjectUtils#equals() . 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: DynProperty.java    From gvnix with GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc} Two properties are equal if their key and value are equals.
 */
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    DynProperty other = (DynProperty) obj;
    if (!ObjectUtils.equals(key, other.key)) {
        return false;
    }
    if (!ObjectUtils.equals(value, other.value)) {
        return false;
    }
    return true;
}
 
Example 2
Source File: LocalDevice.java    From BACnet4J with GNU General Public License v3.0 6 votes vote down vote up
private RemoteDevice getRemoteDeviceImpl(final int instanceId, 
										 final Address address, 
										 final OctetString linkService) {
    for (RemoteDevice d : remoteDevices) {
        if (strict || address == null) {
            // Only compare by device id, as should be sufficient according to the spec's insistence on 
            // unique device ids.
            if (d.getInstanceNumber() == instanceId)
                return d;
        }
        else {
            // Compare device ids and address.
            if (d.getInstanceNumber() == instanceId && d.getAddress().equals(address)
                    && ObjectUtils.equals(d.getLinkService(), linkService))
                return d;
        }
    }
    return null;
}
 
Example 3
Source File: ActivitiPropertyConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @param task Task
 * @param properties Map<QName, Serializable>
 */
private void setTaskOwner(Task task, Map<QName, Serializable> properties)
{
    QName ownerKey = ContentModel.PROP_OWNER;
    if (properties.containsKey(ownerKey))
    {
        Serializable owner = properties.get(ownerKey);
        if (owner != null && !(owner instanceof String))
        {
            throw getInvalidPropertyValueException(ownerKey, owner);
        }
        String assignee = (String) owner;
        String currentAssignee = task.getAssignee();
        // Only set the assignee if the value has changes to prevent
        // triggering assignementhandlers when not needed
        if (ObjectUtils.equals(currentAssignee, assignee)==false)
        {
            activitiUtil.getTaskService().setAssignee(task.getId(), assignee);
        }
    }
}
 
Example 4
Source File: MapsProperty.java    From gvnix with GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc} Two properties are equal if their key and value are equals.
 */
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    MapsProperty other = (MapsProperty) obj;
    if (!ObjectUtils.equals(key, other.key)) {
        return false;
    }
    if (!ObjectUtils.equals(value, other.value)) {
        return false;
    }
    return true;
}
 
Example 5
Source File: IdType.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if this IdType matches the given IdType in terms of resource
 * type and ID, but ignores the URL base
 */
@SuppressWarnings("deprecation")
public boolean equalsIgnoreBase(IdType theId) {
  if (theId == null) {
    return false;
  }
  if (theId.isEmpty()) {
    return isEmpty();
  }
  return ObjectUtils.equals(getResourceType(), theId.getResourceType())
    && ObjectUtils.equals(getIdPart(), theId.getIdPart())
    && ObjectUtils.equals(getVersionIdPart(), theId.getVersionIdPart());
}
 
Example 6
Source File: IdType.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if this IdType matches the given IdType in terms of resource
 * type and ID, but ignores the URL base
 */
@SuppressWarnings("deprecation")
public boolean equalsIgnoreBase(IdType theId) {
  if (theId == null) {
    return false;
  }
  if (theId.isEmpty()) {
    return isEmpty();
  }
  return ObjectUtils.equals(getResourceType(), theId.getResourceType())
    && ObjectUtils.equals(getIdPart(), theId.getIdPart())
    && ObjectUtils.equals(getVersionIdPart(), theId.getVersionIdPart());
}
 
Example 7
Source File: Triple.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Compares this triple to another based on the three elements.</p>
 *
 * @param obj  the object to compare to, null returns false
 * @return true if the elements of the triple are equal
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (obj instanceof Triple<?, ?, ?>) {
        Triple<?, ?, ?> other = (Triple<?, ?, ?>) obj;
        return ObjectUtils.equals(getLeft(), other.getLeft())
            && ObjectUtils.equals(getMiddle(), other.getMiddle())
            && ObjectUtils.equals(getRight(), other.getRight());
    }
    return false;
}
 
Example 8
Source File: DiffConfig.java    From mr4c with Apache License 2.0 5 votes vote down vote up
public boolean equals(Object obj) {
	if ( this==obj ) return true;
	if ( !obj.getClass().equals(this.getClass()) ) return false;
	DiffConfig config = (DiffConfig) obj;
	if ( !ObjectUtils.equals(actual, config.actual) ) return false;
	if ( !ObjectUtils.equals(expected, config.expected) ) return false;
	if ( !ObjectUtils.equals(diff, config.diff) ) return false;
	if ( !ObjectUtils.equals(diffParam, config.diffParam) ) return false;
	return true; 
}
 
Example 9
Source File: Triple.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Compares this triple to another based on the three elements.</p>
 *
 * @param obj  the object to compare to, null returns false
 * @return true if the elements of the triple are equal
 */
@Override
public boolean equals(final Object obj) {
    if (obj == this) {
        return true;
    }
    if (obj instanceof Triple<?, ?, ?>) {
        final Triple<?, ?, ?> other = (Triple<?, ?, ?>) obj;
        return ObjectUtils.equals(getLeft(), other.getLeft())
            && ObjectUtils.equals(getMiddle(), other.getMiddle())
            && ObjectUtils.equals(getRight(), other.getRight());
    }
    return false;
}
 
Example 10
Source File: BaseModelProvider.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
protected void onPlaceSelected(SessionActivePlaceSetEvent event) {
    String newPlaceId = event.getPlaceId().toString();
    if(!ObjectUtils.equals(newPlaceId, getPlaceID())) {
        store.clear();
    }

    placeId.set( event.getPlaceId().toString() );
    reload();
}
 
Example 11
Source File: SequenceOf.java    From BACnet4J with GNU General Public License v3.0 5 votes vote down vote up
public void removeAll(E value) {
    for (ListIterator<E> it = values.listIterator(); it.hasNext();) {
        E e = it.next();
        if (ObjectUtils.equals(e, value))
            it.remove();
    }
}
 
Example 12
Source File: ListUtil.java    From disconf with Apache License 2.0 5 votes vote down vote up
public static <T> boolean in(T value, T... list) {
    if (ArrayUtils.isEmpty(list)) {
        return false;
    }
    for (T t : list) {
        if (ObjectUtils.equals(value, t)) {
            return true;
        }
    }
    return false;
}
 
Example 13
Source File: DatasetConfig.java    From mr4c with Apache License 2.0 5 votes vote down vote up
public boolean equals(Object obj) {
	if ( this==obj ) return true;
	if ( !obj.getClass().equals(this.getClass()) ) return false;
	DatasetConfig config = (DatasetConfig) obj;
	if ( !scheme.equals(config.scheme) ) return false;
	if ( !location.equals(config.location) ) return false;
	if ( !srcConfig.equals(config.srcConfig) ) return false;
	if ( !ObjectUtils.equals(mapConfig, config.mapConfig) ) return false;
	if ( !ObjectUtils.equals(queryOnly, config.queryOnly) ) return false;
	return true; 
}
 
Example 14
Source File: MR4CGenericOptions.java    From mr4c with Apache License 2.0 5 votes vote down vote up
public boolean equals(Object obj) {
	if ( this==obj ) return true;
	if ( !obj.getClass().equals(this.getClass()) ) return false;
	MR4CGenericOptions opts = (MR4CGenericOptions) obj;
	if ( !ObjectUtils.equals(m_cluster, opts.m_cluster) ) return false;
	if ( !ObjectUtils.equals(m_files, opts.m_files) ) return false;
	if ( !ObjectUtils.equals(m_jars, opts.m_jars) ) return false;
	return true;
}
 
Example 15
Source File: MergeDialog.java    From webanno with Apache License 2.0 5 votes vote down vote up
protected void onConfirmInternal(AjaxRequestTarget aTarget, Form<State> aForm)
{
    State state = aForm.getModelObject();
    
    // Check if the challenge was met
    if (!ObjectUtils.equals(state.expectedResponse, state.response)) {
        state.feedback = "Your response did not meet the challenge.";
        aTarget.add(aForm);
        return;
    }
    
    boolean closeOk = true;
    
    // Invoke callback if one is defined
    if (confirmAction != null) {
        try {
            confirmAction.accept(aTarget, aForm);
        }
        catch (Exception e) {
            LoggerFactory.getLogger(getPage().getClass()).error("Error: " + e.getMessage(), e);
            state.feedback = "Error: " + e.getMessage();
            aTarget.add(aForm);
            closeOk = false;
        }
    }
    
    if (closeOk) {
        close(aTarget);
    }
}
 
Example 16
Source File: AutomationUtil.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Deprecated
private static void deleteSpanAnnotation(TypeAdapter aAdapter, AnnotatorState aState,
        CAS aCas, AnnotationFeature aFeature, int aBegin, int aEnd, Object aValue)
{
    Type type = CasUtil.getType(aCas, aAdapter.getAnnotationTypeName());
    for (AnnotationFS fs : CasUtil.selectCovered(aCas, type, aBegin, aEnd)) {
        if (fs.getBegin() == aBegin && fs.getEnd() == aEnd) {
            if (ObjectUtils.equals(aAdapter.getFeatureValue(aFeature, fs), aValue)) {
                aAdapter.delete(aState.getDocument(), aState.getUser().getUsername(), aCas,
                        new VID(getAddr(fs)));
            }
        }
    }
}
 
Example 17
Source File: CompositeKey.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
public boolean equals(int i, Object o) {
    return ObjectUtils.equals(this.values[i], o);
}
 
Example 18
Source File: ESMessageListener.java    From elastic-rabbitmq with MIT License 4 votes vote down vote up
private boolean isGeneratedMessage(Message message) {
    return ObjectUtils.equals("EventGenerator", message.getMessageProperties().getHeaders().get("eventSource"));
}
 
Example 19
Source File: CvarManager.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public boolean remove(Cvar cvar) {
  if (cvar == null) return false;
  String alias = cvar.ALIAS.toLowerCase();
  Cvar queriedCvar = CVARS.get(alias);
  return ObjectUtils.equals(queriedCvar, cvar) && CVARS.remove(alias) != null;
}
 
Example 20
Source File: CvarManager.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public boolean isManaging(Cvar cvar) {
  if (cvar == null) return false;
  String alias = cvar.ALIAS.toLowerCase();
  Cvar queriedCvar = CVARS.get(alias);
  return ObjectUtils.equals(queriedCvar, cvar);
}