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

spock.mock.MockMakerId Maven / Gradle / Ivy

Go to download

Spock is a testing and specification framework for Java and Groovy applications. What makes it stand out from the crowd is its beautiful and highly expressive specification language. Thanks to its JUnit runner, Spock is compatible with most IDEs, build tools, and continuous integration servers. Spock is inspired from JUnit, jMock, RSpec, Groovy, Scala, Vulcans, and other fascinating life forms.

There is a newer version: 2.4-M4-groovy-4.0
Show newest version
package spock.mock;

import org.spockframework.mock.runtime.IMockMaker;
import org.spockframework.util.Beta;
import org.spockframework.util.Checks;
import org.spockframework.util.Immutable;

import java.util.Objects;
import java.util.regex.Pattern;

/**
 * Represents the ID of an {@link IMockMaker}.
 *
 * @since 2.4
 */
@Immutable
@Beta
public final class MockMakerId implements Comparable {
  private static final Pattern VALID_ID = Pattern.compile("^[a-z][a-z0-9-]*+(? "The ID is null.");
    Checks.checkArgument(VALID_ID.matcher(id).matches(), () ->
"The ID '" + id + "' is invalid. A valid ID must comply with the pattern: " + VALID_ID);

    this.id = id;
  }

  @Override
  public int compareTo(MockMakerId o) {
    return this.id.compareTo(o.id);
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    MockMakerId that = (MockMakerId) o;
    return Objects.equals(id, that.id);
  }

  @Override
  public int hashCode() {
    return Objects.hash(id);
  }

  @Override
  public String toString() {
    return id;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy