1 /***
2 * Copyright (C) 2008 Jeremy Thomerson (jthomerson@users.sourceforge.net)
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 net.sf.vcaperture.model;
18
19 import org.apache.commons.lang.builder.EqualsBuilder;
20 import org.apache.commons.lang.builder.HashCodeBuilder;
21
22 public class RepoFileRevision extends RepoFile {
23
24 private String mRevision;
25 private String mAuthor;
26 private String mContents;
27 private RepoFileAction mAction;
28 private RepoFileRevision mCopyOfRevision;
29 private transient IDataRetriever<RepoFileRevision, String> mContentsRetriever;
30
31 public RepoFileRevision(RepoFile file) {
32 super(file);
33 }
34
35 public RepoFileRevision() {
36
37 }
38
39 public RepoFileAction getAction() {
40 return mAction;
41 }
42
43 public void setAction(RepoFileAction action) {
44 mAction = action;
45 }
46
47 public RepoFileRevision getCopyOfRevision() {
48 return mCopyOfRevision;
49 }
50
51 public void setCopyOfRevision(RepoFileRevision copyOfRevision) {
52 mCopyOfRevision = copyOfRevision;
53 }
54
55 public String getAuthor() {
56 return mAuthor;
57 }
58
59 public void setAuthor(String author) {
60 mAuthor = author;
61 }
62
63 public String getContents() {
64 if (mContents == null && mContentsRetriever != null) {
65 return mContentsRetriever.getData(this);
66 }
67 return mContents;
68 }
69
70 public void setContents(String contents) {
71 mContents = contents;
72 }
73
74 public void setContentsRetriever(IDataRetriever<RepoFileRevision, String> contentsRetriever) {
75 mContentsRetriever = contentsRetriever;
76 }
77
78 public String getRevision() {
79 return mRevision;
80 }
81
82 public void setRevision(String revision) {
83 mRevision = revision;
84 }
85
86 /***
87 * @see java.lang.Object#hashCode()
88 */
89 public int hashCode() {
90 return new HashCodeBuilder(43269007, -1362179715).appendSuper(super.hashCode()).append(this.mCopyOfRevision).append(this.mContents)
91 .append(this.mAction).append(this.mAuthor).append(this.mRevision).toHashCode();
92 }
93
94 /***
95 * @see java.lang.Object#equals(Object)
96 */
97 public boolean equals(Object object) {
98 if (!(object instanceof RepoFileRevision)) {
99 return false;
100 }
101 RepoFileRevision rhs = (RepoFileRevision) object;
102 return new EqualsBuilder().appendSuper(super.equals(object)).append(this.mCopyOfRevision, rhs.mCopyOfRevision).append(
103 this.mContents, rhs.mContents).append(this.mAction, rhs.mAction).append(this.mAuthor, rhs.mAuthor).append(this.mRevision,
104 rhs.mRevision).isEquals();
105 }
106
107 }