
io.katharsis.resource.ResourceIdentifier Maven / Gradle / Ivy
The newest version!
package io.katharsis.resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ResourceIdentifier implements Comparable {
private String id;
private String type;
public ResourceIdentifier() {
}
public ResourceIdentifier(String id, String type) {
this.id = id;
this.type = type;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public ResourceIdentifier clone() {
return new ResourceIdentifier(id, type);
}
public static Object fromData(Object data) {
if (data == null) {
return null;
}
if (data instanceof Iterable) {
List result = new ArrayList<>();
for (ResourceIdentifier id : (Iterable) data) {
result.add(id.clone());
}
return result;
} else {
ResourceIdentifier id = (ResourceIdentifier) data;
return id.clone();
}
}
@Override
public int hashCode() {
return Objects.hash(id, type);
}
@Override
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != this.getClass())
return false;
ResourceIdentifier other = (ResourceIdentifier) obj;
return Objects.equals(id, other.id) && Objects.equals(type, other.type);
}
@Override
public int compareTo(ResourceIdentifier o) {
int d = type.compareTo(o.type);
if (d != 0) {
return d;
}
return id.compareTo(o.id);
}
@Override
public String toString() {
return "ResourceIdentifier{" +
"id='" + id + '\'' +
", type='" + type + '\'' +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy