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

COVERAGE SUMMARY FOR SOURCE FILE [VirtualIP.java]

nameclass, %method, %block, %line, %
VirtualIP.java100% (4/4)63%  (17/27)73%  (204/279)60%  (31.7/53)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VirtualIP100% (1/1)45%  (5/11)62%  (77/124)50%  (15/30)
compareTo (VirtualIP): int 0%   (0/1)0%   (0/6)0%   (0/1)
equals (Object): boolean 0%   (0/1)0%   (0/28)0%   (0/10)
getAddress (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getId (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getIpVersion (): VirtualIP$IPVersion 0%   (0/1)0%   (0/3)0%   (0/1)
getType (): VirtualIP$Type 0%   (0/1)0%   (0/3)0%   (0/1)
VirtualIP (int, String, VirtualIP$Type, VirtualIP$IPVersion): void 100% (1/1)97%  (31/32)99%  (7/7)
VirtualIP (): void 100% (1/1)100% (3/3)100% (2/2)
builder (): VirtualIP$Builder 100% (1/1)100% (4/4)100% (1/1)
hashCode (): int 100% (1/1)100% (13/13)100% (4/4)
toString (): String 100% (1/1)100% (26/26)100% (1/1)
     
class VirtualIP$IPVersion100% (1/1)60%  (3/5)75%  (43/57)38%  (1.9/5)
fromValue (String): VirtualIP$IPVersion 0%   (0/1)0%   (0/9)0%   (0/3)
valueOf (String): VirtualIP$IPVersion 0%   (0/1)0%   (0/5)0%   (0/1)
<static initializer> 100% (1/1)100% (34/34)100% (2/2)
VirtualIP$IPVersion (String, int): void 100% (1/1)100% (5/5)100% (1/1)
values (): VirtualIP$IPVersion [] 100% (1/1)100% (4/4)100% (1/1)
     
class VirtualIP$Type100% (1/1)60%  (3/5)75%  (43/57)48%  (2.9/6)
fromValue (String): VirtualIP$Type 0%   (0/1)0%   (0/9)0%   (0/3)
valueOf (String): VirtualIP$Type 0%   (0/1)0%   (0/5)0%   (0/1)
<static initializer> 100% (1/1)100% (34/34)100% (3/3)
VirtualIP$Type (String, int): void 100% (1/1)100% (5/5)100% (1/1)
values (): VirtualIP$Type [] 100% (1/1)100% (4/4)100% (1/1)
     
class VirtualIP$Builder100% (1/1)100% (6/6)100% (41/41)100% (12/12)
VirtualIP$Builder (): void 100% (1/1)100% (9/9)100% (3/3)
address (String): VirtualIP$Builder 100% (1/1)100% (5/5)100% (2/2)
build (): VirtualIP 100% (1/1)100% (12/12)100% (1/1)
id (int): VirtualIP$Builder 100% (1/1)100% (5/5)100% (2/2)
ipVersion (VirtualIP$IPVersion): VirtualIP$Builder 100% (1/1)100% (5/5)100% (2/2)
type (VirtualIP$Type): VirtualIP$Builder 100% (1/1)100% (5/5)100% (2/2)

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.cloudloadbalancers.domain;
20 
21import static com.google.common.base.Preconditions.checkArgument;
22import static com.google.common.base.Preconditions.checkNotNull;
23 
24/**
25 * A virtual IP (VIP) makes a load balancer accessible by clients. The load balancing service
26 * supports either a public VIP, routable on the public Internet, or a ServiceNet address, routable
27 * only within the region in which the load balancer resides.
28 * 
29 * @author Adrian Cole
30 * @see <a href=
31 *      "http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch04s03s01.html"
32 *      />
33 */
34public class VirtualIP implements Comparable<VirtualIP> {
35   public static Builder builder() {
36      return new Builder();
37   }
38 
39   public static class Builder {
40      private int id = -1;
41      private String address;
42      private Type type;
43      private IPVersion ipVersion = IPVersion.IPV4;
44 
45      public Builder id(int id) {
46         this.id = id;
47         return this;
48      }
49 
50      public Builder address(String address) {
51         this.address = address;
52         return this;
53      }
54 
55      public Builder type(Type type) {
56         this.type = type;
57         return this;
58      }
59 
60      public Builder ipVersion(IPVersion ipVersion) {
61         this.ipVersion = ipVersion;
62         return this;
63      }
64 
65      public VirtualIP build() {
66         return new VirtualIP(id, address, type, ipVersion);
67      }
68   }
69 
70   /**
71    * Virtual IP Types
72    */
73   public static enum Type {
74      /**
75       * An address that is routable on the public Internet.
76       */
77      PUBLIC,
78      /**
79       * An address that is routable only on ServiceNet.
80       */
81      SERVICENET, UNRECOGNIZED;
82 
83      public static Type fromValue(String type) {
84         try {
85            return valueOf(checkNotNull(type, "type"));
86         } catch (IllegalArgumentException e) {
87            return UNRECOGNIZED;
88         }
89      }
90 
91   }
92 
93   /**
94    * Virtual IP Versions
95    */
96   public static enum IPVersion {
97 
98      IPV4, IPV6, UNRECOGNIZED;
99 
100      public static IPVersion fromValue(String ipVersion) {
101         try {
102            return valueOf(checkNotNull(ipVersion, "ipVersion"));
103         } catch (IllegalArgumentException e) {
104            return UNRECOGNIZED;
105         }
106      }
107 
108   }
109 
110   // for serialization only
111   VirtualIP() {
112 
113   }
114 
115   private int id;
116   private String address;
117   private Type type;
118   private IPVersion ipVersion;
119 
120   public VirtualIP(int id, String address, Type type, IPVersion ipVersion) {
121      checkArgument(id != -1, "id must be specified");
122      this.id = id;
123      this.address = checkNotNull(address, "address");
124      this.type = checkNotNull(type, "type");
125      this.ipVersion = checkNotNull(ipVersion, "ipVersion");
126   }
127 
128   public int getId() {
129      return id;
130   }
131 
132   public String getAddress() {
133      return address;
134   }
135 
136   public Type getType() {
137      return type;
138   }
139 
140   public IPVersion getIpVersion() {
141      return ipVersion;
142   }
143 
144   @Override
145   public int compareTo(VirtualIP arg0) {
146      return address.compareTo(arg0.address);
147   }
148 
149   @Override
150   public int hashCode() {
151      final int prime = 31;
152      int result = 1;
153      result = prime * result + id;
154      return result;
155   }
156 
157   @Override
158   public boolean equals(Object obj) {
159      if (this == obj)
160         return true;
161      if (obj == null)
162         return false;
163      if (getClass() != obj.getClass())
164         return false;
165      VirtualIP other = (VirtualIP) obj;
166      if (id != other.id)
167         return false;
168      return true;
169   }
170 
171   @Override
172   public String toString() {
173      return String.format("[address=%s, id=%s, ipVersion=%s, type=%s]", address, id, ipVersion, type);
174   }
175 
176}

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