Use Objects.equals() throughout
| | |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | |
| | | && desc.getBaseDns().equals(getBaseDns()) |
| | | && desc.getIndexes().equals(getIndexes()) |
| | | && desc.getVLVIndexes().equals(getVLVIndexes()) |
| | | && equal(getMonitoringEntry(), desc.getMonitoringEntry()); |
| | | && Objects.equals(getMonitoringEntry(), desc.getMonitoringEntry()); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean equal(CustomSearchResult m1, CustomSearchResult m2) |
| | | { |
| | | if (m1 == null) |
| | | { |
| | | return m2 == null; |
| | | } |
| | | return m1.equals(m2); |
| | | } |
| | | |
| | | /** |
| | | * Returns the monitoring entry information. |
| | | * @return the monitoring entry information. |
| | |
| | | |
| | | import java.io.File; |
| | | import java.text.ParseException; |
| | | import java.util.Objects; |
| | | |
| | | import org.opends.server.util.Base64; |
| | | |
| | |
| | | { |
| | | BinaryValue candidate = (BinaryValue)o; |
| | | return candidate.getType() == getType() |
| | | && equal(file, candidate.getFile()) |
| | | && Objects.equals(file, candidate.getFile()) |
| | | && bytesEqual(candidate); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean equal(File o1, File o2) |
| | | { |
| | | if (o1 == null) |
| | | { |
| | | return o2 == null; |
| | | } |
| | | return o1.equals(o2); |
| | | } |
| | | |
| | | private boolean bytesEqual(BinaryValue candidate) |
| | | { |
| | | if (type == Type.BASE64_STRING) |
| | |
| | | import java.net.InetAddress; |
| | | import java.util.ArrayList; |
| | | import java.util.HashSet; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | private int compareNames(AddressConnectionHandlerDescriptor ach1, |
| | | AddressConnectionHandlerDescriptor ach2) |
| | | { |
| | | if (equal(ach1.getAddress(), ach2.getAddress())) |
| | | if (Objects.equals(ach1.getAddress(), ach2.getAddress())) |
| | | { |
| | | Integer port1 = Integer.valueOf(ach1.getConnectionHandler().getPort()); |
| | | Integer port2 = Integer.valueOf(ach2.getConnectionHandler().getPort()); |
| | |
| | | return getName(ach1).compareTo(getName(ach2)); |
| | | } |
| | | |
| | | /** |
| | | * Returns whether two addresses are equal. |
| | | * |
| | | * @param address1 |
| | | * the first address |
| | | * @param address2 |
| | | * the second address |
| | | * @return true if both are equal, false otherwise |
| | | */ |
| | | static boolean equal(InetAddress address1, InetAddress address2) |
| | | { |
| | | if (address1 != null) |
| | | { |
| | | return address1.equals(address2); |
| | | } |
| | | return address2 == null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected CustomSearchResult getMonitoringEntry( |
| | |
| | | return false; |
| | | } |
| | | AddressConnectionHandlerDescriptor ach = (AddressConnectionHandlerDescriptor) o; |
| | | return ConnectionHandlersMonitoringTableModel.equal(getAddress(), ach.getAddress()) |
| | | return Objects.equals(getAddress(), ach.getAddress()) |
| | | && ach.getConnectionHandler().equals(getConnectionHandler()); |
| | | } |
| | | } |
| | |
| | | */ |
| | | package org.opends.guitools.controlpanel.datamodel; |
| | | |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | |
| | | if (o instanceof ObjectClassValue) |
| | | { |
| | | ObjectClassValue oc = (ObjectClassValue)o; |
| | | return equal(structural, oc.getStructural()) |
| | | return Objects.equals(structural, oc.getStructural()) |
| | | && auxiliary.equals(oc.getAuxiliary()); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private boolean equal(String s1, String s2) |
| | | { |
| | | if (s1 == null) |
| | | { |
| | | return s2 == null; |
| | | } |
| | | return s1.equals(s2); |
| | | } |
| | | } |
| | |
| | | |
| | | import static com.persistit.Transaction.CommitPolicy.*; |
| | | import static java.util.Arrays.*; |
| | | |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.UtilityMessages.*; |
| | |
| | | import java.util.ListIterator; |
| | | import java.util.Map; |
| | | import java.util.NoSuchElementException; |
| | | import java.util.Objects; |
| | | import java.util.Queue; |
| | | import java.util.Set; |
| | | import java.util.concurrent.ConcurrentLinkedDeque; |
| | |
| | | ex.fetch(); |
| | | final ByteSequence oldValue = valueToBytes(ex.getValue()); |
| | | final ByteSequence newValue = f.computeNewValue(oldValue); |
| | | if (!equals(newValue, oldValue)) |
| | | if (!Objects.equals(newValue, oldValue)) |
| | | { |
| | | if (newValue == null) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean equals(ByteSequence b1, ByteSequence b2) |
| | | { |
| | | if (b1 == null) |
| | | { |
| | | return b2 == null; |
| | | } |
| | | return b1.equals(b2); |
| | | } |
| | | |
| | | private Exchange getExchangeFromCache(final TreeName treeName) throws PersistitException |
| | | { |
| | | Exchange exchange = exchanges.get(treeName); |
| | |
| | | private boolean anyChangeRequiresRestart(HTTPConnectionHandlerCfg newCfg) |
| | | { |
| | | return !equals(newCfg.getListenPort(), initConfig.getListenPort()) |
| | | || !equals(newCfg.getListenAddress(), initConfig.getListenAddress()) |
| | | || !equals(newCfg.getMaxRequestSize(), currentConfig |
| | | .getMaxRequestSize()) |
| | | || !equals(newCfg.isAllowTCPReuseAddress(), currentConfig |
| | | .isAllowTCPReuseAddress()) |
| | | || !equals(newCfg.isUseTCPKeepAlive(), currentConfig |
| | | .isUseTCPKeepAlive()) |
| | | || !Objects.equals(newCfg.getListenAddress(), initConfig.getListenAddress()) |
| | | || !equals(newCfg.getMaxRequestSize(), currentConfig.getMaxRequestSize()) |
| | | || !equals(newCfg.isAllowTCPReuseAddress(), currentConfig.isAllowTCPReuseAddress()) |
| | | || !equals(newCfg.isUseTCPKeepAlive(), currentConfig.isUseTCPKeepAlive()) |
| | | || !equals(newCfg.isUseTCPNoDelay(), currentConfig.isUseTCPNoDelay()) |
| | | || !equals(newCfg.getMaxBlockedWriteTimeLimit(), currentConfig |
| | | .getMaxBlockedWriteTimeLimit()) |
| | | || !equals(newCfg.getMaxBlockedWriteTimeLimit(), currentConfig.getMaxBlockedWriteTimeLimit()) |
| | | || !equals(newCfg.getBufferSize(), currentConfig.getBufferSize()) |
| | | || !equals(newCfg.getAcceptBacklog(), currentConfig.getAcceptBacklog()) |
| | | || !equals(newCfg.isUseSSL(), currentConfig.isUseSSL()) |
| | | || !equals(newCfg.getKeyManagerProviderDN(), currentConfig |
| | | .getKeyManagerProviderDN()) |
| | | || !equals(newCfg.getSSLCertNickname(), currentConfig |
| | | .getSSLCertNickname()) |
| | | || !equals(newCfg.getTrustManagerProviderDN(), currentConfig |
| | | .getTrustManagerProviderDN()) |
| | | || !equals(newCfg.getSSLProtocol(), currentConfig.getSSLProtocol()) |
| | | || !equals(newCfg.getSSLCipherSuite(), currentConfig |
| | | .getSSLCipherSuite()) |
| | | || !equals(newCfg.getSSLClientAuthPolicy(), currentConfig |
| | | .getSSLClientAuthPolicy()); |
| | | } |
| | | |
| | | private boolean equals(Object o1, Object o2) |
| | | { |
| | | if (o1 == null) |
| | | { |
| | | return o2 == null; |
| | | } |
| | | return o1.equals(o2); |
| | | || !Objects.equals(newCfg.getKeyManagerProviderDN(), currentConfig.getKeyManagerProviderDN()) |
| | | || !Objects.equals(newCfg.getSSLCertNickname(), currentConfig.getSSLCertNickname()) |
| | | || !Objects.equals(newCfg.getTrustManagerProviderDN(), currentConfig.getTrustManagerProviderDN()) |
| | | || !Objects.equals(newCfg.getSSLProtocol(), currentConfig.getSSLProtocol()) |
| | | || !Objects.equals(newCfg.getSSLCipherSuite(), currentConfig.getSSLCipherSuite()) |
| | | || !Objects.equals(newCfg.getSSLClientAuthPolicy(), currentConfig.getSSLClientAuthPolicy()); |
| | | } |
| | | |
| | | private boolean equals(long l1, long l2) |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2014 ForgeRock AS |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | |
| | | */ |
| | | public final class DSInfo |
| | | { |
| | | |
| | | /** DS server id. */ |
| | | private final int dsId; |
| | | /** DS server url. */ |
| | |
| | | && groupId == dsInfo.getGroupId() |
| | | && protocolVersion == dsInfo.getProtocolVersion() |
| | | && refUrls.equals(dsInfo.getRefUrls()) |
| | | && equals(eclIncludes, dsInfo.getEclIncludes()) |
| | | && equals(eclIncludesForDeletes, dsInfo.getEclIncludesForDeletes()); |
| | | } |
| | | |
| | | private boolean equals(Object o1, Object o2) |
| | | { |
| | | return o1 == null ? o2 == null : o1.equals(o2); |
| | | && Objects.equals(eclIncludes, dsInfo.getEclIncludes()) |
| | | && Objects.equals(eclIncludesForDeletes, dsInfo.getEclIncludesForDeletes()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | package org.opends.server.replication.server.changelog.file; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * Represents a record, which is a pair of key-value. |
| | | * |
| | |
| | | return false; |
| | | } |
| | | Record<?, ?> other = (Record<?, ?>) that; |
| | | return equals(key, other.key) |
| | | && equals(value, other.value); |
| | | } |
| | | |
| | | private boolean equals(Object o1, Object o2) |
| | | { |
| | | return o1 == null ? o2 == null : o1.equals(o2); |
| | | return Objects.equals(key, other.key) |
| | | && Objects.equals(value, other.value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | } |
| | | final Topology other = (Topology) obj; |
| | | return rsServerId == other.rsServerId |
| | | && equals(replicaInfos, other.replicaInfos) |
| | | && equals(rsInfos, other.rsInfos) |
| | | && Objects.equals(replicaInfos, other.replicaInfos) |
| | | && Objects.equals(rsInfos, other.rsInfos) |
| | | && urlsEqual1(replicaInfos, other.replicaInfos) |
| | | && urlsEqual2(rsInfos, other.rsInfos); |
| | | } |
| | | |
| | | private boolean equals(Object o1, Object o2) |
| | | { |
| | | return o1 == null ? o2 == null : o1.equals(o2); |
| | | } |
| | | |
| | | private boolean urlsEqual1(Map<Integer, DSInfo> replicaInfos1, |
| | | Map<Integer, DSInfo> replicaInfos2) |
| | | { |
| | | for (Entry<Integer, DSInfo> entry : replicaInfos1.entrySet()) |
| | | { |
| | | DSInfo dsInfo = replicaInfos2.get(entry.getKey()); |
| | | if (!equals(entry.getValue().getDsUrl(), dsInfo.getDsUrl())) |
| | | if (!Objects.equals(entry.getValue().getDsUrl(), dsInfo.getDsUrl())) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | for (Entry<Integer, ReplicationServerInfo> entry : rsInfos1.entrySet()) |
| | | { |
| | | ReplicationServerInfo rsInfo = rsInfos2.get(entry.getKey()); |
| | | if (!equals(entry.getValue().getServerURL(), rsInfo.getServerURL())) |
| | | if (!Objects.equals(entry.getValue().getServerURL(), rsInfo.getServerURL())) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | |
| | | { |
| | | for (ServerProperty prop : propertiesToCompare) |
| | | { |
| | | if (!equals(server1.get(prop), server2.get(prop))) |
| | | if (!Objects.equals(server1.get(prop), server2.get(prop))) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | return true; |
| | | } |
| | | |
| | | private boolean equals(Object o1, Object o2) |
| | | { |
| | | if (o1 != null) |
| | | { |
| | | return o1.equals(o2); |
| | | } |
| | | return o2 == null; |
| | | } |
| | | |
| | | /** |
| | | * Tells whether we are trying to disable all the replicated suffixes. |
| | | * @param uData the disable replication data provided by the user. |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Return true if and only if o1 and o2 are both null or o1.equals(o2). |
| | | * |
| | | * @param o1 the first object to compare |
| | | * @param o2 the second object to compare |
| | | * @return true iff o1 and o2 are equal |
| | | */ |
| | | public static boolean objectsAreEqual(Object o1, Object o2) |
| | | { |
| | | return Objects.equals(o1, o2); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the best human-readable message for the provided exception. For |
| | | * exceptions defined in the OpenDJ project, it will attempt to use the |
| | |
| | | |
| | | import static java.util.Arrays.*; |
| | | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | private String matchingRuleId; |
| | | private boolean dnAttributes; |
| | | |
| | | |
| | | public void validateFilterFields() throws AssertionError { |
| | | if (!searchFilter.getFilterType().equals(filterType)) { |
| | | throwUnequalError("filterTypes"); |
| | | } |
| | | |
| | | if (!searchFilter.getFilterComponents().equals(filterComponents)) { |
| | | throwUnequalError("filterComponents"); |
| | | } |
| | | |
| | | if (!objectsAreEqual(searchFilter.getNotComponent(), notComponent)) { |
| | | throwUnequalError("notComponent"); |
| | | } |
| | | |
| | | if (!objectsAreEqual(searchFilter.getAssertionValue(), assertionValue)) { |
| | | throwUnequalError("assertionValue"); |
| | | } |
| | | |
| | | if (!objectsAreEqual(searchFilter.getAttributeType(), attributeType)) { |
| | | throwUnequalError("attributeType"); |
| | | } |
| | | |
| | | if (!objectsAreEqual(searchFilter.getSubInitialElement(), subInitialElement)) { |
| | | throwUnequalError("subInitial"); |
| | | } |
| | | |
| | | if (!objectsAreEqual(searchFilter.getSubAnyElements(), subAnyElements)) { |
| | | throwUnequalError("subAny"); |
| | | } |
| | | |
| | | if (!objectsAreEqual(searchFilter.getSubFinalElement(), subFinalElement)) { |
| | | throwUnequalError("subFinal"); |
| | | } |
| | | |
| | | if (!objectsAreEqual(searchFilter.getMatchingRuleID(), matchingRuleId)) { |
| | | throwUnequalError("matchingRuleId"); |
| | | } |
| | | |
| | | if (searchFilter.getDNAttributes() != dnAttributes) { |
| | | throwUnequalError("dnAttributes"); |
| | | } |
| | | assertEquals(searchFilter.getFilterType(), filterType, errorMsg("filterTypes")); |
| | | assertEquals(searchFilter.getFilterComponents(), filterComponents, errorMsg("filterComponents")); |
| | | assertEquals(searchFilter.getNotComponent(), notComponent, "notComponent"); |
| | | assertEquals(searchFilter.getAssertionValue(), assertionValue, "assertionValue"); |
| | | assertEquals(searchFilter.getAttributeType(), attributeType, errorMsg("attributeType")); |
| | | assertEquals(searchFilter.getSubInitialElement(), subInitialElement, errorMsg("subInitial")); |
| | | assertEquals(searchFilter.getSubAnyElements(), subAnyElements, errorMsg("subAny")); |
| | | assertEquals(searchFilter.getSubFinalElement(), subFinalElement, errorMsg("subFinal")); |
| | | assertEquals(searchFilter.getMatchingRuleID(), matchingRuleId, errorMsg("matchingRuleId")); |
| | | assertEquals(searchFilter.getDNAttributes(), dnAttributes, errorMsg("dnAttributes")); |
| | | } |
| | | |
| | | |
| | | private void throwUnequalError(String message) throws AssertionError { |
| | | throw new AssertionError("Filter differs from what is expected '" + message + "' differ.\n" + toString()); |
| | | private String errorMsg(String message) { |
| | | return "Filter differs from what is expected '" + message + "' differ.\n" + toString(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "FilterDescription: \n" + |