1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Deprecate and remove use of method now in JVM (Object.equals)

Change-Id: Iec34f0f8388d7d76ce63f88cfc7d16534e5a7d84
This commit is contained in:
Jonah Graham 2020-05-30 22:02:10 -04:00
parent 125afa92dc
commit cfc3278454
13 changed files with 43 additions and 27 deletions

View file

@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.cdt.core.settings.model;
import java.util.Objects;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
@ -156,11 +158,11 @@ public final class CLibraryFileEntry extends ACPathEntry implements ICLibraryFil
}
private boolean sourceAttachmentSettingsEqual(CLibraryFileEntry otherEntry) {
if (!CDataUtil.objectsEqual(fSourceAttachmentPath, otherEntry.fSourceAttachmentPath))
if (!Objects.equals(fSourceAttachmentPath, otherEntry.fSourceAttachmentPath))
return false;
if (!CDataUtil.objectsEqual(fSourceAttachmentRootPath, otherEntry.fSourceAttachmentRootPath))
if (!Objects.equals(fSourceAttachmentRootPath, otherEntry.fSourceAttachmentRootPath))
return false;
if (!CDataUtil.objectsEqual(fSourceAttachmentPrefixMapping, otherEntry.fSourceAttachmentPrefixMapping))
if (!Objects.equals(fSourceAttachmentPrefixMapping, otherEntry.fSourceAttachmentPrefixMapping))
return false;
return true;
}

View file

@ -14,6 +14,7 @@
package org.eclipse.cdt.core.settings.model.extension.impl;
import java.util.Arrays;
import java.util.Objects;
import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
import org.eclipse.cdt.core.settings.model.ICOutputEntry;
@ -80,7 +81,7 @@ public class CDefaultBuildData extends CBuildData {
@Override
public void setBuilderCWD(IPath path) {
if (CDataUtil.objectsEqual(path, fCWD))
if (Objects.equals(path, fCWD))
return;
fCWD = path;

View file

@ -15,6 +15,7 @@ package org.eclipse.cdt.core.settings.model.extension.impl;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Objects;
import org.eclipse.cdt.core.cdtvariables.ICdtVariablesContributor;
import org.eclipse.cdt.core.settings.model.CConfigurationStatus;
@ -192,7 +193,7 @@ public class CDefaultConfigurationData extends CConfigurationData {
@Override
public void setDescription(String description) {
if (CDataUtil.objectsEqual(description, fDescription))
if (Objects.equals(description, fDescription))
return;
fDescription = description;
@ -238,7 +239,7 @@ public class CDefaultConfigurationData extends CConfigurationData {
@Override
public void setName(String name) {
if (CDataUtil.objectsEqual(name, fName))
if (Objects.equals(name, fName))
return;
fName = name;
setModified(true);

View file

@ -15,6 +15,7 @@ package org.eclipse.cdt.core.settings.model.extension.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
@ -92,7 +93,7 @@ public class CDefaultFolderData extends CFolderData {
@Override
public void setPath(IPath path) {
if (CDataUtil.objectsEqual(path, fPath))
if (Objects.equals(path, fPath))
return;
fPath = path;

View file

@ -14,6 +14,7 @@
package org.eclipse.cdt.core.settings.model.extension.impl;
import java.util.Arrays;
import java.util.Objects;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
@ -132,7 +133,7 @@ public class CDefaultLanguageData extends CLanguageData {
@Override
public void setLanguageId(String id) {
if (CDataUtil.objectsEqual(id, fLanguageId))
if (Objects.equals(id, fLanguageId))
return;
fLanguageId = id;

View file

@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
@ -107,10 +108,12 @@ public class CDataUtil {
suffix;
}
/**
* @deprecated Use {@link Object#equals(Object)}
*/
@Deprecated
public static boolean objectsEqual(Object o1, Object o2) {
if (o1 == null)
return o2 == null;
return o1.equals(o2);
return Objects.equals(o1, o2);
}
public static String arrayToString(String[] array, String separator) {

View file

@ -23,6 +23,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
@ -370,7 +371,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS
public void setName(String name) {
if (isReadOnly())
throw ExceptionFactory.createIsReadOnlyException();
if (!CDataUtil.objectsEqual(fName, name)) {
if (!Objects.equals(fName, name)) {
fName = name;
fIsModified = true;
}
@ -383,7 +384,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS
public void setId(String id) {
if (isReadOnly())
throw ExceptionFactory.createIsReadOnlyException();
if (!CDataUtil.objectsEqual(fId, id)) {
if (!Objects.equals(fId, id)) {
fId = id;
fIsModified = true;
}
@ -392,7 +393,7 @@ public class CConfigurationSpecSettings implements ICSettingsStorage, ILanguageS
void setBuildSystemId(String id) {
if (isReadOnly())
throw ExceptionFactory.createIsReadOnlyException();
if (!CDataUtil.objectsEqual(fBuildSystemId, id)) {
if (!Objects.equals(fBuildSystemId, id)) {
fBuildSystemId = id;
fIsModified = true;
}

View file

@ -40,6 +40,7 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
@ -1404,7 +1405,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
CConfigurationSpecSettings oldSettings = ((IInternalCCfgInfo) oldCfg).getSpecSettings();
String newId = newSettings.getCOwnerId();
String oldId = oldSettings.getCOwnerId();
if (!CDataUtil.objectsEqual(newId, oldId))
if (!Objects.equals(newId, oldId))
flags |= ICDescriptionDelta.OWNER;
Map<String, CConfigExtensionReference[]> newMap = newSettings.getExtensionMapCopy();
@ -1505,7 +1506,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
delta.addChangeFlags(ICDescriptionDelta.NAME);
}
if (!CDataUtil.objectsEqual(newCfg.getDescription(), oldCfg.getDescription())) {
if (!Objects.equals(newCfg.getDescription(), oldCfg.getDescription())) {
delta.addChangeFlags(ICDescriptionDelta.DESCRIPTION);
}
@ -1808,7 +1809,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
CProjectDescriptionDelta delta = new CProjectDescriptionDelta(newLs, oldLs);
if (delta.getDeltaKind() == ICDescriptionDelta.CHANGED) {
if (!CDataUtil.objectsEqual(newLs.getLanguageId(), oldLs.getLanguageId()))
if (!Objects.equals(newLs.getLanguageId(), oldLs.getLanguageId()))
delta.addChangeFlags(ICDescriptionDelta.LANGUAGE_ID);
int kinds[] = KindBasedStore.getLanguageEntryKinds();

View file

@ -24,6 +24,7 @@ import java.text.MessageFormat;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Objects;
import org.eclipse.cdt.core.AbstractCExtension;
import org.eclipse.cdt.core.CCorePlugin;
@ -206,7 +207,7 @@ final public class CConfigBasedDescriptor implements ICDescriptor {
@Override
public void setExtensionData(String key, String value) throws CoreException {
if (!CDataUtil.objectsEqual(fCfgExtRef.getExtensionData(key), value)) {
if (!Objects.equals(fCfgExtRef.getExtensionData(key), value)) {
fIsDirty = true;
fCfgExtRef.setExtensionData(key, value);
checkApply();

View file

@ -14,6 +14,7 @@
package org.eclipse.cdt.internal.core.cdtvariables;
import java.util.Arrays;
import java.util.Objects;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
@ -188,7 +189,7 @@ public class CdtVariableManager implements ICdtVariableManager {
}
private static boolean variablesEqual(ICdtVariable var1, ICdtVariable var2) {
if (CDataUtil.objectsEqual(var1, var2))
if (Objects.equals(var1, var2))
return true;
if (var1 == null || var2 == null)
@ -207,7 +208,7 @@ public class CdtVariableManager implements ICdtVariableManager {
if (!Arrays.equals(v1, v2))
return false;
} else {
if (!CDataUtil.objectsEqual(var1.getStringValue(), var2.getStringValue()))
if (!Objects.equals(var1.getStringValue(), var2.getStringValue()))
return false;
}
} catch (CdtVariableException e) {

View file

@ -21,6 +21,7 @@ import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
@ -292,7 +293,7 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
if (fVar == otherVar)
return true;
if (!CDataUtil.objectsEqual(fVar.getName(), otherVar.getName()))
if (!Objects.equals(fVar.getName(), otherVar.getName()))
return false;
if (fNameOnly)
@ -310,7 +311,7 @@ public class UserDefinedVariableSupplier extends CoreMacroSupplierBase {
}
} else {
try {
if (!CDataUtil.objectsEqual(fVar.getStringValue(), otherVar.getStringValue()))
if (!Objects.equals(fVar.getStringValue(), otherVar.getStringValue()))
return false;
} catch (CdtVariableException e) {
CCorePlugin.log(e);

View file

@ -19,6 +19,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
@ -251,8 +252,8 @@ public class Cygwin {
String envCygwinHomeValue = varCygwinHome != null ? varCygwinHome.getValue() : null;
// isCygwinLocationCached is used to figure fact of caching when all cached objects are null
if (isCygwinLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached)
&& CDataUtil.objectsEqual(envCygwinHomeValue, envCygwinHomeValueCached)) {
if (isCygwinLocationCached && Objects.equals(envPathValue, envPathValueCached)
&& Objects.equals(envCygwinHomeValue, envCygwinHomeValueCached)) {
return cygwinLocation;
}

View file

@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core;
import java.io.File;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.WeakHashMap;
@ -298,8 +299,8 @@ public class MinGW {
// isMinGWLocationCached is used to figure fact of caching when all
// cached objects are null
if (isMinGWLocationCached && CDataUtil.objectsEqual(envPathValue, envPathValueCached)
&& CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached)) {
if (isMinGWLocationCached && Objects.equals(envPathValue, envPathValueCached)
&& Objects.equals(envMinGWHomeValue, envMinGWHomeValueCached)) {
return minGWLocation;
}
@ -337,7 +338,7 @@ public class MinGW {
// isMSysLocationCached is used to figure whether it was cached when all
// cached objects are null
if (isMSysLocationCached && CDataUtil.objectsEqual(envMinGWHomeValue, envMinGWHomeValueCached_msys)) {
if (isMSysLocationCached && Objects.equals(envMinGWHomeValue, envMinGWHomeValueCached_msys)) {
return mSysLocation;
}