Created
June 28, 2017 12:06
-
-
Save circlee/01914e773b40d386187c8e2669708fbd to your computer and use it in GitHub Desktop.
ResourceSupport
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Source code recreated from a .class file by IntelliJ IDEA | |
// (powered by Fernflower decompiler) | |
// | |
package org.springframework.hateoas; | |
import com.fasterxml.jackson.annotation.JsonIgnore; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Iterator; | |
import java.util.List; | |
import javax.xml.bind.annotation.XmlElement; | |
import org.springframework.util.Assert; | |
public class ResourceSupport implements Identifiable<Link> { | |
private final List<Link> links = new ArrayList(); | |
public ResourceSupport() { | |
} | |
@JsonIgnore | |
public Link getId() { | |
return this.getLink("self"); | |
} | |
public void add(Link link) { | |
Assert.notNull(link, "Link must not be null!"); | |
this.links.add(link); | |
} | |
public void add(Iterable<Link> links) { | |
Assert.notNull(links, "Given links must not be null!"); | |
Iterator var2 = links.iterator(); | |
while(var2.hasNext()) { | |
Link candidate = (Link)var2.next(); | |
this.add(candidate); | |
} | |
} | |
public void add(Link... links) { | |
Assert.notNull(links, "Given links must not be null!"); | |
this.add((Iterable)Arrays.asList(links)); | |
} | |
public boolean hasLinks() { | |
return !this.links.isEmpty(); | |
} | |
public boolean hasLink(String rel) { | |
return this.getLink(rel) != null; | |
} | |
@XmlElement( | |
name = "link", | |
namespace = "http://www.w3.org/2005/Atom" | |
) | |
@JsonProperty("links") | |
public List<Link> getLinks() { | |
return this.links; | |
} | |
public void removeLinks() { | |
this.links.clear(); | |
} | |
public Link getLink(String rel) { | |
Iterator var2 = this.links.iterator(); | |
Link link; | |
do { | |
if(!var2.hasNext()) { | |
return null; | |
} | |
link = (Link)var2.next(); | |
} while(!link.getRel().equals(rel)); | |
return link; | |
} | |
public String toString() { | |
return String.format("links: %s", new Object[]{this.links.toString()}); | |
} | |
public boolean equals(Object obj) { | |
if(this == obj) { | |
return true; | |
} else if(obj != null && obj.getClass().equals(this.getClass())) { | |
ResourceSupport that = (ResourceSupport)obj; | |
return this.links.equals(that.links); | |
} else { | |
return false; | |
} | |
} | |
public int hashCode() { | |
return this.links.hashCode(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment