Skip to content

Commit

Permalink
Add AbstractRepository#toString
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laeubi committed May 11, 2024
1 parent c9f0582 commit fabf6d0
Showing 1 changed file with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,7 +42,7 @@ public abstract class AbstractRepository<T> 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
Expand Down Expand Up @@ -126,7 +126,7 @@ public synchronized String getProvider() {

/**
* Returns the provisioning agent used by this repository
*
*
* @return the provisioning agent
*/
@Override
Expand Down Expand Up @@ -159,7 +159,7 @@ public boolean isModifiable() {

/**
* Sets the description of this repository
*
*
* @param description the repository description
*/
public synchronized void setDescription(String description) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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<String, String> 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();
}
}

0 comments on commit fabf6d0

Please sign in to comment.