@Override
	public <T extends Resource> T attach(String attachmentId, ResourceId resourceId, Class<? extends T> clazz) {
		checkNotNull(attachmentId,"Attachment identifier cannot be null");
		checkNotNull(resourceId,"Attached resource identifier cannot be null");
		checkNotNull(clazz,"Attached resource class cannot be null");
		this.attachmentCollection.checkNotAttached(attachmentId,resourceId);
		ResourceTemplate attachmentTemplate=super.getTemplate(resourceId);
		checkState(Resources.areCompatible(clazz,attachmentTemplate),"Attachment '%s' is not of type '%s' (%s)",attachmentId,clazz.getCanonicalName(),attachmentTemplate.getClass().getCanonicalName());
		JPAResource newResource=createChild(resourceId,attachmentTemplate);
		JPAAttachment newAttachment=this.attachmentCollection.attachmentById(attachmentId);
		newAttachment.bind(resourceId);
		return clazz.cast(newResource);
	}
@Override
	public <T extends Resource> T attach(String attachmentId, ResourceId resourceId, Class<? extends T> clazz) {
		checkNotNull(attachmentId,"Attachment identifier cannot be null");
		checkNotNull(resourceId,"Attached resource identifier cannot be null");
		checkNotNull(clazz,"Attached resource class cannot be null");
		this.attachmentCollection.checkNotAttached(attachmentId,resourceId);
		ResourceTemplate attachmentTemplate=super.getTemplate(resourceId);
		checkState(Resources.areCompatible(clazz,attachmentTemplate),"Attachment '%s' is not of type '%s' (%s)",attachmentId,clazz.getCanonicalName(),attachmentTemplate.getClass().getCanonicalName());
		JPAResource newResource=createChild(resourceId,attachmentTemplate);
		JPAAttachment newAttachment=this.attachmentCollection.attachmentById(attachmentId);
		newAttachment.bind(resourceId);
		return clazz.cast(newResource);
	}
@ Override public < T extends Resource > T attach ( String attachmentId , ResourceId resourceId , Class < ? extends T > clazz ) { checkNotNull ( attachmentId , "Attachment identifier cannot be null" ) ; checkNotNull ( resourceId , "Attached resource identifier cannot be null" ) ; checkNotNull ( clazz , "Attached resource class cannot be null" ) ; this . attachmentCollection . checkNotAttached ( attachmentId , resourceId ) ; ResourceTemplate attachmentTemplate = super . getTemplate ( resourceId ) ; checkState ( Resources . areCompatible ( clazz , attachmentTemplate ) , "Attachment '%s' is not of type '%s' (%s)" , attachmentId , clazz . getCanonicalName ( ) , attachmentTemplate . getClass ( ) . getCanonicalName ( ) ) ; JPAResource newResource = createChild ( resourceId , attachmentTemplate ) ; JPAAttachment newAttachment = this . attachmentCollection . attachmentById ( attachmentId ) ; newAttachment . bind ( resourceId ) ; return clazz . cast ( newResource ) ; }
{@inheritDoc}
{