1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.cloudsigma.domain;
20
21 import static com.google.common.base.Preconditions.checkNotNull;
22
23
24
25
26
27 public abstract class Device {
28 public static abstract class Builder {
29 protected String uuid;
30 protected MediaType mediaType = MediaType.DISK;
31
32 public Builder mediaType(MediaType mediaType) {
33 this.mediaType = mediaType;
34 return this;
35 }
36
37 public Builder uuid(String uuid) {
38 this.uuid = uuid;
39 return this;
40 }
41
42 public abstract Device build();
43 }
44
45 protected final String driveUuid;
46 protected final MediaType mediaType;
47
48 public Device(String driveUuid, MediaType mediaType) {
49 this.driveUuid = checkNotNull(driveUuid, "driveUuid");
50 this.mediaType = checkNotNull(mediaType, "mediaType");
51 }
52
53
54
55
56 public abstract String getId();
57
58
59
60
61
62 public String getDriveUuid() {
63 return driveUuid;
64 }
65
66
67
68
69
70
71 public MediaType getMediaType() {
72 return mediaType;
73 }
74
75 @Override
76 public int hashCode() {
77 final int prime = 31;
78 int result = 1;
79 result = prime * result + ((driveUuid == null) ? 0 : driveUuid.hashCode());
80 result = prime * result + ((mediaType == null) ? 0 : mediaType.hashCode());
81 return result;
82 }
83
84 @Override
85 public boolean equals(Object obj) {
86 if (this == obj)
87 return true;
88 if (obj == null)
89 return false;
90 if (getClass() != obj.getClass())
91 return false;
92 Device other = (Device) obj;
93 if (driveUuid == null) {
94 if (other.driveUuid != null)
95 return false;
96 } else if (!driveUuid.equals(other.driveUuid))
97 return false;
98 if (mediaType != other.mediaType)
99 return false;
100 return true;
101 }
102
103 @Override
104 public String toString() {
105 return "[driveUuid=" + driveUuid + ", mediaType=" + mediaType + "]";
106 }
107 }