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

com.github.dakusui.floorplan.Connector 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;

import com.github.dakusui.floorplan.component.Attribute;
import com.github.dakusui.floorplan.component.Ref;

import static com.github.dakusui.floorplan.utils.Checks.requireArgument;
import static java.util.Objects.requireNonNull;

public class Connector {
  private Attribute fromAttr;
  private Ref       from;

  private Connector(Ref from, Attribute fromAttr) {
    requireArgument(fromAttr, attr -> from.spec() == attr.spec());
    this.fromAttr = requireNonNull(fromAttr);
    this.from = requireNonNull(from);
  }

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

  @Override
  public boolean equals(Object anotherObject) {
    if (anotherObject instanceof Connector) {
      Connector another = Connector.class.cast(anotherObject);
      return another.from.equals(this.from) && another.fromAttr.equals(this.fromAttr);
    }
    return false;
  }

  public static Connector connector(Ref from, Attribute fromAttr) {
    return new Connector(from, fromAttr);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy