public static String buildSpecializedPagedResultClass(TypeSpec.Builder classBuilder, SQLiteModelMethod method) {
		// TypeName entityTypeName =
		// TypeUtility.typeName(method.getParent().getEntityClassName());
		TypeName entityTypeName = TypeUtility.typeName(method.getEntity().getName());

		String pagedResultName = "PaginatedResult" + (pagedResultCounter++);

		TypeSpec.Builder typeBuilder = TypeSpec.classBuilder(pagedResultName).addModifiers(Modifier.PUBLIC)
				.superclass(TypeUtility.parameterizedTypeName(TypeUtility.className(PagedResultImpl.class), entityTypeName));

		// add fields and define constructor
		MethodSpec.Builder setupBuilder = MethodSpec.constructorBuilder();

		MethodSpec.Builder executeBuilder = MethodSpec.methodBuilder("execute").addModifiers(Modifier.PUBLIC)
				.returns(TypeUtility.parameterizedTypeName(TypeUtility.className(List.class), entityTypeName));
		executeBuilder.addComment("Executor builder - BEGIN");

		ClassName daoFactoryClassName = BindDaoFactoryBuilder.generateDaoFactoryClassName(method.getParent().getParent());
		MethodSpec.Builder executeWithDaoFactortBuilder = MethodSpec.methodBuilder("execute").addParameter(daoFactoryClassName, "daoFactory").addModifiers(Modifier.PUBLIC)
				.returns(TypeUtility.parameterizedTypeName(TypeUtility.className(List.class), entityTypeName));
		executeWithDaoFactortBuilder.addCode("return daoFactory.get$L().$L(", method.getParentName(), method.getName());

		if (!method.isPagedLiveData()) {
			executeBuilder.addCode("list=$T.this.$L(", TypeUtility.typeName(method.getParent().getElement(), BindDaoBuilder.SUFFIX), method.getName());
		}

		// we have always a first parameter
		String separator = "";
		ParameterSpec parameterSpec;
		for (Pair<String, TypeName> item : method.getParameters()) {
			if (method.hasDynamicPageSizeConditions() && method.dynamicPageSizeName.equals(item.value0)) {
				setupBuilder.addStatement("this.pageSize=$L", item.value0);
			} else {
				// field
				typeBuilder.addField(item.value1, item.value0);
				setupBuilder.addStatement("this.$L=$L", item.value0, item.value0);
			}

			// construtor
			parameterSpec = ParameterSpec.builder(item.value1, item.value0).build();
			setupBuilder.addParameter(parameterSpec);

			// execute
			if (method.dynamicPageSizeName != null && method.dynamicPageSizeName.equals(item.value0)) {
				if (!method.isPagedLiveData()) {
					executeBuilder.addCode(separator + "this.pageSize");
				}
				executeWithDaoFactortBuilder.addCode(separator + "this.pageSize");
			} else {
				if (!method.isPagedLiveData()) {
					executeBuilder.addCode(separator + item.value0);
				}
				executeWithDaoFactortBuilder.addCode(separator + item.value0);
			}
			separator = ", ";
		}

		if (method.isPagedLiveData()) {
			// if method is not paged live data, add complete execute method
			executeBuilder.addComment("paged result is used in live data, so this method must be empty");
			executeBuilder.addStatement("return null");
		} else {
			executeBuilder.addCode(separator + "this);\n");
			executeBuilder.addStatement("return list");
		}
		executeBuilder.addComment("Executor builder - END");

		typeBuilder.addMethod(executeBuilder.build());

		if (!method.hasDynamicPageSizeConditions()) {
			ModelAnnotation annotation = method.getAnnotation(BindSqlSelect.class);
			int pageSize = annotation.getAttributeAsInt(AnnotationAttributeType.PAGE_SIZE);

			// in case pageSize is not specified (only for liveData)
			if (pageSize == 0) {
				pageSize = 20;
			}

			setupBuilder.addStatement("this.pageSize=$L", pageSize);
		}

		typeBuilder.addMethod(setupBuilder.build());

		executeWithDaoFactortBuilder.addCode(separator + "this);\n");

		typeBuilder.addMethod(executeWithDaoFactortBuilder.build());

		classBuilder.addType(typeBuilder.build());

		return pagedResultName;
	}
