Skip to content

Commit

Permalink
[146] Remove usage of com.google.common.base.Objects
Browse files Browse the repository at this point in the history
Bug: #146
Signed-off-by: Pierre-Charles David <[email protected]>
  • Loading branch information
pcdavid committed Jul 31, 2024
1 parent e874a1a commit 8a5a68c
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 86 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2021 THALES GLOBAL SERVICES.
* Copyright (c) 2010, 2024 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.sirius.diagram.sequence.business.api.util;

import com.google.common.base.Objects;
import java.util.Objects;

/**
* Generic helper class to hold two elements of the same type. In some
Expand Down Expand Up @@ -62,32 +62,22 @@ public T second() {
return second;
}

/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return Objects.hashCode(first, second);
return Objects.hash(first, second);
}

/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
boolean result = false;
if (this == obj) {
result = true;
} else if (obj instanceof Pair<?>) {
Pair<?> that = (Pair<?>) obj;
result = Objects.equal(this.first, that.first) && Objects.equal(this.second, that.second);
} else if (obj instanceof Pair<?> that) {
result = Objects.equals(this.first, that.first) && Objects.equals(this.second, that.second);
}
return result;
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "<" + String.valueOf(first) + ", " + String.valueOf(second) + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2021 THALES GLOBAL SERVICES and others.
* Copyright (c) 2010, 2024 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.sirius.diagram.sequence.business.internal.operation;

import java.util.Objects;

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.View;
Expand All @@ -21,8 +23,6 @@
import org.eclipse.sirius.diagram.sequence.tool.internal.Messages;
import org.eclipse.sirius.diagram.ui.business.internal.operation.AbstractModelChangeOperation;

import com.google.common.base.Objects;

/**
* An operation to set the vertical range of a sequence message.
*
Expand Down Expand Up @@ -102,12 +102,12 @@ public Void execute() {
Edge currentMessage = message;

currentMessage.setSource(source);
if (currentMessage.getElement() instanceof DEdge && source.getElement() instanceof EdgeTarget) {
((DEdge) currentMessage.getElement()).setSourceNode((EdgeTarget) source.getElement());
if (currentMessage.getElement() instanceof DEdge edge && source.getElement() instanceof EdgeTarget edgeTarget) {
edge.setSourceNode(edgeTarget);
}
currentMessage.setTarget(target);
if (currentMessage.getElement() instanceof DEdge && target.getElement() instanceof EdgeTarget) {
((DEdge) currentMessage.getElement()).setTargetNode((EdgeTarget) target.getElement());
if (currentMessage.getElement() instanceof DEdge edge && target.getElement() instanceof EdgeTarget edgeTarget) {
edge.setTargetNode(edgeTarget);
}

int srcTop = sourceBounds.getTop().y;
Expand All @@ -132,7 +132,7 @@ public Void execute() {
private boolean isMessageToSelf(Edge msg) {
View src = msg.getSource();
View tgt = msg.getTarget();
return Objects.equal(src, tgt) || Objects.equal(src.eContainer(), tgt) || Objects.equal(src, tgt.eContainer());
return Objects.equals(src, tgt) || Objects.equals(src.eContainer(), tgt) || Objects.equals(src, tgt.eContainer());
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 THALES GLOBAL SERVICES.
* Copyright (c) 2017, 2024 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -13,6 +13,7 @@
package org.eclipse.sirius.diagram.ui.edit.internal.part.listener;

import java.util.Iterator;
import java.util.Objects;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
Expand All @@ -26,8 +27,6 @@
import org.eclipse.sirius.diagram.ui.tools.internal.figure.SynchronizeStatusFigure;
import org.eclipse.ui.PlatformUI;

import com.google.common.base.Objects;

/**
* When the DDiagram synchronize state changes, this ResourceSet listener will update </br>
* - the status bar </br>
Expand Down Expand Up @@ -74,7 +73,7 @@ public void resourceSetChanged(ResourceSetChangeEvent event) {
while (notifs.hasNext()) {
Notification notif = notifs.next();

if (Objects.equal(resolveSemanticElement, notif.getNotifier())) {
if (Objects.equals(resolveSemanticElement, notif.getNotifier())) {
SynchronizeStatusFigure.updateNotification((DiagramRootEditPart) diagramEditor.getDiagramEditPart().getRoot());
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2016 THALES GLOBAL SERVICES.
* Copyright (c) 2009, 2024 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -12,12 +12,12 @@
*******************************************************************************/
package org.eclipse.sirius.diagram.ui.tools.internal.format.semantic;

import java.util.Objects;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.sirius.diagram.ui.tools.api.format.FormatDataKey;

import com.google.common.base.Objects;

