1 | /** |
2 | * |
3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
4 | * |
5 | * ==================================================================== |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * you may not use this file except in compliance with the License. |
8 | * 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, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * See the License for the specific language governing permissions and |
16 | * limitations under the License. |
17 | * ==================================================================== |
18 | */ |
19 | package org.jclouds.openstack.swift.domain; |
20 | |
21 | |
22 | /** |
23 | * |
24 | * @author Adrian Cole |
25 | * |
26 | */ |
27 | public class ContainerMetadata implements Comparable<ContainerMetadata> { |
28 | /** The serialVersionUID */ |
29 | private static final long serialVersionUID = 2925863715029426128L; |
30 | private String name; |
31 | private long count; |
32 | private long bytes; |
33 | |
34 | public ContainerMetadata() { |
35 | } |
36 | |
37 | public ContainerMetadata(String name, long count, long bytes) { |
38 | setName(name); |
39 | setBytes(bytes); |
40 | setCount(count); |
41 | } |
42 | |
43 | public long getCount() { |
44 | return count; |
45 | } |
46 | |
47 | public void setCount(long count) { |
48 | this.count = count; |
49 | } |
50 | |
51 | public void setName(String name) { |
52 | this.name = name; |
53 | } |
54 | |
55 | public String getName() { |
56 | return name; |
57 | } |
58 | |
59 | public void setBytes(long bytes) { |
60 | this.bytes = bytes; |
61 | } |
62 | |
63 | public long getBytes() { |
64 | return bytes; |
65 | } |
66 | |
67 | @Override |
68 | public int hashCode() { |
69 | final int prime = 31; |
70 | int result = 1; |
71 | result = prime * result + (int) (bytes ^ (bytes >>> 32)); |
72 | result = prime * result + (int) (count ^ (count >>> 32)); |
73 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
74 | return result; |
75 | } |
76 | |
77 | @Override |
78 | public boolean equals(Object obj) { |
79 | if (this == obj) |
80 | return true; |
81 | if (obj == null) |
82 | return false; |
83 | if (getClass() != obj.getClass()) |
84 | return false; |
85 | ContainerMetadata other = (ContainerMetadata) obj; |
86 | if (bytes != other.bytes) |
87 | return false; |
88 | if (count != other.count) |
89 | return false; |
90 | if (name == null) { |
91 | if (other.name != null) |
92 | return false; |
93 | } else if (!name.equals(other.name)) |
94 | return false; |
95 | return true; |
96 | } |
97 | |
98 | public int compareTo(ContainerMetadata o) { |
99 | if (getName() == null) |
100 | return -1; |
101 | return (this == o) ? 0 : getName().compareTo(o.getName()); |
102 | } |
103 | |
104 | } |