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

com.github.dakusui.floorplan.component.Ref Maven / Gradle / Ivy

Go to download

A library to model a heterogeneous and distributed software system for testing

There is a newer version: 5.1.1
Show newest version
package com.github.dakusui.floorplan.component;

import java.util.Objects;

import static java.util.Objects.requireNonNull;

public final class Ref {
  private ComponentSpec spec;
  private String           id;

  private Ref(ComponentSpec spec, String id) {
    this.spec = requireNonNull(spec);
    this.id = requireNonNull(id);
  }

  public ComponentSpec spec() {
    return this.spec;
  }

  public String id() {
    return this.id;
  }

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

  @Override
  public boolean equals(Object anotherObject) {
    if (anotherObject instanceof Ref) {
      Ref another = (Ref) anotherObject;
      return this.spec.equals(another.spec) && Objects.equals(this.id, another.id);
    }
    return false;
  }

  @Override
  public String toString() {
    return String.format("%s#%s", spec, id);
  }

  public static Ref ref(ComponentSpec spec, String id) {
    return new Ref(spec, id);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy