| 1 | |
package org.jbehave.core.io.rest; |
| 2 | |
|
| 3 | |
import static org.apache.commons.lang.StringUtils.substringAfterLast; |
| 4 | |
|
| 5 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
| 6 | |
import org.apache.commons.lang.builder.ToStringStyle; |
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
public class Resource { |
| 12 | |
|
| 13 | |
private final String uri; |
| 14 | |
private final String name; |
| 15 | |
private final String parentName; |
| 16 | |
private String text; |
| 17 | |
private String breadcrumbs; |
| 18 | |
|
| 19 | |
public Resource(String uri) { |
| 20 | 6 | this(uri, substringAfterLast(uri, "/")); |
| 21 | 6 | } |
| 22 | |
|
| 23 | |
public Resource(String uri, String name) { |
| 24 | 6 | this(uri, name, null); |
| 25 | 6 | } |
| 26 | |
|
| 27 | 10 | public Resource(String uri, String name, String parentName) { |
| 28 | 10 | this.uri = uri; |
| 29 | 10 | this.name = name; |
| 30 | 10 | this.parentName = parentName; |
| 31 | 10 | } |
| 32 | |
|
| 33 | |
public String getURI() { |
| 34 | 10 | return uri; |
| 35 | |
} |
| 36 | |
|
| 37 | |
public String getName() { |
| 38 | 4 | return name; |
| 39 | |
} |
| 40 | |
|
| 41 | |
public String getParentName() { |
| 42 | 2 | return parentName; |
| 43 | |
} |
| 44 | |
|
| 45 | |
public boolean hasParent() { |
| 46 | 6 | return parentName != null; |
| 47 | |
} |
| 48 | |
|
| 49 | |
public void setText(String text) { |
| 50 | 4 | this.text = text; |
| 51 | 4 | } |
| 52 | |
|
| 53 | |
public String getText() { |
| 54 | 4 | return text; |
| 55 | |
} |
| 56 | |
|
| 57 | |
public boolean hasText() { |
| 58 | 2 | return text != null; |
| 59 | |
} |
| 60 | |
|
| 61 | |
public String getBreadcrumbs() { |
| 62 | 2 | return breadcrumbs; |
| 63 | |
} |
| 64 | |
|
| 65 | |
public void setBreadcrumbs(String breadcrumbs) { |
| 66 | 2 | this.breadcrumbs = breadcrumbs; |
| 67 | 2 | } |
| 68 | |
|
| 69 | |
public boolean hasBreadcrumbs() { |
| 70 | 4 | return breadcrumbs != null; |
| 71 | |
} |
| 72 | |
|
| 73 | |
public String toString() { |
| 74 | 0 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); |
| 75 | |
} |
| 76 | |
|
| 77 | |
} |