]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/attachment/SimpleAttachment.java
Save current state even if not completely stable
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / attachment / SimpleAttachment.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
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
17 package org.argeo.slc.core.attachment;
18
19 import java.io.Serializable;
20 import java.util.UUID;
21
22 public class SimpleAttachment implements Attachment, Serializable {
23 private static final long serialVersionUID = 6615155908800610606L;
24 private String uuid = UUID.randomUUID().toString();
25 private String name;
26 private String contentType = "";
27
28 public SimpleAttachment() {
29 }
30
31 public SimpleAttachment(String uuid, String name, String contentType) {
32 super();
33 this.uuid = uuid;
34 this.name = name;
35 this.contentType = contentType;
36 }
37
38 public String getUuid() {
39 return uuid;
40 }
41
42 public void setUuid(String uuid) {
43 this.uuid = uuid;
44 }
45
46 public String getName() {
47 return name;
48 }
49
50 public void setName(String name) {
51 this.name = name;
52 }
53
54 public String getContentType() {
55 return contentType;
56 }
57
58 public void setContentType(String contentType) {
59 this.contentType = contentType;
60 }
61
62 public String toString() {
63 return "Attachment #" + uuid + "(" + name + ", " + contentType + ")";
64 }
65
66 public boolean equals(Object obj) {
67 if (obj instanceof Attachment) {
68 Attachment attachment = (Attachment) obj;
69 if (uuid != null && attachment.getUuid() != null)
70 return uuid.equals(attachment.getUuid());
71
72 if (name != null && attachment.getName() != null)
73 return name.equals(attachment.getName());
74
75 return hashCode() == attachment.hashCode();
76 }
77 return false;
78 }
79 }