1 23 24 28 29 31 32 package com.sun.enterprise.management.support; 33 34 import java.util.Set ; 35 import java.util.Collections ; 36 37 import com.sun.appserv.management.util.misc.ObjectUtil; 38 39 40 52 class TypeData 53 { 54 private final String mJ2EEType; 55 private final Set <String > mLegalParentsTypes; 56 private final String mContainedByJ2EEType; 57 58 59 public int 60 hashCode() 61 { 62 return ObjectUtil.hashCode( 63 mJ2EEType, mLegalParentsTypes, mContainedByJ2EEType); 64 } 65 66 public boolean 67 equals( final Object rhs ) 68 { 69 boolean equals = false; 70 71 if ( this == rhs ) 72 { 73 equals = true; 74 } 75 else if ( ! (rhs instanceof TypeData) ) 76 { 77 equals = false; 78 } 79 else 80 { 81 final TypeData rhsTypeData = (TypeData)rhs; 82 83 equals = ObjectUtil.equals( mJ2EEType, rhsTypeData.mJ2EEType ) && 84 mLegalParentsTypes.equals( rhsTypeData.mLegalParentsTypes ) && 85 ObjectUtil.equals( mContainedByJ2EEType, rhsTypeData.mContainedByJ2EEType ); 86 } 87 88 return equals; 89 } 90 91 94 protected TypeData( 95 final String j2eeType, 96 final String parentJ2EEType ) 97 { 98 this( j2eeType, Collections.singleton( parentJ2EEType ) ); 99 } 100 101 105 protected TypeData( 106 final String j2eeType, 107 final Set <String > legalParentJ2EETypes ) 108 { 109 this( j2eeType, legalParentJ2EETypes, null ); 110 } 111 112 117 protected TypeData( 118 final String j2eeType, 119 final Set <String > legalParentJ2EETypes, 120 final String containedByJ2EEType ) 121 { 122 if ( containedByJ2EEType != null && legalParentJ2EETypes != null ) 123 { 124 throw new IllegalArgumentException ( "can't have both parents and contained type" ); 125 } 126 127 mJ2EEType = j2eeType; 128 if ( containedByJ2EEType != null ) 129 { 130 mContainedByJ2EEType = containedByJ2EEType; 131 mLegalParentsTypes = null; 132 } 133 else 134 { 135 mContainedByJ2EEType = null; 136 mLegalParentsTypes = legalParentJ2EETypes == null ? 137 null : Collections.unmodifiableSet( legalParentJ2EETypes ); 138 } 139 } 140 141 public final Set <String > 142 getLegalParentJ2EETypes() 143 { 144 return( mLegalParentsTypes ); 145 } 146 147 public final String 148 getJ2EEType() 149 { 150 return( mJ2EEType ); 151 } 152 153 public boolean 154 isSubType() 155 { 156 return( mLegalParentsTypes != null ); 157 } 158 159 public final String 160 getContaineeByJ2EEType() 161 { 162 return( mContainedByJ2EEType ); 163 } 164 } 165 166 | Popular Tags |