gt: 		if ( element != null ) {
context: /*
   * Hibernate, Relational Persistence for Idiomatic Java
   *
   * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
   * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
   */
  package org.hibernate.cfg;
  
  import java.util.HashMap;
  import java.util.Map;
  import javax.persistence.Convert;
  import javax.persistence.Converts;
  import javax.persistence.Enumerated;
  import javax.persistence.JoinTable;
  import javax.persistence.ManyToMany;
  import javax.persistence.MapKeyClass;
  import javax.persistence.MapKeyEnumerated;
  import javax.persistence.MapKeyTemporal;
  import javax.persistence.OneToMany;
  import javax.persistence.Temporal;
  
  import org.hibernate.AssertionFailure;
  import org.hibernate.annotations.CollectionType;
  import org.hibernate.annotations.ManyToAny;
  import org.hibernate.annotations.MapKeyType;
  import org.hibernate.annotations.common.reflection.XClass;
  import org.hibernate.annotations.common.reflection.XProperty;
  import org.hibernate.boot.spi.AttributeConverterDescriptor;
  import org.hibernate.boot.spi.MetadataBuildingContext;
  import org.hibernate.internal.CoreLogging;
  import org.hibernate.internal.CoreMessageLogger;
  import org.hibernate.internal.util.StringHelper;
  import org.hibernate.mapping.Collection;
  import org.hibernate.mapping.IndexedCollection;
  import org.hibernate.mapping.Join;
  import org.hibernate.mapping.KeyValue;
  import org.hibernate.mapping.PersistentClass;
  import org.hibernate.mapping.Property;
  import org.hibernate.mapping.Table;
  
  /**
   * @author Emmanuel Bernard
   * @author Steve Ebersole
   */
  public class CollectionPropertyHolder extends AbstractPropertyHolder {
  	private static final CoreMessageLogger log = CoreLogging.messageLogger( CollectionPropertyHolder.class );
  
  	private final Collection collection;
  
  	// assume true, the constructor will opt out where appropriate
  	private boolean canElementBeConverted = true;
  	private boolean canKeyBeConverted = true;
  
  	private Map<String,AttributeConversionInfo> elementAttributeConversionInfoMap;
  	private Map<String,AttributeConversionInfo> keyAttributeConversionInfoMap;
  
  	public CollectionPropertyHolder(
  			Collection collection,
  			String path,
  			XClass clazzToProcess,
  			XProperty property,
  			PropertyHolder parentPropertyHolder,
  			MetadataBuildingContext context) {
  		super( path, parentPropertyHolder, clazzToProcess, context );
  		this.collection = collection;
  		setCurrentProperty( property );
  
  		this.elementAttributeConversionInfoMap = new HashMap<String, AttributeConversionInfo>();
  		this.keyAttributeConversionInfoMap = new HashMap<String, AttributeConversionInfo>();
  	}
  
  	public Collection getCollectionBinding() {
  		return collection;
  	}
  
  	private void buildAttributeConversionInfoMaps(
  			XProperty collectionProperty,
  			Map<String,AttributeConversionInfo> elementAttributeConversionInfoMap,
  			Map<String,AttributeConversionInfo> keyAttributeConversionInfoMap) {
  		if ( collectionProperty == null ) {
  			// not sure this is valid condition
  			return;
  		}
  
  		{
  			final Convert convertAnnotation = collectionProperty.getAnnotation( Convert.class );
  			if ( convertAnnotation != null ) {
  				applyLocalConvert( convertAnnotation, collectionProperty, elementAttributeConversionInfoMap, keyAttributeConversionInfoMap );
  			}
  		}
  
  		{
  			final Converts convertsAnnotation = collectionProperty.getAnnotation( Converts.class );
  			if ( convertsAnnotation != null ) {
  				for ( Convert convertAnnotation : convertsAnnotation.value() ) {
  					applyLocalConvert(
  							convertAnnotation,
  							collectionProperty,
  							elementAttributeConversionInfoMap,
  							keyAttributeConversionInfoMap
  					);
  				}
  			}
  		}
  	}
  
  	private void applyLocalConvert(
  			Convert convertAnnotation,
  			XProperty collectionProperty,
  			Map<String,AttributeConversionInfo> elementAttributeConversionInfoMap,
  			Map<String,AttributeConversionInfo> keyAttributeConversionInfoMap) {
  
  		// IMPL NOTE : the rules here are quite more lenient than what JPA says.  For example, JPA says
  		// that @Convert on a Map always needs to specify attributeName of key/value (or prefixed with
  		// key./value. for embedded paths).  However, we try to see if conversion of either is disabled
  		// for whatever reason.  For example, if the Map is annotated with @Enumerated the elements cannot
  		// be converted so any @Convert likely meant the key, so we apply it to the key
  
  		final AttributeConversionInfo info = new AttributeConversionInfo( convertAnnotation, collectionProperty );
  		if ( collection.isMap() ) {
  			boolean specCompliant = StringHelper.isNotEmpty( info.getAttributeName() )
  					&& ( info.getAttributeName().startsWith( "key" )
  					|| info.getAttributeName().startsWith( "value" ) );
  			if ( !specCompliant ) {
  				log.nonCompliantMapConversion( collection.getRole() );
  			}
  		}
  
  		if ( StringHelper.isEmpty( info.getAttributeName() ) ) {
  			// the @Convert did not name an attribute...
  			if ( canElementBeConverted && canKeyBeConverted ) {
  				throw new IllegalStateException(
  						"@Convert placed on Map attribute [" + collection.getRole()
  								+ "] must define attributeName of 'key' or 'value'"
  				);
  			}
  			else if ( canKeyBeConverted ) {
  				keyAttributeConversionInfoMap.put( "", info );
  			}
  			else if ( canElementBeConverted ) {
  				elementAttributeConversionInfoMap.put( "", info );
  			}
  			// if neither, we should not be here...
  		}
  		else {
  			// the @Convert named an attribute...
  			final String keyPath = removePrefix( info.getAttributeName(), "key" );
  			final String elementPath = removePrefix( info.getAttributeName(), "value" );
  
  			if ( canElementBeConverted && canKeyBeConverted && keyPath == null && elementPath == null ) {
  				// specified attributeName needs to have 'key.' or 'value.' prefix
  				throw new IllegalStateException(
  						"@Convert placed on Map attribute [" + collection.getRole()
  								+ "] must define attributeName of 'key' or 'value'"
  				);
  			}
  
  			if ( keyPath != null ) {
  				keyAttributeConversionInfoMap.put( keyPath, info );
  			}
  			else if ( elementPath != null ) {
  				elementAttributeConversionInfoMap.put( elementPath, info );
  			}
  		}
  	}
  
  	/**
  	 * Check if path has the given prefix and remove it.
  	 *
  	 * @param path Path.
  	 * @param prefix Prefix.
  	 * @return Path without prefix, or null, if path did not have the prefix.
  	 */
  	private String removePrefix(String path, String prefix) {
  		if ( path.equals(prefix) ) {
  			return "";
  		}
  
  		if (path.startsWith(prefix + ".")) {
  			return path.substring( prefix.length() + 1 );
  		}
  
  		return null;
  	}
  
  	@Override
  	protected String normalizeCompositePath(String attributeName) {
  		return attributeName;
  	}
  
  	@Override
  	protected String normalizeCompositePathForLogging(String attributeName) {
  		return collection.getRole() + '.' + attributeName;
  	}
  
  	@Override
  	public void startingProperty(XProperty property) {
  		if ( property == null ) {
  			return;
  		}
  
  		// todo : implement (and make sure it gets called - for handling collections of composites)
  	}
  
  	@Override
  	protected AttributeConversionInfo locateAttributeConversionInfo(XProperty property) {
  		if ( canElementBeConverted && canKeyBeConverted ) {
  			// need to decide whether 'property' refers to key/element
  			// todo : this may not work for 'basic collections' since there is no XProperty for the element
  		}
  		else if ( canKeyBeConverted ) {
  
  		}
  		else {
  			return null;
  		}
  
  		return null;
  	}
  
  	@Override
  	protected AttributeConversionInfo locateAttributeConversionInfo(String path) {
  		final String key = removePrefix( path, "key" );
  		if ( key != null ) {
  			return keyAttributeConversionInfoMap.get( key );
  		}
  
  		final String element = removePrefix( path, "element" );
  