| 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 | */ |
| 19 | package org.jclouds.atmos.domain; |
| 20 | |
| 21 | import java.util.Date; |
| 22 | |
| 23 | import org.jclouds.javax.annotation.Nullable; |
| 24 | |
| 25 | /** |
| 26 | * Metadata of a Atmos Online object |
| 27 | * |
| 28 | * @author Adrian Cole |
| 29 | */ |
| 30 | public class SystemMetadata extends DirectoryEntry { |
| 31 | |
| 32 | private final Date atime; |
| 33 | private final Date ctime; |
| 34 | private final String gid; |
| 35 | private final Date itime; |
| 36 | private final Date mtime; |
| 37 | private final int nlink; |
| 38 | private final String policyname; |
| 39 | private final long size; |
| 40 | private final String uid; |
| 41 | private final byte[] contentmd5; |
| 42 | |
| 43 | public SystemMetadata(@Nullable byte [] contentmd5, Date atime, Date ctime, String gid, Date itime, Date mtime, int nlink, |
| 44 | String objectid, String objname, String policyname, long size, FileType type, String uid) { |
| 45 | super(objectid, type, objname); |
| 46 | this.contentmd5 = contentmd5; |
| 47 | this.atime = atime; |
| 48 | this.ctime = ctime; |
| 49 | this.gid = gid; |
| 50 | this.itime = itime; |
| 51 | this.mtime = mtime; |
| 52 | this.nlink = nlink; |
| 53 | this.policyname = policyname; |
| 54 | this.size = size; |
| 55 | this.uid = uid; |
| 56 | } |
| 57 | |
| 58 | public String getGroupID() { |
| 59 | return gid; |
| 60 | } |
| 61 | |
| 62 | public int getHardLinkCount() { |
| 63 | return nlink; |
| 64 | } |
| 65 | |
| 66 | public Date getInceptionTime() { |
| 67 | return itime; |
| 68 | } |
| 69 | |
| 70 | public Date getLastAccessTime() { |
| 71 | return atime; |
| 72 | } |
| 73 | |
| 74 | public Date getLastMetadataModification() { |
| 75 | return mtime; |
| 76 | } |
| 77 | |
| 78 | public Date getLastUserDataModification() { |
| 79 | return ctime; |
| 80 | } |
| 81 | |
| 82 | public String getPolicyName() { |
| 83 | return policyname; |
| 84 | } |
| 85 | |
| 86 | public long getSize() { |
| 87 | return size; |
| 88 | } |
| 89 | |
| 90 | public String getUserID() { |
| 91 | return uid; |
| 92 | } |
| 93 | |
| 94 | public byte[] getContentMD5() { |
| 95 | return contentmd5; |
| 96 | } |
| 97 | |
| 98 | @Override |
| 99 | public int hashCode() { |
| 100 | final int prime = 31; |
| 101 | int result = super.hashCode(); |
| 102 | result = prime * result + ((atime == null) ? 0 : atime.hashCode()); |
| 103 | result = prime * result + ((ctime == null) ? 0 : ctime.hashCode()); |
| 104 | result = prime * result + ((gid == null) ? 0 : gid.hashCode()); |
| 105 | result = prime * result + ((itime == null) ? 0 : itime.hashCode()); |
| 106 | result = prime * result + ((mtime == null) ? 0 : mtime.hashCode()); |
| 107 | result = prime * result + nlink; |
| 108 | result = prime * result + ((policyname == null) ? 0 : policyname.hashCode()); |
| 109 | result = prime * result + (int) (size ^ (size >>> 32)); |
| 110 | result = prime * result + ((uid == null) ? 0 : uid.hashCode()); |
| 111 | return result; |
| 112 | } |
| 113 | |
| 114 | @Override |
| 115 | public boolean equals(Object obj) { |
| 116 | if (this == obj) |
| 117 | return true; |
| 118 | if (!super.equals(obj)) |
| 119 | return false; |
| 120 | if (getClass() != obj.getClass()) |
| 121 | return false; |
| 122 | SystemMetadata other = (SystemMetadata) obj; |
| 123 | if (atime == null) { |
| 124 | if (other.atime != null) |
| 125 | return false; |
| 126 | } else if (!atime.equals(other.atime)) |
| 127 | return false; |
| 128 | if (ctime == null) { |
| 129 | if (other.ctime != null) |
| 130 | return false; |
| 131 | } else if (!ctime.equals(other.ctime)) |
| 132 | return false; |
| 133 | if (gid == null) { |
| 134 | if (other.gid != null) |
| 135 | return false; |
| 136 | } else if (!gid.equals(other.gid)) |
| 137 | return false; |
| 138 | if (itime == null) { |
| 139 | if (other.itime != null) |
| 140 | return false; |
| 141 | } else if (!itime.equals(other.itime)) |
| 142 | return false; |
| 143 | if (mtime == null) { |
| 144 | if (other.mtime != null) |
| 145 | return false; |
| 146 | } else if (!mtime.equals(other.mtime)) |
| 147 | return false; |
| 148 | if (nlink != other.nlink) |
| 149 | return false; |
| 150 | if (policyname == null) { |
| 151 | if (other.policyname != null) |
| 152 | return false; |
| 153 | } else if (!policyname.equals(other.policyname)) |
| 154 | return false; |
| 155 | if (size != other.size) |
| 156 | return false; |
| 157 | if (uid == null) { |
| 158 | if (other.uid != null) |
| 159 | return false; |
| 160 | } else if (!uid.equals(other.uid)) |
| 161 | return false; |
| 162 | return true; |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public String toString() { |
| 167 | return "[type=" + getType() + ", id=" + getObjectID() + ", name=" + getObjectName() + "]"; |
| 168 | } |
| 169 | |
| 170 | } |