EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.savvis.vpdc.domain]

COVERAGE SUMMARY FOR SOURCE FILE [ResourceImpl.java]

nameclass, %method, %block, %line, %
ResourceImpl.java100% (2/2)83%  (15/18)76%  (202/266)70%  (42/60)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ResourceImpl$Builder100% (1/1)86%  (6/7)69%  (35/51)91%  (10/11)
fromResource (ResourceImpl): ResourceImpl$Builder 0%   (0/1)0%   (0/16)0%   (0/1)
ResourceImpl$Builder (): void 100% (1/1)100% (3/3)100% (1/1)
build (): ResourceImpl 100% (1/1)100% (12/12)100% (1/1)
href (URI): ResourceImpl$Builder 100% (1/1)100% (5/5)100% (2/2)
id (String): ResourceImpl$Builder 100% (1/1)100% (5/5)100% (2/2)
name (String): ResourceImpl$Builder 100% (1/1)100% (5/5)100% (2/2)
type (String): ResourceImpl$Builder 100% (1/1)100% (5/5)100% (2/2)
     
class ResourceImpl100% (1/1)82%  (9/11)78%  (167/215)65%  (32/49)
compareTo (Resource): int 0%   (0/1)0%   (0/11)0%   (0/1)
toBuilder (): ResourceImpl$Builder 0%   (0/1)0%   (0/3)0%   (0/1)
equals (Object): boolean 100% (1/1)60%  (51/85)46%  (13/28)
ResourceImpl (String, String, String, URI): void 100% (1/1)100% (15/15)100% (6/6)
builder (): ResourceImpl$Builder 100% (1/1)100% (4/4)100% (1/1)
getHref (): URI 100% (1/1)100% (3/3)100% (1/1)
getId (): String 100% (1/1)100% (3/3)100% (1/1)
getName (): String 100% (1/1)100% (3/3)100% (1/1)
getType (): String 100% (1/1)100% (3/3)100% (1/1)
hashCode (): int 100% (1/1)100% (58/58)100% (7/7)
toString (): String 100% (1/1)100% (27/27)100% (1/1)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds.savvis.vpdc.domain;
20 
21import java.net.URI;
22 
23/**
24 * Location of a Rest resource
25 * 
26 * @author Adrian Cole
27 * 
28 */
29public class ResourceImpl implements Resource {
30   public static Builder builder() {
31      return new Builder();
32   }
33 
34   public static class Builder {
35      protected String id;
36      protected String name;
37      protected String type;
38      protected URI href;
39 
40      public Builder id(String id) {
41         this.id = id;
42         return this;
43      }
44 
45      public Builder name(String name) {
46         this.name = name;
47         return this;
48      }
49 
50      public Builder type(String type) {
51         this.type = type;
52         return this;
53      }
54 
55      public Builder href(URI href) {
56         this.href = href;
57         return this;
58      }
59 
60      public ResourceImpl build() {
61         return new ResourceImpl(id, name, type, href);
62      }
63 
64      public static Builder fromResource(ResourceImpl in) {
65         return new Builder().id(in.getId()).name(in.getName()).type(in.getType()).href(in.getHref());
66      }
67   }
68 
69   protected final String id;
70   protected final String name;
71   protected final String type;
72   protected final URI href;
73 
74   public ResourceImpl(String id, String name, String type, URI href) {
75      this.id = id;
76      this.name = name;
77      this.type = type;
78      this.href = href;
79   }
80 
81   public String getId() {
82      return id;
83   }
84 
85   public String getName() {
86      return name;
87   }
88 
89   public String getType() {
90      return type;
91   }
92 
93   public URI getHref() {
94      return href;
95   }
96 
97   public int compareTo(Resource that) {
98      return (this == that) ? 0 : getHref().compareTo(that.getHref());
99   }
100 
101   @Override
102   public int hashCode() {
103      final int prime = 31;
104      int result = 1;
105      result = prime * result + ((href == null) ? 0 : href.hashCode());
106      result = prime * result + ((id == null) ? 0 : id.hashCode());
107      result = prime * result + ((name == null) ? 0 : name.hashCode());
108      result = prime * result + ((type == null) ? 0 : type.hashCode());
109      return result;
110   }
111 
112   @Override
113   public boolean equals(Object obj) {
114      if (this == obj)
115         return true;
116      if (obj == null)
117         return false;
118      if (getClass() != obj.getClass())
119         return false;
120      ResourceImpl other = (ResourceImpl) obj;
121      if (href == null) {
122         if (other.href != null)
123            return false;
124      } else if (!href.equals(other.href))
125         return false;
126      if (id == null) {
127         if (other.id != null)
128            return false;
129      } else if (!id.equals(other.id))
130         return false;
131      if (name == null) {
132         if (other.name != null)
133            return false;
134      } else if (!name.equals(other.name))
135         return false;
136      if (type == null) {
137         if (other.type != null)
138            return false;
139      } else if (!type.equals(other.type))
140         return false;
141      return true;
142   }
143 
144   public Builder toBuilder() {
145      return Builder.fromResource(this);
146   }
147 
148   @Override
149   public String toString() {
150      return "[id=" + id + ", href=" + href + ", name=" + name + ", type=" + type + "]";
151   }
152}

[all classes][org.jclouds.savvis.vpdc.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov