org.nomin.core.ValueRuleElem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nomin Show documentation
Show all versions of nomin Show documentation
Nomin is a mapping engine for the Java platform. It provides abilities to transform object trees according to
declarative mapping rules. Main features of Nomin are no XML configuration, intuitively looking mapping,
using arbitrary expressions and method invocations in mappings, pre and postprocessing right in a mapping listing,
customizations. It's applicable for any Java compatible classes, not only JavaBeans.
package org.nomin.core;
import org.nomin.util.TypeInfoFactory;
/**
* Contains static value and provides access to it.
* @author Dmitry Dobrynin
* Created: 27.04.2010 22:43:38
*/
public class ValueRuleElem extends RuleElem {
final Object value;
public ValueRuleElem(Object value) {
super(TypeInfoFactory.typeInfo(value != null ? value.getClass() : Object.class));
this.value = value;
}
public Object get(Object instance) throws Exception { return value; }
public Object set(Object instance, Object value) throws Exception {
throw new NominException("Could not change the constant value!");
}
public String toString() { return String.valueOf(value); }
}