001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2008-2012 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
019 */
020 package org.sonar.core.purge;
021
022 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
023 import org.apache.commons.lang.builder.ToStringStyle;
024
025 import java.util.Date;
026
027 public class PurgeableSnapshotDto implements Comparable<PurgeableSnapshotDto> {
028 private Date date;
029 private long snapshotId;
030 private boolean hasEvents;
031 private boolean isLast;
032
033 public Date getDate() {
034 return date;//NOSONAR May expose internal representation by returning reference to mutable object
035 }
036
037 public long getSnapshotId() {
038 return snapshotId;
039 }
040
041 public boolean hasEvents() {
042 return hasEvents;
043 }
044
045 public boolean isLast() {
046 return isLast;
047 }
048
049 public PurgeableSnapshotDto setDate(Date date) {
050 this.date = date;//NOSONAR May expose internal representation by incorporating reference to mutable object
051 return this;
052 }
053
054 public PurgeableSnapshotDto setSnapshotId(long snapshotId) {
055 this.snapshotId = snapshotId;
056 return this;
057 }
058
059 public PurgeableSnapshotDto setHasEvents(boolean b) {
060 this.hasEvents = b;
061 return this;
062 }
063
064 public PurgeableSnapshotDto setLast(boolean last) {
065 isLast = last;
066 return this;
067 }
068
069 public int compareTo(PurgeableSnapshotDto other) {
070 return date.compareTo(other.date);
071 }
072
073 @Override
074 public boolean equals(Object o) {
075 if (this == o) {
076 return true;
077 }
078 if (o == null || getClass() != o.getClass()) {
079 return false;
080 }
081 PurgeableSnapshotDto that = (PurgeableSnapshotDto) o;
082 return snapshotId == that.snapshotId;
083 }
084
085 @Override
086 public int hashCode() {
087 return (int)snapshotId;
088 }
089
090 @Override
091 public String toString() {
092 return new ReflectionToStringBuilder(this, ToStringStyle.SIMPLE_STYLE).toString();
093 }
094 }