All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.selendroid.server.common.action.touch.FlickDirection Maven / Gradle / Ivy

The newest version!
package io.selendroid.server.common.action.touch;

import java.util.HashMap;
import java.util.Map;

public enum FlickDirection {
  UP("up", 0, -1),
  DOWN("down", 0, 1),
  LEFT("left", -1, 0),
  RIGHT("right", 1 ,0);

  private final String direction; // String representation so these can be sent over the wire
  private final int xMultiplier;
  private final int yMultiplier;

  private final static Map directionMap
      = new HashMap();

  FlickDirection(String direction, int xMultiplier, int yMultiplier) {
    this.direction = direction;
    this.xMultiplier = xMultiplier;
    this.yMultiplier = yMultiplier;
  }

  static {
    // Build map so we get the scroll direction for a given string
    for (FlickDirection direction : FlickDirection.values()) {
      directionMap.put(direction.getDirection(), direction);
    }
  }

  public static FlickDirection fromString(String directionString) {
    FlickDirection direction = directionMap.get(directionString);
    if (direction == null) {
      throw new IllegalArgumentException(
          "Attempted to lookup invalid direction: " + directionString);
    }

    return direction;
  }

  public String getDirection() {
    return direction;
  }

  public int getxMultiplier() {
    return xMultiplier;
  }

  public int getyMultiplier() {
    return yMultiplier;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy