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

COVERAGE SUMMARY FOR SOURCE FILE [LoadBalancerAttributes.java]

nameclass, %method, %block, %line, %
LoadBalancerAttributes.java100% (2/2)21%  (3/14)6%   (14/233)9%   (4.5/51)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class LoadBalancerAttributes100% (1/1)22%  (2/9)4%   (8/206)9%   (4/47)
algorithm (String): LoadBalancerAttributes 0%   (0/1)0%   (0/5)0%   (0/2)
equals (Object): boolean 0%   (0/1)0%   (0/85)0%   (0/28)
fromLoadBalancer (BaseLoadBalancer): LoadBalancerAttributes 0%   (0/1)0%   (0/14)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/58)0%   (0/7)
port (int): LoadBalancerAttributes 0%   (0/1)0%   (0/6)0%   (0/2)
protocol (String): LoadBalancerAttributes 0%   (0/1)0%   (0/5)0%   (0/2)
toString (): String 0%   (0/1)0%   (0/25)0%   (0/1)
LoadBalancerAttributes (): void 100% (1/1)100% (3/3)100% (2/2)
name (String): LoadBalancerAttributes 100% (1/1)100% (5/5)100% (2/2)
     
class LoadBalancerAttributes$Builder100% (1/1)20%  (1/5)22%  (6/27)20%  (1/5)
LoadBalancerAttributes$Builder (): void 0%   (0/1)0%   (0/3)0%   (0/1)
algorithm (String): LoadBalancerAttributes 0%   (0/1)0%   (0/6)0%   (0/1)
port (int): LoadBalancerAttributes 0%   (0/1)0%   (0/6)0%   (0/1)
protocol (String): LoadBalancerAttributes 0%   (0/1)0%   (0/6)0%   (0/1)
name (String): LoadBalancerAttributes 100% (1/1)100% (6/6)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.cloudloadbalancers.domain;
20 
21import org.jclouds.cloudloadbalancers.domain.internal.BaseLoadBalancer;
22 
23/**
24 * 
25 * @author Adrian Cole
26 * @see <a href=
27 *      "http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch04s01s02.html"
28 *      />
29 */
30public class LoadBalancerAttributes {
31   protected String name;
32   protected String protocol;
33   protected Integer port;
34   protected String algorithm;
35 
36   public LoadBalancerAttributes name(String name) {
37      this.name = name;
38      return this;
39   }
40 
41   public LoadBalancerAttributes protocol(String protocol) {
42      this.protocol = protocol;
43      return this;
44   }
45 
46   public LoadBalancerAttributes port(int port) {
47      this.port = port;
48      return this;
49   }
50 
51   public LoadBalancerAttributes algorithm(String algorithm) {
52      this.algorithm = algorithm;
53      return this;
54   }
55 
56   public static <T extends BaseLoadBalancer<?, T>> LoadBalancerAttributes fromLoadBalancer(T lb) {
57      return Builder.name(lb.getName()).port(lb.getPort()).protocol(lb.getProtocol()).algorithm(lb.getAlgorithm());
58   }
59 
60   public static class Builder {
61      public static LoadBalancerAttributes name(String name) {
62         return new LoadBalancerAttributes().name(name);
63      }
64 
65      public static LoadBalancerAttributes protocol(String protocol) {
66         return new LoadBalancerAttributes().protocol(protocol);
67      }
68 
69      public static LoadBalancerAttributes port(int port) {
70         return new LoadBalancerAttributes().port(port);
71      }
72 
73      public static LoadBalancerAttributes algorithm(String algorithm) {
74         return new LoadBalancerAttributes().algorithm(algorithm);
75      }
76   }
77 
78   @Override
79   public String toString() {
80      return String.format("[algorithm=%s, name=%s, port=%s, protocol=%s]", algorithm, name, port, protocol);
81   }
82 
83   @Override
84   public int hashCode() {
85      final int prime = 31;
86      int result = 1;
87      result = prime * result + ((algorithm == null) ? 0 : algorithm.hashCode());
88      result = prime * result + ((name == null) ? 0 : name.hashCode());
89      result = prime * result + ((port == null) ? 0 : port.hashCode());
90      result = prime * result + ((protocol == null) ? 0 : protocol.hashCode());
91      return result;
92   }
93 
94   @Override
95   public boolean equals(Object obj) {
96      if (this == obj)
97         return true;
98      if (obj == null)
99         return false;
100      if (getClass() != obj.getClass())
101         return false;
102      LoadBalancerAttributes other = (LoadBalancerAttributes) obj;
103      if (algorithm == null) {
104         if (other.algorithm != null)
105            return false;
106      } else if (!algorithm.equals(other.algorithm))
107         return false;
108      if (name == null) {
109         if (other.name != null)
110            return false;
111      } else if (!name.equals(other.name))
112         return false;
113      if (port == null) {
114         if (other.port != null)
115            return false;
116      } else if (!port.equals(other.port))
117         return false;
118      if (protocol == null) {
119         if (other.protocol != null)
120            return false;
121      } else if (!protocol.equals(other.protocol))
122         return false;
123      return true;
124   }
125}

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