1 package org.jboss.profileservice.spi; 2 3 import java.io.Serializable ; 4 5 11 public class ProfileKey 12 implements Comparable , Serializable 13 { 14 private static final long serialVersionUID = 1; 15 16 public static final String DEFAULT = "default"; 17 18 19 private String domain; 20 21 private String server; 22 23 private String name; 24 25 29 public ProfileKey(String name) 30 { 31 this(DEFAULT, DEFAULT, name); 32 } 33 34 42 public ProfileKey(String domain, String server, String name) 43 { 44 if( domain == null ) 45 domain = DEFAULT; 46 this.domain = domain; 47 if( server == null ) 48 server = DEFAULT; 49 this.server = server; 50 if( name == null ) 51 name = DEFAULT; 52 this.name = name; 53 } 54 55 62 public int compareTo(Object o) 63 { 64 ProfileKey pk = (ProfileKey) o; 65 int compareTo = domain.compareTo(pk.domain); 66 if( compareTo == 0 ) 67 { 68 compareTo = server.compareTo(pk.server); 69 if( compareTo == 0 ) 70 { 71 compareTo = name.compareTo(pk.name); 72 } 73 } 74 return compareTo; 75 } 76 public boolean equals(Object o) 77 { 78 return compareTo(o) == 0; 79 } 80 public int hashCode() 81 { 82 int hash = domain.hashCode() + server.hashCode() + name.hashCode(); 83 return hash; 84 } 85 } 86 | Popular Tags |