From fabf6d030b8417ff255de28bc02a4a51e55dd537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 11 May 2024 07:24:25 +0200 Subject: [PATCH] Add AbstractRepository#toString Currently in a debug session it is quite annoying as repositories usually have only the default string what is not really helpful. This adds a AbstractRepository#toString to print the name and URI if available. --- .../p2/repository/spi/AbstractRepository.java | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/AbstractRepository.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/AbstractRepository.java index 9eb3f67378..2eec99ff60 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/AbstractRepository.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/AbstractRepository.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * EclipseSource - Ongoing development @@ -42,7 +42,7 @@ public abstract class AbstractRepository extends PlatformObject implements IR /** * Creates a new repository with the given attributes. - * + * * @param agent the provisioning agent to be used by this repository * @param name the repository name * @param type the repository type @@ -126,7 +126,7 @@ public synchronized String getProvider() { /** * Returns the provisioning agent used by this repository - * + * * @return the provisioning agent */ @Override @@ -159,7 +159,7 @@ public boolean isModifiable() { /** * Sets the description of this repository - * + * * @param description the repository description */ public synchronized void setDescription(String description) { @@ -168,7 +168,7 @@ public synchronized void setDescription(String description) { /** * Sets the name of this repository - * + * * @param value the repository name */ public synchronized void setName(String value) { @@ -196,7 +196,7 @@ public synchronized String setProperty(String key, String value) { /** * Sets the provider of this repository - * + * * @param provider the repository provider */ public synchronized void setProvider(String provider) { @@ -205,7 +205,7 @@ public synchronized void setProvider(String provider) { /** * Sets the type of this repository - * + * * @param type the repository type */ protected synchronized void setType(String type) { @@ -214,7 +214,7 @@ protected synchronized void setType(String type) { /** * Sets the location of this repository - * + * * @param location the repository location */ protected synchronized void setLocation(URI location) { @@ -223,7 +223,7 @@ protected synchronized void setLocation(URI location) { /** * Sets the version of this repository - * + * * @param version the repository version */ protected synchronized void setVersion(String version) { @@ -232,10 +232,26 @@ protected synchronized void setVersion(String version) { /** * Sets the properties of this repository - * + * * @param properties the repository provider */ protected synchronized void setProperties(Map properties) { this.properties = properties; } + + @Override + public String toString() { + String repoName = getName(); + URI uri = getLocation(); + if (repoName != null) { + if (uri == null) { + return name; + } + return String.format("%s (%s)", name, uri); //$NON-NLS-1$ + } + if (uri != null) { + return uri.toString(); + } + return super.toString(); + } }