001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2009 SonarSource SA 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.api.database.model; 021 022 import org.sonar.api.database.BaseIdentifiable; 023 import org.sonar.api.database.DatabaseProperties; 024 025 import javax.persistence.Column; 026 import javax.persistence.Entity; 027 import javax.persistence.Lob; 028 import javax.persistence.Table; 029 030 @Entity 031 @Table(name = "snapshot_sources") 032 public class SnapshotSource extends BaseIdentifiable { 033 034 @Column(name = "snapshot_id") 035 private Integer snapshotId; 036 037 @Lob 038 @Column(name = "data", updatable = true, nullable = true, length = DatabaseProperties.MAX_TEXT_SIZE) 039 private String data; 040 041 public SnapshotSource() { 042 } 043 044 public SnapshotSource(Snapshot snapshot, String data) { 045 this.snapshotId = snapshot.getId(); 046 this.data = data; 047 } 048 049 public void setSnapshot(Snapshot snapshot) { 050 this.snapshotId = snapshot.getId(); 051 } 052 053 public String getData() { 054 return data; 055 } 056 057 public void setData(String data) { 058 this.data = data; 059 } 060 061 @Override 062 public boolean equals(Object obj) { 063 if (!(obj instanceof SnapshotSource)) { 064 return false; 065 } 066 if (this == obj) { 067 return true; 068 } 069 SnapshotSource other = (SnapshotSource) obj; 070 return snapshotId.equals(other.snapshotId); 071 } 072 073 @Override 074 public int hashCode() { 075 return snapshotId.hashCode(); 076 } 077 }