1 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 AutoLock implements Lock { 13 14 private final String methodExpression; 15 private final LockLevel lockLevel; 16 17 public AutoLock(String methodExpression, LockLevel lockLevel) { 18 Assert.assertNotBlank(methodExpression); 19 Assert.assertNotNull(lockLevel); 20 21 this.methodExpression = methodExpression; 22 this.lockLevel = lockLevel; 23 } 24 25 public boolean isAutoLock() { 26 return true; 27 } 28 29 public String lockName() { 30 throw Assert.failure("Autolocks don't have names."); 31 } 32 33 public String methodExpression() { 34 return this.methodExpression; 35 } 36 37 public LockLevel lockLevel() { 38 return this.lockLevel; 39 } 40 41 public boolean equals(Object that) { 42 if (!(that instanceof AutoLock)) return false; 43 AutoLock thatLock = (AutoLock) that; 44 return new EqualsBuilder().append(this.methodExpression, thatLock.methodExpression).append(this.lockLevel, 45 thatLock.lockLevel) 46 .isEquals(); 47 } 48 49 public int hashCode() { 50 return new HashCodeBuilder().append(this.methodExpression).append(this.lockLevel).toHashCode(); 51 } 52 53 public String toString() { 54 return new OurStringBuilder(this, OurStringBuilder.COMPACT_STYLE) 55 .append("method expression", this.methodExpression).append("lock level", this.lockLevel).toString(); 56 } 57 58 } 59 | Popular Tags |