001/* 002 * #%L 003 * Netarchivesuite - harvester 004 * %% 005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library, 006 * the National Library of France and the Austrian National Library. 007 * %% 008 * This program is free software: you can redistribute it and/or modify 009 * it under the terms of the GNU Lesser General Public License as 010 * published by the Free Software Foundation, either version 2.1 of the 011 * License, or (at your option) any later version. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Lesser Public License for more details. 017 * 018 * You should have received a copy of the GNU General Lesser Public 019 * License along with this program. If not, see 020 * <http://www.gnu.org/licenses/lgpl-2.1.html>. 021 * #L% 022 */ 023package dk.netarkivet.harvester.datamodel; 024 025import java.util.Date; 026 027import dk.netarkivet.common.exceptions.ArgumentNotValid; 028 029/** 030 * This class manages owner information about a domain. Immutable. 031 */ 032 033@SuppressWarnings({"rawtypes"}) 034public class DomainOwnerInfo implements Comparable { 035 036 /** Information about the owner of a domain. */ 037 private String ownerInfo; 038 039 /** The date the information was registered. */ 040 private Date date; 041 042 /** ID autogenerated by DB, ignored otherwise. */ 043 private Long id; 044 045 /** 046 * Create new instance. 047 * 048 * @param d the date the owner information is registered 049 * @param info the owner information 050 */ 051 public DomainOwnerInfo(Date d, String info) { 052 ArgumentNotValid.checkNotNull(d, "d"); 053 ArgumentNotValid.checkNotNullOrEmpty(info, "info"); 054 ownerInfo = info; 055 date = d; 056 } 057 058 /** 059 * Gets the owner information. 060 * 061 * @return the owner information 062 */ 063 public String getInfo() { 064 return ownerInfo; 065 } 066 067 /** 068 * Gets the date. 069 * 070 * @return the date 071 */ 072 public Date getDate() { 073 return date; 074 } 075 076 /** 077 * Get the ID of this ownerinfo. Only for use by DBDAO 078 * 079 * @return the ID of this ownerinfo object 080 */ 081 long getID() { 082 return id; 083 } 084 085 /** 086 * Set the ID of this ownerinfo. Only for use by DBDAO. 087 * 088 * @param newid use this id for this ownerinfo 089 */ 090 void setID(long newid) { 091 this.id = newid; 092 } 093 094 /** 095 * Check if this ownerinfo has an ID set yet (doesn't happen until the DBDAO persists it). 096 * 097 * @return true, if this ownerinfo-object has an ID 098 */ 099 boolean hasID() { 100 return id != null; 101 } 102 103 /** 104 * Compares two DomainOwnerInfo objects using dates. 105 * 106 * @param other is a non-null DomainOwnerInfo. 107 * @throws ClassCastException if <code>other</code> is not an DomainOwnerInfo object. 108 * @see Comparable#compareTo(java.lang.Object) 109 */ 110 public int compareTo(Object other) { 111 ArgumentNotValid.checkNotNull(other, "other"); 112 113 if (this == other) { 114 return 0; 115 } 116 return date.compareTo(((DomainOwnerInfo) other).date); 117 } 118 119}