All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.wesleyhome.dao.processor.method.CustomQueryMethodGenerator Maven / Gradle / Ivy

/*
 * @(#)CustomQueryMethodGenerator.java
 * 
 * (C) Copyright 2014 by Travelers
 * All Rights Reserved.
 * 
 * This software is the confidential and proprietary information
 * of the Travelers Corporation. ("Confidential Information").
 * Redistribution of the source code or binary form is not permitted
 * without prior authorization from Travelers.
 */
package com.wesleyhome.dao.processor.method;

import java.util.List;
import javax.lang.model.element.Element;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JFieldVar;
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JMod;
import com.sun.codemodel.JType;
import com.wesleyhome.dao.processor.EntityInformationMap;
import com.wesleyhome.dao.processor.model.CustomQueryInfo;
import com.wesleyhome.dao.processor.model.EntityInfo;
import com.wesleyhome.dao.processor.model.MappingType;
import com.wesleyhome.dao.processor.model.ParamInfo;

/**
 * The CustomQueryMethodGenerator class is a
 * 
 * @author
 * @since
 */
public class CustomQueryMethodGenerator implements MethodGenerator {

	@Override
	public void createMethods(final JCodeModel model, final JClass entityJClass, final JDefinedClass _class, final Element fieldElement,
		final JFieldVar entityManagerField, final boolean generate, final EntityInfo entityInfo, final EntityInformationMap entityInfoMap, MappingType mappingType) {
		if (_class.isInterface()) {
			for (CustomQueryInfo customQueryInfo : entityInfo.customQueryInfoList) {
				createCustomQueryMethod(customQueryInfo, model, _class);
			}
		}
	}

	/* (non-Javadoc)
	 * @see com.travelers.smart.dao.generator.processor.method.QueryMethodGenerator#createQueryMethods(com.sun.codemodel.JCodeModel, com.sun.codemodel.JClass, com.sun.codemodel.JDefinedClass, javax.lang.model.element.Element, boolean, com.sun.codemodel.JFieldVar)
	 */
	private void createCustomQueryMethod(final CustomQueryInfo customQueryInfo, final JCodeModel model, final JDefinedClass generatedClass) {
		String methodName = customQueryInfo.methodName;
		List paramInfoList = customQueryInfo.paramInfoList;
		JType returnType = CodeGenerationHelper.getReturnType(model, customQueryInfo.returnInfo);
		JMethod method = generatedClass.method(JMod.NONE, returnType, methodName);
		CodeGenerationHelper.applyParameters(model, paramInfoList, method);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy