Fixed toString and hashCode in config element. Fixing DeploymentSpec.

Signed-off-by: Jonas Bonér <jonas@jonasboner.com>
This commit is contained in:
Jonas Bonér 2011-08-30 18:41:47 +02:00
parent 796137c933
commit eb2cf56467
2 changed files with 12 additions and 5 deletions

View file

@ -21,7 +21,7 @@ class DeployerSpec extends WordSpec with MustMatchers {
None,
LeastCPU,
Clustered(
Vector(Node("node1")),
List(Node("node1")),
new ReplicationFactor(3),
Replication(
TransactionLog,

View file

@ -93,12 +93,19 @@ object DeploymentConfig {
// --- Replicas
// --------------------------------
object ReplicationFactor {
def apply(factor: Int) = new ReplicationFactor(factor)
}
class ReplicationFactor(val factor: Int) extends Serializable {
if (factor < 0) throw new IllegalArgumentException("replication-factor can not be negative")
def toString = "ReplicationFactor(" + factor +")"
override def hashCode = 0 + factor.##
override def equals(other: Any) = ReplicationFactor.unapply(this) == ReplicationFactor.unapply(other)
override def toString = "ReplicationFactor(" + factor + ")"
}
object ReplicationFactor {
def apply(factor: Int): ReplicationFactor = new ReplicationFactor(factor)
def unapply(other: Any) = other match {
case x: ReplicationFactor import x._; Some(factor)
case _ None
}
}
// For Java API