Java Code Examples for javax.persistence.metamodel.PluralAttribute#CollectionType

The following examples show how to use javax.persistence.metamodel.PluralAttribute#CollectionType . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractManagedType.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private <E> void checkTypeForPluralAttributes(
		String attributeType,
		PluralAttribute<?,?,?> attribute,
		String name,
		Class<E> elementType,
		PluralAttribute.CollectionType collectionType) {
	if ( attribute == null
			|| ( elementType != null && !attribute.getBindableJavaType().equals( elementType ) )
			|| attribute.getCollectionType() != collectionType ) {
		throw new IllegalArgumentException(
				attributeType + " named " + name
				+ ( elementType != null ? " and of element type " + elementType : "" )
				+ " is not present"
		);
	}
}
 
Example 2
Source File: AttributeFactory.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static PluralAttribute.CollectionType determineCollectionType(Class javaType) {
	if ( java.util.List.class.isAssignableFrom( javaType ) ) {
		return PluralAttribute.CollectionType.LIST;
	}
	else if ( java.util.Set.class.isAssignableFrom( javaType ) ) {
		return PluralAttribute.CollectionType.SET;
	}
	else if ( java.util.Map.class.isAssignableFrom( javaType ) ) {
		return PluralAttribute.CollectionType.MAP;
	}
	else if ( java.util.Collection.class.isAssignableFrom( javaType ) ) {
		return PluralAttribute.CollectionType.COLLECTION;
	}
	else if ( javaType.isArray() ) {
		return PluralAttribute.CollectionType.LIST;
	}
	else {
		throw new IllegalArgumentException( "Expecting collection type [" + javaType.getName() + "]" );
	}
}
 
Example 3
Source File: AttributeFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public PluralAttribute.CollectionType getAttributeCollectionType() {
	return attributeCollectionType;
}
 
Example 4
Source File: AttributeFactory.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Retrieve the JPA collection type classification for this attribute
 *
 * @return The JPA collection type classification
 */
public PluralAttribute.CollectionType getAttributeCollectionType();