<commit_before>package net.jodah.failsafe.util;

import java.util.Objects;
import java.util.concurrent.TimeUnit;

/**
 * Duration, consisting of length of a time unit.
 */
public class Duration {
  public static final Duration NONE = new Duration(0, TimeUnit.MILLISECONDS);

  private final long length;
  private final TimeUnit timeUnit;

  public Duration(long length, TimeUnit timeUnit) {
    this.length = length;
    this.timeUnit = timeUnit;
  }

  @Override public boolean equals(Object o)
  {
    return this == o 
        || Duration.class.isInstance(o)
           && toNanos() == Duration.class.cast(o).toNanos();
  }

  @Override public int hashCode()
  {
    return Objects.hash(toNanos(), TimeUnit.NANOSECONDS);
  }
    
  @Override public String toString()
  {
    return "Duration{" + "length=" + length + ", timeUnit=" + timeUnit + '}';
  }

  /**
   * Returns the Duration in nanoseconds.
   */
  public long toNanos() {
    return timeUnit.toNanos(length);
  }

  /**
   * Returns the Duration in milliseconds.
   */
  public long toMillis() {
    return timeUnit.toMillis(length);
  }

  /**
   * Returns the Duration in seconds.
   */
  public long toSeconds() {
    return timeUnit.toSeconds(length);
  }

  /**
   * Returns the Duration in minutes.<commit_msg>Add Duration.equals/toString/hashCode + some simple tests for same.<commit_after>package net.jodah.failsafe.util;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import static java.util.concurrent.TimeUnit.NANOSECONDS;

/**
 * Duration, consisting of length of a time unit.
 */
public class Duration {
  public static final Duration NONE = new Duration(0, TimeUnit.MILLISECONDS);

  private final long length;
  private final TimeUnit timeUnit;

  public Duration(long length, TimeUnit timeUnit) {
    this.length = length;
    this.timeUnit = timeUnit;
  }

  @Override public boolean equals(Object o)
  {
    return this == o 
        || Duration.class.isInstance(o)
           && toNanos() == Duration.class.cast(o).toNanos();
  }

  @Override public int hashCode()
  {
    return Arrays.hashCode(new Object[] {toNanos(), NANOSECONDS});
  }

  @Override public String toString()
  {
    return "Duration{" + "length=" + length + ", timeUnit=" + timeUnit + '}';
  }

  /**
   * Returns the Duration in nanoseconds.
   */
  public long toNanos() {
    return timeUnit.toNanos(length);
  }

  /**
   * Returns the Duration in milliseconds.
   */
  public long toMillis() {
    return timeUnit.toMillis(length);
  }

  /**
   * Returns the Duration in seconds.
   */
  public long toSeconds() {
    return timeUnit.toSeconds(length);
  }

  /**
   * Returns the Duration in minutes.
{'fraction_non_alphanumeric': 0.12126865671641791, 'fraction_numerical': 0.0007462686567164179, 'mean_word_length': 3.080669710806697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '974052', 'n_tokens_mistral': 876, 'n_tokens_neox': 830, 'n_words': 220}