1 6 7 package SOFA.SOFAnet.Admin.RMI; 8 9 import SOFA.SOFAnet.Repository.Contract; 10 import java.io.Serializable ; 11 12 16 public class ContractDesc implements Comparable , Serializable 17 { 18 public String name; 19 public String description; 20 21 22 public ContractDesc(Contract contract) 23 { 24 this.name = contract.getName(); 25 this.description = contract.getDescription(); 26 } 27 28 ContractDesc(String name, String description) 29 { 30 this.name = name; 31 this.description = description; 32 } 33 34 public boolean equals(Object o) 35 { 36 if (this == o) return true; 37 if (o instanceof ContractDesc) 38 { 39 ContractDesc contractDesc = (ContractDesc)o; 40 return toString().compareTo(contractDesc.toString()) == 0; 41 } 42 else return false; 43 } 44 45 public int compareTo(Object o) 46 { 47 ContractDesc contractDesc = (ContractDesc)o; 48 return toString().compareTo(contractDesc.toString()); 49 } 50 51 public String toString() 52 { 53 if (description.length() == 0) return name; 54 else return name + " (" + description + ")"; 55 } 56 } 57 | Popular Tags |