1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.core.attachment;
17
18 import java.io.Serializable;
19 import java.util.UUID;
20
21 public class SimpleAttachment implements Attachment, Serializable {
22 private static final long serialVersionUID = 6615155908800610606L;
23 private String uuid = UUID.randomUUID().toString();
24 private String name;
25 private String contentType = "";
26
27 public SimpleAttachment() {
28 }
29
30 public SimpleAttachment(String uuid, String name, String contentType) {
31 super();
32 this.uuid = uuid;
33 this.name = name;
34 this.contentType = contentType;
35 }
36
37 public String getUuid() {
38 return uuid;
39 }
40
41 public void setUuid(String uuid) {
42 this.uuid = uuid;
43 }
44
45 public String getName() {
46 return name;
47 }
48
49 public void setName(String name) {
50 this.name = name;
51 }
52
53 public String getContentType() {
54 return contentType;
55 }
56
57 public void setContentType(String contentType) {
58 this.contentType = contentType;
59 }
60
61 public String toString() {
62 return "Attachment #" + uuid + "(" + name + ", " + contentType + ")";
63 }
64
65 public boolean equals(Object obj) {
66 if (obj instanceof Attachment) {
67 Attachment attachment = (Attachment) obj;
68 if (uuid != null && attachment.getUuid() != null)
69 return uuid.equals(attachment.getUuid());
70
71 if (name != null && attachment.getName() != null)
72 return name.equals(attachment.getName());
73
74 return hashCode() == attachment.hashCode();
75 }
76 return false;
77 }
78 }