public static String buildSpecializedPagedResultClass ( TypeSpec . Builder classBuilder , SQLiteModelMethod method ) { TypeName entityTypeName = TypeUtility . typeName ( method . getEntity ( ) . getName ( ) ) ; String pagedResultName = "PaginatedResult" + ( pagedResultCounter ++ ) ; TypeSpec . Builder typeBuilder = TypeSpec . classBuilder ( pagedResultName ) . addModifiers ( Modifier . PUBLIC ) . superclass ( TypeUtility . parameterizedTypeName ( TypeUtility . className ( PagedResultImpl . class ) , entityTypeName ) ) ; MethodSpec . Builder setupBuilder = MethodSpec . constructorBuilder ( ) ; MethodSpec . Builder executeBuilder = MethodSpec . methodBuilder ( "execute" ) . addModifiers ( Modifier . PUBLIC ) . returns ( TypeUtility . parameterizedTypeName ( TypeUtility . className ( List . class ) , entityTypeName ) ) ; executeBuilder . addComment ( "Executor builder - BEGIN" ) ; ClassName daoFactoryClassName = BindDaoFactoryBuilder . generateDaoFactoryClassName ( method . getParent ( ) . getParent ( ) ) ; MethodSpec . Builder executeWithDaoFactortBuilder = MethodSpec . methodBuilder ( "execute" ) . addParameter ( daoFactoryClassName , "daoFactory" ) . addModifiers ( Modifier . PUBLIC ) . returns ( TypeUtility . parameterizedTypeName ( TypeUtility . className ( List . class ) , entityTypeName ) ) ; executeWithDaoFactortBuilder . addCode ( "return daoFactory.get$L().$L(" , method . getParentName ( ) , method . getName ( ) ) ; if ( ! method . isPagedLiveData ( ) ) { executeBuilder . addCode ( "list=$T.this.$L(" , TypeUtility . typeName ( method . getParent ( ) . getElement ( ) , BindDaoBuilder . SUFFIX ) , method . getName ( ) ) ; } String separator = "" ; ParameterSpec parameterSpec ; for ( Pair < String , TypeName > item : method . getParameters ( ) ) { if ( method . hasDynamicPageSizeConditions ( ) && method . dynamicPageSizeName . equals ( item . value0 ) ) { setupBuilder . addStatement ( "this.pageSize=$L" , item . value0 ) ; } else { typeBuilder . addField ( item . value1 , item . value0 ) ; setupBuilder . addStatement ( "this.$L=$L" , item . value0 , item . value0 ) ; } parameterSpec = ParameterSpec . builder ( item . value1 , item . value0 ) . build ( ) ; setupBuilder . addParameter ( parameterSpec ) ; if ( method . dynamicPageSizeName != null && method . dynamicPageSizeName . equals ( item . value0 ) ) { if ( ! method . isPagedLiveData ( ) ) { executeBuilder . addCode ( separator + "this.pageSize" ) ; } executeWithDaoFactortBuilder . addCode ( separator + "this.pageSize" ) ; } else { if ( ! method . isPagedLiveData ( ) ) { executeBuilder . addCode ( separator + item . value0 ) ; } executeWithDaoFactortBuilder . addCode ( separator + item . value0 ) ; } separator = ", " ; } if ( method . isPagedLiveData ( ) ) { executeBuilder . addComment ( "paged result is used in live data, so this method must be empty" ) ; executeBuilder . addStatement ( "return null" ) ; } else { executeBuilder . addCode ( separator + "this);\n" ) ; executeBuilder . addStatement ( "return list" ) ; } executeBuilder . addComment ( "Executor builder - END" ) ; typeBuilder . addMethod ( executeBuilder . build ( ) ) ; if ( ! method . hasDynamicPageSizeConditions ( ) ) { ModelAnnotation annotation = method . getAnnotation ( BindSqlSelect . class ) ; int pageSize = annotation . getAttributeAsInt ( AnnotationAttributeType . PAGE_SIZE ) ; if ( pageSize == 0 ) { pageSize = 20 ; } setupBuilder . addStatement ( "this.pageSize=$L" , pageSize ) ; } typeBuilder . addMethod ( setupBuilder . build ( ) ) ; executeWithDaoFactortBuilder . addCode ( separator + "this);\n" ) ; typeBuilder . addMethod ( executeWithDaoFactortBuilder . build ( ) ) ; classBuilder . addType ( typeBuilder . build ( ) ) ; return pagedResultName ; }
Build paginated result class handler.

@param classBuilder
the class builder
@param method
the method
@return name of generated class