@Override @SuppressWarnings("unchecked") protected ManagedType<? super X> locateManagedType() { if ( getModel().getBindableType() == Bindable.BindableType.ENTITY_TYPE ) { return (ManagedType<? super X>) getModel(); } else if ( getModel().getBindableType() == Bindable.BindableType.SINGULAR_ATTRIBUTE ) { final Type joinedAttributeType = ( (SingularAttribute) getAttribute() ).getType(); if ( !ManagedType.class.isInstance( joinedAttributeType ) ) { throw new UnsupportedOperationException( "Cannot further dereference attribute join [" + getPathIdentifier() + "] as its type is not a ManagedType" ); } return (ManagedType<? super X>) joinedAttributeType; } else if ( getModel().getBindableType() == Bindable.BindableType.PLURAL_ATTRIBUTE ) { final Type elementType = ( (PluralAttribute) getAttribute() ).getElementType(); if ( !ManagedType.class.isInstance( elementType ) ) { throw new UnsupportedOperationException( "Cannot further dereference attribute join [" + getPathIdentifier() + "] (plural) as its element type is not a ManagedType" ); } return (ManagedType<? super X>) elementType; } return super.locateManagedType(); }
if ( getPathSource().getModel().getBindableType() == Bindable.BindableType.ENTITY_TYPE ) { "Unexpected BindableType; expected [%s]; instead got [%s]", Bindable.BindableType.ENTITY_TYPE, getPathSource().getModel().getBindableType()
public void addAttribute(Attribute<X,?> attribute) { declaredAttributes.put( attribute.getName(), attribute ); final Bindable.BindableType bindableType = ( ( Bindable ) attribute ).getBindableType(); switch ( bindableType ) { case SINGULAR_ATTRIBUTE : { declaredSingularAttributes.put( attribute.getName(), (SingularAttribute<X,?>) attribute ); break; } case PLURAL_ATTRIBUTE : { declaredPluralAttributes.put(attribute.getName(), (PluralAttribute<X,?,?>) attribute ); break; } default : { throw new AssertionFailure( "unknown bindable type: " + bindableType ); } } } };
@Override @SuppressWarnings({"unchecked"}) protected ManagedType<? super X> getManagedType() { Bindable<X> m = getModel(); Bindable.BindableType t = m.getBindableType(); switch (t) { case ENTITY_TYPE: return (ManagedType<? super X>) m; case SINGULAR_ATTRIBUTE: final Type<?> joinedAttributeType = ((SingularAttribute<?, ?>) getAttribute()).getType(); if (!(joinedAttributeType instanceof ManagedType<?>)) { throw new IllegalArgumentException("Joins on '" + getPathExpression() + "' are not allowed"); } return (ManagedType<? super X>) joinedAttributeType; case PLURAL_ATTRIBUTE: final Type<?> elementType = ((PluralAttribute<?, ?, ?>) getAttribute()).getElementType(); if (!(elementType instanceof ManagedType<?>)) { throw new IllegalArgumentException("Joins on '" + getPathExpression() + "' are not allowed"); } return (ManagedType<? super X>) elementType; default: break; } return super.getManagedType(); }
@Override @SuppressWarnings({"unchecked"}) protected ManagedType<? super X> getManagedType() { Bindable<X> m = getModel(); Bindable.BindableType t = m.getBindableType(); switch (t) { case ENTITY_TYPE: return (ManagedType<? super X>) m; case SINGULAR_ATTRIBUTE: final Type<?> joinedAttributeType = ((SingularAttribute<?, ?>) getAttribute()).getType(); if (!(joinedAttributeType instanceof ManagedType<?>)) { throw new IllegalArgumentException("Joins on '" + getPathExpression() + "' are not allowed"); } return (ManagedType<? super X>) joinedAttributeType; case PLURAL_ATTRIBUTE: final Type<?> elementType = ((PluralAttribute<?, ?, ?>) getAttribute()).getElementType(); if (!(elementType instanceof ManagedType<?>)) { throw new IllegalArgumentException("Joins on '" + getPathExpression() + "' are not allowed"); } return (ManagedType<? super X>) elementType; default: break; } return super.getManagedType(); }