diff --git a/tools/src/main/java/org/jvnet/jaxb2_commons/xjc/outline/artificial/ConstantPropertyOutline.java b/tools/src/main/java/org/jvnet/jaxb2_commons/xjc/outline/artificial/ConstantPropertyOutline.java index 505c6e42..e01f8bea 100644 --- a/tools/src/main/java/org/jvnet/jaxb2_commons/xjc/outline/artificial/ConstantPropertyOutline.java +++ b/tools/src/main/java/org/jvnet/jaxb2_commons/xjc/outline/artificial/ConstantPropertyOutline.java @@ -1,86 +1,85 @@ -package org.jvnet.jaxb2_commons.xjc.outline.artificial; - -import org.apache.commons.lang3.Validate; -import org.jvnet.jaxb2_commons.xjc.outline.MClassOutline; -import org.jvnet.jaxb2_commons.xjc.outline.MPropertyAccessor; -import org.jvnet.jaxb2_commons.xml.bind.model.MPropertyInfo; - -import com.sun.codemodel.JBlock; -import com.sun.codemodel.JExpr; -import com.sun.codemodel.JExpression; -import com.sun.codemodel.JFieldVar; -import com.sun.codemodel.JMod; -import com.sun.codemodel.JType; -import com.sun.codemodel.JVar; -import com.sun.tools.xjc.model.nav.NClass; -import com.sun.tools.xjc.model.nav.NType; -import com.sun.tools.xjc.outline.Outline; - -public abstract class ConstantPropertyOutline extends AbstractPropertyOutline { - - protected final JExpression value; - - protected final JFieldVar field; - - public ConstantPropertyOutline(Outline outline, MClassOutline classOutline, - MPropertyInfo target, final JExpression value) { - super(outline, classOutline, target); - Validate.notNull(value); - this.value = value; - this.field = generateField(); - } - - protected JExpression createValue() { - return value; - } - - protected JFieldVar generateField() { - // generate the constant - JExpression value = createValue(); - - JFieldVar field = referenceClass.field(JMod.PUBLIC | JMod.STATIC - | JMod.FINAL, type, propertyInfo.getPublicName(), value); - - annotate(field); - - return field; - } - - public MPropertyAccessor createPropertyAccessor(JExpression target) { - return new PropertyAccessor(target); - } - - public class PropertyAccessor extends - AbstractPropertyOutline.PropertyAccessor { - - public PropertyAccessor(JExpression target) { - super(target); - } - - @Override - public boolean isConstant() { - return true; - } - - public void unset(JBlock body) { - } - - public void set(JBlock block, String uniqueName, JExpression value) { - } - - @Override - public boolean isVirtual() { - return false; - } - - public JExpression isSet() { - return JExpr.TRUE; - } - - public void get(JBlock block, JVar variable) { - block.assign(variable, ConstantPropertyOutline.this.referenceClass - .staticRef(ConstantPropertyOutline.this.field)); - } - - } -} +package org.jvnet.jaxb2_commons.xjc.outline.artificial; + +import org.apache.commons.lang3.Validate; +import org.jvnet.jaxb2_commons.xjc.outline.MClassOutline; +import org.jvnet.jaxb2_commons.xjc.outline.MPropertyAccessor; +import org.jvnet.jaxb2_commons.xml.bind.model.MPropertyInfo; + +import com.sun.codemodel.JBlock; +import com.sun.codemodel.JExpr; +import com.sun.codemodel.JExpression; +import com.sun.codemodel.JFieldVar; +import com.sun.codemodel.JMod; +import com.sun.codemodel.JVar; +import com.sun.tools.xjc.model.nav.NClass; +import com.sun.tools.xjc.model.nav.NType; +import com.sun.tools.xjc.outline.Outline; + +public abstract class ConstantPropertyOutline extends AbstractPropertyOutline { + + protected final JExpression value; + + protected final JFieldVar field; + + public ConstantPropertyOutline(Outline outline, MClassOutline classOutline, + MPropertyInfo target, final JExpression value) { + super(outline, classOutline, target); + Validate.notNull(value); + this.value = value; + this.field = generateField(); + } + + protected JExpression createValue() { + return value; + } + + protected JFieldVar generateField() { + // generate the constant + JExpression value = createValue(); + + JFieldVar field = referenceClass.field(JMod.PUBLIC | JMod.STATIC + | JMod.FINAL, type, propertyInfo.getPublicName(), value); + + annotate(field); + + return field; + } + + public MPropertyAccessor createPropertyAccessor(JExpression target) { + return new PropertyAccessor(target); + } + + public class PropertyAccessor extends + AbstractPropertyOutline.PropertyAccessor { + + public PropertyAccessor(JExpression target) { + super(target); + } + + @Override + public boolean isConstant() { + return true; + } + + public void unset(JBlock body) { + } + + public void set(JBlock block, String uniqueName, JExpression value) { + } + + @Override + public boolean isVirtual() { + return false; + } + + public JExpression isSet() { + return JExpr.TRUE; + } + + public void get(JBlock block, JVar variable) { + block.assign(variable, ConstantPropertyOutline.this.referenceClass + .staticRef(ConstantPropertyOutline.this.field)); + } + + } +}