001
014
015 package com.liferay.portal.kernel.search;
016
017 import com.liferay.portal.kernel.comment.Comment;
018 import com.liferay.portal.kernel.repository.model.FileEntry;
019 import com.liferay.portal.kernel.util.HashUtil;
020 import com.liferay.portal.kernel.util.Validator;
021
022 import java.util.ArrayList;
023 import java.util.List;
024
025
028 public class SearchResult {
029
030 public SearchResult(String className, long classPK) {
031 _className = className;
032 _classPK = classPK;
033 }
034
035 public void addComment(Comment comment, Summary summary) {
036 _commentRelatedSearchResults.add(
037 new RelatedSearchResult<>(comment, summary));
038 }
039
040 public void addFileEntry(FileEntry fileEntry, Summary summary) {
041 _fileEntryRelatedSearchResults.add(
042 new RelatedSearchResult<>(fileEntry, summary));
043 }
044
045 public void addVersion(String version) {
046 _versions.add(version);
047 }
048
049 @Override
050 public boolean equals(Object obj) {
051 if (this == obj) {
052 return true;
053 }
054
055 if (!(obj instanceof SearchResult)) {
056 return false;
057 }
058
059 SearchResult searchResult = (SearchResult)obj;
060
061 if (Validator.equals(_classPK, searchResult._classPK) &&
062 Validator.equals(_className, searchResult._className)) {
063
064 return true;
065 }
066
067 return false;
068 }
069
070 public String getClassName() {
071 return _className;
072 }
073
074 public long getClassPK() {
075 return _classPK;
076 }
077
078 public List<RelatedSearchResult<Comment>> getCommentRelatedSearchResults() {
079 return _commentRelatedSearchResults;
080 }
081
082 public List<RelatedSearchResult<FileEntry>>
083 getFileEntryRelatedSearchResults() {
084
085 return _fileEntryRelatedSearchResults;
086 }
087
088 public Summary getSummary() {
089 return _summary;
090 }
091
092 public List<String> getVersions() {
093 return _versions;
094 }
095
096 @Override
097 public int hashCode() {
098 int hash = HashUtil.hash(0, _classPK);
099
100 return HashUtil.hash(hash, _className);
101 }
102
103
106 @Deprecated
107 public void setClassName(String className) {
108 _className = className;
109 }
110
111
114 @Deprecated
115 public void setClassPK(long classPK) {
116 _classPK = classPK;
117 }
118
119 public void setSummary(Summary summary) {
120 _summary = summary;
121 }
122
123 private String _className;
124 private long _classPK;
125 private final List<RelatedSearchResult<Comment>>
126 _commentRelatedSearchResults = new ArrayList<>();
127 private final List<RelatedSearchResult<FileEntry>>
128 _fileEntryRelatedSearchResults = new ArrayList<>();
129 private Summary _summary;
130 private final List<String> _versions = new ArrayList<>();
131
132 }