KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > config > schema > NamedLock


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.config.schema;
5
6 import org.apache.commons.lang.builder.EqualsBuilder;
7 import org.apache.commons.lang.builder.HashCodeBuilder;
8
9 import com.tc.util.Assert;
10 import com.tc.util.stringification.OurStringBuilder;
11
12 public class NamedLock implements Lock {
13
14   private final String JavaDoc lockName;
15   private final String JavaDoc methodExpression;
16   private final LockLevel lockLevel;
17
18   public NamedLock(String JavaDoc lockName, String JavaDoc methodExpression, LockLevel lockLevel) {
19     Assert.assertNotBlank(lockName);
20     Assert.assertNotBlank(methodExpression);
21
22     this.lockName = lockName;
23     this.methodExpression = methodExpression;
24     this.lockLevel = lockLevel;
25   }
26
27   public boolean isAutoLock() {
28     return false;
29   }
30
31   public String JavaDoc lockName() {
32     return this.lockName;
33   }
34
35   public String JavaDoc methodExpression() {
36     return this.methodExpression;
37   }
38
39   public LockLevel lockLevel() {
40     return this.lockLevel;
41   }
42
43   public boolean equals(Object JavaDoc that) {
44     if (!(that instanceof NamedLock)) return false;
45     NamedLock thatLock = (NamedLock) that;
46     return new EqualsBuilder().append(this.methodExpression, thatLock.methodExpression).append(this.lockLevel,
47                                                                                                thatLock.lockLevel)
48         .append(this.lockName, thatLock.lockName).isEquals();
49   }
50
51   public int hashCode() {
52     return new HashCodeBuilder().append(this.methodExpression).append(this.lockLevel).append(this.lockName)
53         .toHashCode();
54   }
55
56   public String JavaDoc toString() {
57     return new OurStringBuilder(this, OurStringBuilder.COMPACT_STYLE)
58         .append("method expression", this.methodExpression).append("lock level", this.lockLevel).append("lock name",
59                                                                                                         this.lockName)
60         .toString();
61   }
62
63 }
64
Popular Tags