Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.sporniket.libre.javabeans.generator.core;
  
  
Implementation for property having type="enum:...".

© Copyright 2012-2013 David Sporn


This file is part of The Sporniket Javabeans Library – core.

The Sporniket Javabeans Library – core is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Sporniket Javabeans Library – core is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with The Sporniket Javabeans Library – core. If not, see http://www.gnu.org/licenses/. 2


Author(s):
David SPORN
Version:
13.01.01
Since:
13.01.01
 
 public class PropertyGeneratorTypeEnum implements PropertyGenerator
 {
Name of the template file for generating the enum.
 
 	private static String TEMPLATE_NAME__ENUM = "template_property_enum.txt";
 
 	
 
 	{
 	}
 
 	public void outputPropertyJavaCode(PrintWriter outPropertyType propertyTypeProperty propertyBean beanPackage pack,
 			BeanSet set)
 	{
 		// prepare template parameters
 		String _enumJavaName = null;
 		PropertyTypeEnum _propertyType = (PropertyTypeEnumpropertyType;
 		if (_propertyType.isAnonymous())
 		{
 			Name _name = Name.createFromJavabeanPropertyName(property.getName());
 			_enumJavaName = _name.getCapitalized();
 		}
 		else
 		{
 			_enumJavaName = _propertyType.getEnumJavaName();
 		}
 
 		// generate enum part
 		Object[] _params =
 		{
 				_enumJavaName_propertyType.getEnumValues(), property.getName()
 		};
 		out.println(.format(_params));
 
 		// substitute type to use normal generator.
 		String _oldType = property.getType();
 		String _fakeType = .. + . + _enumJavaName;
 		property.setType(_fakeType);
 		outputPropertyJavaCode__outputRegularCode(out_enumJavaNamepropertybeanpackset);
 		property.setType(_oldType);
 
 	}

Parameters:
out output.
enumJavaName Java name of the enum.
property property to generate.
bean bean definition for reference.
pack package definition for reference.
set set for reference.
	protected void outputPropertyJavaCode__outputRegularCode(PrintWriter outString enumJavaNameProperty propertyBean bean,
			Package packBeanSet set)
	{
		PropertyType _fakePropertyType = PropertyType.Utils.instanciate(property.getType());
		.outputPropertyJavaCode(out_fakePropertyTypepropertybeanpackset);
	}
	{
	}
	{
	}
New to GrepCode? Check out our FAQ X