@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof RoadModelBuilders.CollisionGraphRMB) { RoadModelBuilders.CollisionGraphRMB that = (RoadModelBuilders.CollisionGraphRMB) o; return (this.distanceUnit.equals(that.getDistanceUnit())) && (this.speedUnit.equals(that.getSpeedUnit())) && (this.graphSupplier.equals(that.getGraphSupplier())) && (this.modCheckEnabled == that.isModCheckEnabled()) && (Double.doubleToLongBits(this.vehicleLength) == Double.doubleToLongBits(that.getVehicleLength())) && (Double.doubleToLongBits(this.minDistance) == Double.doubleToLongBits(that.getMinDistance())); } return false; }
/** * Returns a copy of this builder with the specified vehicle length. The * vehicle length defines the length of each vehicle added to the * {@link CollisionGraphRoadModel} that will be constructed by this builder. * The vehicle length must be a strictly positive number. The default value * is {@link #DEFAULT_VEHICLE_LENGTH}. * @param length A length expressed in the unit set by * {@link #withDistanceUnit(Unit)}. * @return A new builder instance. */ @CheckReturnValue public CollisionGraphRMB withVehicleLength(double length) { checkArgument(length > 0d, "Only positive vehicle lengths are allowed, found %s.", length); checkArgument(Doubles.isFinite(length), "%s is not a valid vehicle length.", length); return create(getDistanceUnit(), getSpeedUnit(), getGraphSupplier(), isModCheckEnabled(), length, getMinDistance()); }
/** * Returns a copy of this builder with the specified min distance. The min * distance defines the minimum required distance between two vehicles. The * minimum distance must be a positive number ≤ to 2 * vehicle length. * The default value is {@link #DEFAULT_MIN_DISTANCE}. * @param dist A distance expressed in the unit set by * {@link #withDistanceUnit(Unit)}. * @return A new builder instance. */ @CheckReturnValue public CollisionGraphRMB withMinDistance(double dist) { checkArgument(dist >= 0d); return create(getDistanceUnit(), getSpeedUnit(), getGraphSupplier(), isModCheckEnabled(), getVehicleLength(), dist); }
@Override public CollisionGraphRoadModelImpl build( DependencyProvider dependencyProvider) { checkArgument(getDistanceUnit() == SI.METER, "Currently only %s is supported, found %s.", SI.METER, getDistanceUnit()); final double minConnectionLength = getVehicleLength(); checkArgument( getMinDistance() <= minConnectionLength, "Min distance must be smaller than 2 * vehicle length (%s), but is %s.", getVehicleLength(), getMinDistance()); final ListenableGraph<?> graph = getGraph(); for (final Connection<?> conn : graph.getConnections()) { CollisionGraphRoadModelImpl .checkConnectionLength(minConnectionLength, conn); } return new CollisionGraphRoadModelImpl(graph, minConnectionLength, this); }
@Override public CollisionGraphRMB withSpeedUnit(Unit<Velocity> unit) { return create(getDistanceUnit(), unit, getGraphSupplier(), isModCheckEnabled(), getVehicleLength(), getMinDistance()); }
@Override public CollisionGraphRMB withModificationCheck(boolean enabled) { return create(getDistanceUnit(), getSpeedUnit(), getGraphSupplier(), enabled, getVehicleLength(), getMinDistance()); }