Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RepositoryReference.toString() to simplify debugging #346

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 IBM Corporation and others.
* Copyright (c) 2008, 2023 IBM Corporation 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
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* IBM Corporation - initial API and implementation
* Cloudsmith Inc - public API
*******************************************************************************/
package org.eclipse.equinox.p2.repository.spi;

import java.net.URI;
import java.util.Objects;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryReference;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
Expand All @@ -27,7 +28,7 @@
* @since 2.0
* @noextend This class is not intended to be subclassed by clients.
*/
public class RepositoryReference implements IRepositoryReference {

Check warning on line 31 in bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/RepositoryReference.java

View workflow job for this annotation

GitHub Actions / build / Verify Linux

RepositoryReference implements non-API interface IRepositoryReference

Check warning on line 31 in bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/RepositoryReference.java

View workflow job for this annotation

GitHub Actions / build / Verify Windows

RepositoryReference implements non-API interface IRepositoryReference

Check warning on line 31 in bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/spi/RepositoryReference.java

View workflow job for this annotation

GitHub Actions / build / Verify MacOS

RepositoryReference implements non-API interface IRepositoryReference
private final URI location;
private final int type;
private final int options;
Expand All @@ -36,17 +37,17 @@
/**
* Creates a reference to another repository.
*
* The {@link IRepository#ENABLED} option flag controls whether the
* The {@link IRepository#ENABLED} option flag controls whether the
* referenced repository should be marked as enabled when added to the repository
* manager. If this flag is set, the repository will be marked as enabled when
* added to the repository manager. If this flag is missing, the repository will
* be marked as disabled.
*
*
* @param location the location of the repository to add
* @param nickname The nickname of the repository, or <code>null</code>
* @param type the repository type (currently either {@link IRepository#TYPE_METADATA}
* or {@link IRepository#TYPE_ARTIFACT}).
* @param options bit-wise or of option constants (currently either
* @param options bit-wise or of option constants (currently either
* {@link IRepository#ENABLED} or {@link IRepository#NONE}).
* @see IMetadataRepositoryManager#setEnabled(URI, boolean)
*/
Expand All @@ -57,21 +58,19 @@
this.nickname = nickname;
}

@Override
public int hashCode() {
return Objects.hash(location, type);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (!(obj instanceof IRepositoryReference))
return false;
IRepositoryReference other = (IRepositoryReference) obj;
if (location == null) {
if (other.getLocation() != null)
return false;
} else if (!location.equals(other.getLocation()))
return false;
if (type != other.getType())
return false;
return true;
}
return obj instanceof IRepositoryReference other //
&& Objects.equals(location, other.getLocation()) //
&& type == other.getType();
}

@Override
Expand All @@ -95,12 +94,10 @@
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((location == null) ? 0 : location.hashCode());
result = prime * result + type;
return result;
public String toString() {
String status = ((options & IRepository.NONE) != 0) ? "enabled" : " disabled"; //$NON-NLS-1$//$NON-NLS-2$
return "location=" + location + (nickname != null && !nickname.isBlank() ? " name=" + nickname : "") + " " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
+ status;
}

}
Loading