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

com.clouway.oauth2.Duration Maven / Gradle / Ivy

package com.clouway.oauth2;

/**
 * @author Ivan Stefanov 
 */
public class Duration {
  public Long seconds;

  public Duration() {
  }

  public Duration(Long seconds) {
    this.seconds = seconds;
  }

  public static Duration minutes(Integer minutes) {
    return new Duration(minutes * 60L);
  }

  public static Duration hours(Integer hours) {
    return new Duration(hours * 60 * 60L);
  }

  public static Duration seconds(Long seconds) {
    return new Duration(seconds);
  }

  public Long asMills() {
    return seconds * 1000;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof Duration)) return false;

    Duration duration = (Duration) o;

    if (seconds != null ? !seconds.equals(duration.seconds) : duration.seconds != null) return false;

    return true;
  }

  @Override
  public int hashCode() {
    return seconds != null ? seconds.hashCode() : 0;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy