aQute.bnd.resource.repository.ResourceDescriptorImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biz.aQute.bndlib Show documentation
Show all versions of biz.aQute.bndlib Show documentation
bndlib: A Swiss Army Knife for OSGi
package aQute.bnd.resource.repository;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor;
public class ResourceDescriptorImpl extends ResourceDescriptor implements Comparable {
public Set repositories = new HashSet();
public ResourceDescriptorImpl() {}
public ResourceDescriptorImpl(ResourceDescriptor ref) throws IllegalAccessException {
for (Field f : ref.getClass().getFields()) {
f.set(this, f.get(ref));
}
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(id);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ResourceDescriptorImpl other = (ResourceDescriptorImpl) obj;
if (!Arrays.equals(id, other.id))
return false;
return true;
}
public int compareTo(ResourceDescriptorImpl var0) {
for (int i = 0; i < id.length; i++) {
if (i >= var0.id.length)
return 1;
if (id[i] > var0.id[i])
return 1;
if (id[i] < var0.id[i])
return -1;
}
if (var0.id.length > id.length)
return -1;
return 0;
}
public String toString() {
return bsn + "-" + version;
}
}