Skip to content
Permalink
Browse files

Merge pull request #84 from davidalain/master

 Fixing mistake in hashCode() and equals()
  • Loading branch information...
NetCal committed Aug 13, 2019
2 parents 3e7c640 + 49fd041 commit ee59c50fd495bae69f196872c8e29f05fa48efb1
@@ -28,6 +28,7 @@

import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
@@ -200,6 +201,30 @@ public AnalysisConfig copy() { // deep copy as primitive data types are copied b
}

@Override
public int hashCode() {
return Objects.hash(multiplexing_enforcement, enforce_max_sc, enforce_max_sc_output_rate, arrival_bound_methods,
convolve_alternative_arrival_bounds, server_backlog_arrival_bound);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AnalysisConfig other = (AnalysisConfig) obj;

return Objects.equals(this.multiplexing_enforcement, other.multiplexing_enforcement) &&
Objects.equals(this.enforce_max_sc, other.enforce_max_sc) &&
Objects.equals(this.enforce_max_sc_output_rate, other.enforce_max_sc_output_rate) &&
Objects.equals(this.arrival_bound_methods, other.arrival_bound_methods) &&
Objects.equals(this.convolve_alternative_arrival_bounds, other.convolve_alternative_arrival_bounds) &&
Objects.equals(this.server_backlog_arrival_bound, other.server_backlog_arrival_bound);
}

@Override
public String toString() {
StringBuffer analysis_config_str = new StringBuffer();

@@ -27,6 +27,8 @@

package org.networkcalculus.dnc.curves.disco;

import java.util.Objects;

import org.networkcalculus.dnc.Calculator;
import org.networkcalculus.dnc.curves.LinearSegment;
import org.networkcalculus.num.Num;
@@ -223,7 +225,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return x.hashCode() * y.hashCode() * grad.hashCode() * Boolean.hashCode(leftopen);
return Objects.hash(x, y, grad, leftopen);
}

/**
@@ -27,6 +27,8 @@

package org.networkcalculus.dnc.curves.disco.affine;

import java.util.Objects;

import org.networkcalculus.dnc.curves.ArrivalCurve;
import org.networkcalculus.dnc.curves.Curve;
import org.networkcalculus.dnc.curves.disco.Curves_Disco_Configuration;
@@ -87,7 +89,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return "AC".hashCode() * super.hashCode();
return Objects.hash("AC", super.hashCode());
}

/**
@@ -27,6 +27,8 @@

package org.networkcalculus.dnc.curves.disco.affine;

import java.util.Objects;

import org.networkcalculus.dnc.curves.Curve;
import org.networkcalculus.dnc.curves.MaxServiceCurve;
import org.networkcalculus.dnc.curves.disco.Curves_Disco_Configuration;
@@ -88,7 +90,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return "MSC".hashCode() * super.hashCode();
return Objects.hash("MSC", super.hashCode());
}

/**
@@ -27,6 +27,8 @@

package org.networkcalculus.dnc.curves.disco.affine;

import java.util.Objects;

import org.networkcalculus.dnc.curves.Curve;
import org.networkcalculus.dnc.curves.ServiceCurve;
import org.networkcalculus.dnc.curves.disco.Curves_Disco_Configuration;
@@ -83,7 +85,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return "SC".hashCode() * super.hashCode();
return Objects.hash("SC", super.hashCode());
}

/**
@@ -27,6 +27,8 @@

package org.networkcalculus.dnc.curves.disco.pw_affine;

import java.util.Objects;

import org.networkcalculus.dnc.curves.ArrivalCurve;
import org.networkcalculus.dnc.curves.Curve;
import org.networkcalculus.dnc.curves.disco.Curves_Disco_Configuration;
@@ -87,7 +89,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return "AC".hashCode() * super.hashCode();
return Objects.hash("AC", super.hashCode());
}

/**
@@ -27,6 +27,8 @@

package org.networkcalculus.dnc.curves.disco.pw_affine;

import java.util.Objects;

import org.networkcalculus.dnc.curves.Curve;
import org.networkcalculus.dnc.curves.MaxServiceCurve;
import org.networkcalculus.dnc.curves.disco.Curves_Disco_Configuration;
@@ -86,7 +88,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return "MSC".hashCode() * super.hashCode();
return Objects.hash("MSC", super.hashCode());
}

/**
@@ -27,6 +27,8 @@

package org.networkcalculus.dnc.curves.disco.pw_affine;

import java.util.Objects;

import org.networkcalculus.dnc.curves.Curve;
import org.networkcalculus.dnc.curves.ServiceCurve;
import org.networkcalculus.dnc.curves.disco.Curves_Disco_Configuration;
@@ -83,7 +85,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return "SC".hashCode() * super.hashCode();
return Objects.hash("SC", super.hashCode());
}

/**
@@ -31,6 +31,7 @@
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;

import org.networkcalculus.dnc.Calculator;
import org.networkcalculus.dnc.curves.Curve;
@@ -293,7 +294,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return (int) Arrays.hashCode(path_servers.toArray()) * Arrays.hashCode(path_turns.toArray());
return Objects.hash(path_servers, path_turns);
}

// --------------------------------------------------------------------------------------------------------------
@@ -26,6 +26,8 @@

package org.networkcalculus.dnc.network.server_graph;

import java.util.Objects;

public class Turn {
private int id;
private String alias;
@@ -66,13 +68,13 @@ public boolean equals(Object obj) {
}

Turn l = (Turn) obj;
return (this.src != null ? this.src.equals(l.src) : l.src == null)
&& (this.dest != null ? this.dest.equals(l.dest) : l.dest == null);
return Objects.equals(this.src, l.src) &&
Objects.equals(this.dest, l.dest);
}

@Override
public int hashCode() {
return (int) src.hashCode() * dest.hashCode();
return Objects.hash(src, dest);
}

// --------------------------------------------------------------------------------------------------------------

0 comments on commit ee59c50

Please sign in to comment.
You can’t perform that action at this time.