/**
* Common behavior for Semantic*FormatDataKey classes.
*
Expand Down Expand Up @@ -52,21 +52,11 @@ protected String getSemanticElementURIFragment() {
return semanticElementURIFragment;
}

/**
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
return Objects.hashCode(semanticElementURIFragment);
return Objects.hash(semanticElementURIFragment);
}

/**
* {@inheritDoc}
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(final Object obj) {
boolean result = false;
Expand All @@ -78,25 +68,16 @@ public boolean equals(final Object obj) {
return result;
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "Key ID: " + getId(); //$NON-NLS-1$
}

/**
* {@inheritDoc}
*/
@Override
public String getId() {
return getSemanticElementURIFragment();
}

/**
* {@inheritDoc}
*/
@Override
public int compareTo(final AbstractSemanticFormatDataKey o) {
return getId().compareTo(o.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2021 THALES GLOBAL SERVICES.
* Copyright (c) 2009, 2024 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.sirius.diagram.business.internal.helper.task;

import java.util.Objects;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
Expand All @@ -30,8 +32,6 @@
import org.eclipse.sirius.diagram.tools.api.Messages;
import org.eclipse.sirius.tools.api.SiriusPlugin;

import com.google.common.base.Objects;

/**
* Default command for dropin node.
*
Expand Down Expand Up @@ -120,7 +120,7 @@ private void handleDNodeListCase(DDiagram parentDiagram) {
} else if (abstractDNode instanceof DNode) {
((DNodeList) target).getOwnedBorderedNodes().add((DNode) abstractDNode);
}
if (!Objects.equal(abstractDNode, droppedDiagramElement)) {
if (!Objects.equals(abstractDNode, droppedDiagramElement)) {
if (moveEdges) {
DnDTasksOperations.moveEdges(target, semanticContainer, droppedDiagramElement, abstractDNode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.sirius.diagram.business.internal.metamodel.helper;

import java.util.List;
import java.util.Objects;

import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IPreferencesService;
Expand Down Expand Up @@ -104,8 +105,6 @@
import org.eclipse.sirius.viewpoint.description.style.LabelStyleDescription;
import org.eclipse.sirius.viewpoint.description.style.StyleDescription;

import com.google.common.base.Objects;

/**
* This helper class contains utility methods to create and update (refresh) concrete style instances from a style
* description. This helper modify sometimes the diagram element to which apply the style (width, height, ...).
Expand Down Expand Up @@ -293,7 +292,7 @@ private void updateEdgeStyle(final EdgeStyleDescription edgeDescription, final E
} catch (final EvaluationException e) {
// silent.
}
if (!Objects.equal(size, edgeStyle.getSize())) {
if (!Objects.equals(size, edgeStyle.getSize())) {
edgeStyle.setSize(size);
}
}
Expand Down Expand Up @@ -775,7 +774,7 @@ private void updateBorderedStyleFeatures(BorderedStyleDescription description, B
&& !style.getCustomFeatures().contains(DiagramPackage.Literals.BORDERED_STYLE__BORDER_SIZE.getName())) {
try {
Integer borderSize = interpreter.evaluateInteger(((AbstractDNode) style.eContainer()).getTarget(), description.getBorderSizeComputationExpression());
if (!Objects.equal(borderSize, style.getBorderSize())) {
if (!Objects.equals(borderSize, style.getBorderSize())) {
style.setBorderSize(borderSize);
}
} catch (final EvaluationException e) {
Expand Down Expand Up @@ -962,7 +961,7 @@ private void updateWorkspaceImage(final WorkspaceImage image, final WorkspaceIma
if (image.eContainer() instanceof DNode && description.getSizeComputationExpression() != null) {
final DNode node = (DNode) image.eContainer();
Integer size = computeStyleSize(node.getTarget(), description);
if (Objects.equal(-1, size)) {
if (Objects.equals(-1, size)) {
// real image size
if (!size.equals(node.getHeight())) {
node.setHeight(size);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2021 THALES GLOBAL SERVICES and others.
* Copyright (c) 2007, 2024 THALES GLOBAL SERVICES and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import org.eclipse.emf.common.util.BasicEList;
Expand Down Expand Up @@ -93,7 +94,6 @@
import org.eclipse.sirius.viewpoint.description.style.StylePackage;
import org.eclipse.sirius.viewpoint.description.style.TooltipStyleDescription;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;

Expand Down Expand Up @@ -596,7 +596,7 @@ private void refreshTooltip(final DDiagramElement elt, final TooltipStyleDescrip
if (!StringUtil.isEmpty(style.getTooltipExpression())) {
final String oldValue = elt.getTooltipText();
final String newValue = computeTooltip(elt, style);
if (!Objects.equal(newValue, oldValue)) {
if (!Objects.equals(newValue, oldValue)) {
elt.setTooltipText(newValue);
}
}
Expand Down
Loading

0 comments on commit 8a5a68c

Please sign in to comment.