code: @Programmatic
      public <T> T paperclipAttaches(final Document document, Class<T> typeAttachedTo) {
          final List<Paperclip> paperclips = findByDocument(document);
          for (Paperclip paperclip : paperclips) {
              final Object attachedTo = paperclip.getAttachedTo();
              if(typeAttachedTo.isAssignableFrom(attachedTo.getClass())) {
                  return (T) attachedTo;
              }
          }
          return null;
      }
docs: region > attach (programmatic)