Java Code Examples for com.sun.codemodel.JExpr#refthis()

The following examples show how to use com.sun.codemodel.JExpr#refthis() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXBElementValueField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JAXBElementValueField(ClassOutlineImpl context, CPropertyInfo prop,
		CReferencePropertyInfo core, CPropertyInfo nameProperty,
		CNonElement type) {
	super(context, prop, core);
	this.nameProperty = nameProperty;
	this.nameField = JExpr.refthis(nameProperty.getName(false));
	this.type = type;
}
 
Example 2
Source File: JAXBElementNameField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public JAXBElementNameField(final ClassOutlineImpl context,
		final CPropertyInfo prop, final CReferencePropertyInfo core,
		final CPropertyInfo valueProperty, final CNonElement type) {
	super(context, prop, core);
	this.valueProperty = valueProperty;
	this.valueField = JExpr.refthis(valueProperty.getName(false));
	this.elementType = type;
}
 
Example 3
Source File: ModifierGenerator.java    From jaxb2-rich-contract-plugin with MIT License 5 votes vote down vote up
private ModifierGenerator(final PluginContext pluginContext, final DefinedTypeOutline classOutline, final String modifierClassName, final String modifierInterfaceName, final Collection<TypeOutline> interfaces, final String modifierMethodName, final boolean implement) throws JClassAlreadyExistsException {
	this.classOutline = classOutline;
	final JDefinedClass definedClass = classOutline.getImplClass();
	this.implement = implement;
	this.modifierClass = definedClass._class(JMod.PUBLIC, modifierClassName, classOutline.getImplClass().getClassType());
	if(interfaces != null) {
		for (final TypeOutline interfaceOutline : interfaces) {
			this.modifierClass._implements( pluginContext.ref(interfaceOutline.getImplClass(), modifierInterfaceName, true));
		}
	}
	final JFieldRef cachedModifierField;
	if(!"java.lang.Object".equals(definedClass._extends().fullName())) {
		this.modifierClass._extends(pluginContext.ref(definedClass._extends(), modifierClassName, false));
		cachedModifierField = JExpr.refthis(ModifierGenerator.MODIFIER_CACHE_FIELD_NAME);
	} else {
		if(implement) {
			cachedModifierField = JExpr._this().ref(definedClass.field(JMod.PROTECTED | JMod.TRANSIENT, this.modifierClass, ModifierGenerator.MODIFIER_CACHE_FIELD_NAME));
		} else {
			cachedModifierField = null;
		}
	}

	final JDefinedClass typeDefinition = classOutline.isInterface() && ((DefinedInterfaceOutline)classOutline).getSupportInterface() != null ? ((DefinedInterfaceOutline)classOutline).getSupportInterface() : definedClass;
	final JMethod modifierMethod = typeDefinition.method(JMod.PUBLIC, this.modifierClass, modifierMethodName);
	if(this.implement) {
		final JConditional ifCacheNull = modifierMethod.body()._if(JExpr._null().eq(cachedModifierField));
		ifCacheNull._then().assign(cachedModifierField, JExpr._new(this.modifierClass));
		modifierMethod.body()._return(JExpr.cast(this.modifierClass, cachedModifierField));
	}

}
 
Example 4
Source File: SingleElementField.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public SingleElementField(ClassOutlineImpl outline,
		CPropertyInfo property, CPropertyInfo nameProperty,
		CPropertyInfo valueProperty) {
	super(outline, property);

	this.nameProperty = nameProperty;

	this.nameField = JExpr.refthis(nameProperty.getName(false));

	this.valueProperty = valueProperty;

	this.valueField = JExpr.refthis(valueProperty.getName(false));

	final JFieldVar field = outline.implClass.field(JMod.PROTECTED,

	exposedType, property.getName(false));

	annotate(field);

	this.field = JExpr._this().ref(field);

	this.setter = createSetter();
	this.getter = createGetter();

}