code: public static <T extends UIObject> String animate(final T widget, final String animation, final int count, final int duration, final int delay) {
  
          if (widget != null && animation != null) {
              // on valid input
              if (widget.getStyleName().contains(animation)) {
                  // animation is present, remove it and run again.
                  stopAnimation(widget, animation);
                  Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
                      @Override
                      public boolean execute() {
                          styleElement(widget.getElement(), animation, count, duration, delay);
                          return false;
                      }
                  }, 200);
                  return animation + " " + getStyleNameFromAnimation(animation,count,duration,delay);
              } else {
                  // animation was not present, run immediately
                  return styleElement(widget.getElement(), animation, count, duration, delay);
              }
          } else {
              return null;
          }
  
      }
docs: Animate any element with specific animation. Animation is done by CSS and runs multiple times.
  
  Animation is started when element is appended to the DOM or new (not same) animation is added
  to already displayed element. Animation runs on hidden elements too and is not paused/stopped
  when element is set as hidden.
  
  @param widget Widget to apply animation to.
  @param animation Custom CSS class name used as animation.
  @param count Number of animation repeats. 0 disables animation, any negative value set repeats to infinite.
  @param duration Animation duration in ms. 0 disables animation, any negative value keeps default of original animation.
  @param delay Delay before starting the animation loop in ms. Value <= 0 means no delay.
  @param <T> Any object extending UIObject class (typically Widget).
  @return Animation's CSS class name, which can be removed to stop animation.