1 16 package org.springframework.binding.expression.support; 17 18 import org.springframework.binding.expression.EvaluationContext; 19 import org.springframework.binding.expression.EvaluationException; 20 import org.springframework.binding.expression.Expression; 21 import org.springframework.util.ObjectUtils; 22 23 28 public class StaticExpression implements Expression { 29 30 33 private Object value; 34 35 39 public StaticExpression(Object value) { 40 this.value = value; 41 } 42 43 public int hashCode() { 44 if (value == null) { 45 return 0; 46 } 47 else { 48 return value.hashCode(); 49 } 50 } 51 52 public boolean equals(Object o) { 53 if (!(o instanceof StaticExpression)) { 54 return false; 55 } 56 StaticExpression other = (StaticExpression)o; 57 return ObjectUtils.nullSafeEquals(value, other.value); 58 } 59 60 public Object evaluate(Object target, EvaluationContext context) throws EvaluationException { 61 return value; 62 } 63 64 public String toString() { 65 return String.valueOf(value); 66 } 67 } | Popular Tags |