001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle-sdk. 005 * 006 * Dicoogle/dicoogle-sdk is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle-sdk 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 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package pt.ua.dicoogle.sdk.datastructs; 020 021import java.io.Serializable; 022import java.util.Objects; 023 024/** An immutable data structure for describing a DICOM node (potential C-MOVE destinations). 025 * 026 * @author Luís A. Bastião Silva <bastiao@ua.pt> 027 */ 028public class MoveDestination implements Serializable 029{ 030 static final long serialVersionUID = 2L; 031 032 private final String AETitle; 033 private final String ipAddrs; 034 private final int port; 035 036 private final String description; 037 private final boolean isPublic; 038 039 public MoveDestination(String AETitle, String ipAddr, int port, boolean isPublic, String description) { 040 this.AETitle = AETitle; 041 this.ipAddrs = ipAddr; 042 this.port = port; 043 this.isPublic = isPublic; 044 this.description = description; 045 } 046 047 public MoveDestination(String AETitle, String ipAddr, int port, boolean isPublic) { 048 this(AETitle, ipAddr, port, isPublic, ""); 049 } 050 051 public MoveDestination(String AETitle, String ipAddr, int port) { 052 this(AETitle, ipAddr, port, false, ""); 053 } 054 055 /** 056 * @return the AETitle 057 */ 058 public String getAETitle() 059 { 060 return AETitle; 061 } 062 063 /** 064 * @param AETitle the AETitle to set 065 */ 066/* public void setAETitle(String AETitle) 067 { 068 this.AETitle = AETitle; 069 }*/ 070 071 /** 072 * @return the ipAddrs 073 */ 074 public String getIpAddrs() 075 { 076 return ipAddrs; 077 } 078 079 /** 080 * @param ipAddrs the ipAddrs to set 081 */ 082/* public void setIpAddrs(String ipAddrs) 083 { 084 this.ipAddrs = ipAddrs; 085 } */ 086 087 /** 088 * @return the port 089 */ 090 public int getPort() 091 { 092 return port; 093 } 094 095 @Override 096 public String toString() 097 { 098 String result; 099 result = "MoveDestination AET: " + this.AETitle + " (" + this.ipAddrs + ":" + 100 String.valueOf(this.port) + ")"; 101 if (!description.isEmpty()) { 102 result += " - " + this.description; 103 } 104 105 return result ; 106 } 107 108 109 /** 110 * @return the description 111 */ 112 public String getDescription() { 113 return description; 114 } 115 116 /** 117 * @return the isPublic 118 */ 119 public boolean isIsPublic() { 120 return isPublic; 121 } 122 123 @Override 124 public boolean equals(Object obj){ 125 if(obj == null || getClass() != obj.getClass()) 126 return false; 127 128 if(obj == this) 129 return true; 130 131 MoveDestination move = (MoveDestination) obj; 132 133 // To the list of MoveDestinations may not be repeated AETitles 134 return move.AETitle.equals(AETitle) && move.ipAddrs.equals(ipAddrs) && move.port == port; 135 } 136 137 @Override 138 public int hashCode() { 139 int hash = 3; 140 hash = 97 * hash + Objects.hashCode(this.AETitle); 141 hash = 97 * hash + Objects.hashCode(this.ipAddrs); 142 hash = 97 * hash + this.port; 143 return hash; 144 } 145}