private void buildProfileAttributeMap ( ) throws DeploymentException { HashMap < String , ProfileAttribute > map = new HashMap < String , ProfileAttribute > ( ) ; Class < ? > cmpInterface = getProfileCmpInterfaceClass ( ) ; String attributeGetterMethodPrefix = "get" ; for ( Method method : cmpInterface . getMethods ( ) ) { if ( ! method . getDeclaringClass ( ) . equals ( Object . class ) && method . getName ( ) . startsWith ( attributeGetterMethodPrefix ) ) { String attributeName = method . getName ( ) . substring ( attributeGetterMethodPrefix . length ( ) ) ; switch ( attributeName . length ( ) ) { case 0 : throw new DeploymentException ( "the profile cmp interface class has an invalid attribute getter method name > " + method . getName ( ) ) ; case 1 : attributeName = attributeName . toLowerCase ( ) ; break ; default : attributeName = attributeName . substring ( 0 , 1 ) . toLowerCase ( ) + attributeName . substring ( 1 ) ; break ; } ProfileAttributeImpl profileAttribute = null ; try { profileAttribute = new ProfileAttributeImpl ( attributeName , method . getReturnType ( ) ) ; } catch ( Throwable e ) { throw new DeploymentException ( "Invalid profile cmp interface attribute getter method definition ( name = " + attributeName + " , type = " + method . getReturnType ( ) + " )" , e ) ; } if ( isSlee11 ( ) ) { for ( ProfileCMPFieldDescriptor cmpField : getDescriptor ( ) . getProfileCMPInterface ( ) . getCmpFields ( ) ) { if ( cmpField . getCmpFieldName ( ) . equals ( attributeName ) ) { // TODO add index hints ? profileAttribute . setUnique ( cmpField . isUnique ( ) ) ; } } } else { for ( ProfileIndexDescriptor profileIndex : getDescriptor ( ) . getIndexedAttributes ( ) ) { if ( profileIndex . getName ( ) . equals ( attributeName ) ) { profileAttribute . setIndex ( true ) ; profileAttribute . setUnique ( profileIndex . getUnique ( ) ) ; } } } map . put ( attributeName , profileAttribute ) ; } } profileAttributeMap = Collections . unmodifiableMap ( map ) ; }
Builds the profile attribute map using the cmp interface class