]> git.argeo.org Git - gpl/argeo-slc.git/blob - SimpleAttachment.java
e9a44c959474e504cf4243f815b9a9d06ee32b8f
[gpl/argeo-slc.git] / SimpleAttachment.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.core.attachment;
17
18 import java.io.Serializable;
19 import java.util.UUID;
20
21 import org.argeo.slc.attachment.Attachment;
22
23 public class SimpleAttachment implements Attachment, Serializable {
24 private static final long serialVersionUID = 6615155908800610606L;
25 private String uuid = UUID.randomUUID().toString();
26 private String name;
27 private String contentType = "";
28
29 public SimpleAttachment() {
30 }
31
32 public SimpleAttachment(String uuid, String name, String contentType) {
33 super();
34 this.uuid = uuid;
35 this.name = name;
36 this.contentType = contentType;
37 }
38
39 public String getUuid() {
40 return uuid;
41 }
42
43 public void setUuid(String uuid) {
44 this.uuid = uuid;
45 }
46
47 public String getName() {
48 return name;
49 }
50
51 public void setName(String name) {
52 this.name = name;
53 }
54
55 public String getContentType() {
56 return contentType;
57 }
58
59 public void setContentType(String contentType) {
60 this.contentType = contentType;
61 }
62
63 public String toString() {
64 return "Attachment #" + uuid + "(" + name + ", " + contentType + ")";
65 }
66
67 public boolean equals(Object obj) {
68 if (obj instanceof Attachment) {
69 Attachment attachment = (Attachment) obj;
70 if (uuid != null && attachment.getUuid() != null)
71 return uuid.equals(attachment.getUuid());
72
73 if (name != null && attachment.getName() != null)
74 return name.equals(attachment.getName());
75
76 return hashCode() == attachment.hashCode();
77 }
78 return false;
79 }
80 }