Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014-2015 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  * either express or implied. See the License for the specific language
  * governing permissions and limitations under the License.
  */
 package org.dbflute.cbean.result;
 
 import java.util.List;
 
The builder of result bean.

Parameters:
<ENTITY> The type of entity.
Author(s):
jflute
 
 public class ResultBeanBuilder<ENTITY> {
 
     // ===================================================================================
     //                                                                           Attribute
     //                                                                           =========
     protected final String _tableDbName// null allowed
 
     // ===================================================================================
     //                                                                         Constructor
     //                                                                         ===========
     public ResultBeanBuilder(String tableDbName) {
          = tableDbName;
     }
 
     // ===================================================================================
     //                                                                                List
     //                                                                                ====
     
Build the result bean of list. {for CB}

Parameters:
cb The condition-bean. (NotNull)
selectedList The actually selected list of the entity. (NotNull)
Returns:
The result bean of list. (NullAllowed: if null, treated as empty)
 
     public ListResultBean<ENTITY> buildListOfCB(ConditionBean cbList<ENTITY> selectedList) {
         ListResultBean<ENTITY> rb = newListResultBean();
         rb.setTableDbName();
         rb.setAllRecordCount(selectedList.size());
         rb.setOrderByClause(cb.getOrderByComponent());
         rb.setSelectedList(selectedList);
         return rb;
     }

    
Build the result bean of list with all record count, order-by clause. {for Nested}

Parameters:
inherited The result bean to inherit option info, e.g. all record count. (NotNull)
selectedList The actually selected list of the entity. (NotNull)
Returns:
The result bean of list. (NullAllowed: if null, treated as empty)
 
     public ListResultBean<ENTITY> buildListInherited(ListResultBean<?> inheritedList<ENTITY> selectedList) {
         ListResultBean<ENTITY> rb = newListResultBean();
         rb.setTableDbName();
         rb.setAllRecordCount(inherited.getAllRecordCount());
         rb.setOrderByClause(inherited.getOrderByClause());
         rb.setSelectedList(selectedList);
         return rb;
     }

    
Build the result bean of list without order-by clause. {for Simple}

Parameters:
selectedList The actually selected list of the entity. (NotNull)
Returns:
The result bean of list. (NullAllowed: if null, treated as empty)
 
     public ListResultBean<ENTITY> buildListSimply(List<ENTITY> selectedList) {
         ListResultBean<ENTITY> rb = newListResultBean();
         rb.setTableDbName();
         rb.setAllRecordCount(selectedList.size());
         rb.setSelectedList(selectedList);
         return rb;
     }

    
Build the result bean of list as empty. {for Paging}

Parameters:
pb The bean of paging. (NotNull)
Returns:
The result bean of list as empty. (NotNull)
 
     public ListResultBean<ENTITY> buildEmptyListOfPaging(PagingBean pb) {
         ListResultBean<ENTITY> rb = newListResultBean();
         rb.setTableDbName();
         rb.setOrderByClause(pb.getOrderByComponent());
         return rb;
     }

    
Build the result bean of list as empty. {for General}

Returns:
The result bean of list as empty. (NotNull)
    public ListResultBean<ENTITY> buildEmptyListSimply() {
        ListResultBean<ENTITY> rb = newListResultBean();
        rb.setTableDbName();
        return rb;
    }
    protected ListResultBean<ENTITY> newListResultBean() {
        return new ListResultBean<ENTITY>();
    }
    // ===================================================================================
    //                                                                              Paging
    //                                                                              ======
    
Build the result bean of paging. {for Paging}

Parameters:
pb The bean of paging. (NotNull)
allRecordCount All record count.
selectedList The list of selected entity. (NotNull)
Returns:
The result bean of paging. (NotNull)
    public PagingResultBean<ENTITY> buildPagingOfPaging(PagingBean pbint allRecordCountList<ENTITY> selectedList) {
        PagingResultBean<ENTITY> rb = newPagingResultBean();
        rb.setTableDbName();
        rb.setAllRecordCount(allRecordCount);
        rb.setOrderByClause(pb.getOrderByComponent());
        rb.setSelectedList(selectedList);
        rb.setPageSize(pb.getFetchSize());
        return rb;
    }

    
Build the result bean of paging. {for Simple}

Parameters:
pageSize The record count of one page.
pageNumber The number of current page.
allRecordCount All record count.
selectedList The list of selected entity. (NotNull)
Returns:
The result bean of paging. (NotNull)
    public PagingResultBean<ENTITY> buildPagingSimply(int pageSizeint pageNumberint allRecordCountList<ENTITY> selectedList) {
        PagingResultBean<ENTITY> rb = newPagingResultBean();
        rb.setTableDbName();
        rb.setAllRecordCount(allRecordCount);
        rb.setSelectedList(selectedList);
        rb.setPageSize(pageSize);
        rb.setCurrentPageNumber(pageNumber);
        return rb;
    }

    
Build the result bean of paging as empty. {for Empty}

Parameters:
pageSize The record count of one page.
Returns:
The result bean of list as empty. (NotNull)
    public ListResultBean<ENTITY> buildEmptyPagingSimply(int pageSize) {
        PagingResultBean<ENTITY> rb = newPagingResultBean();
        rb.setTableDbName();
        rb.setPageSize(pageSize);
        rb.setCurrentPageNumber(1);
        return rb;
    }
    protected PagingResultBean<ENTITY> newPagingResultBean() {
        return new PagingResultBean<ENTITY>();
    }
New to GrepCode? Check out our FAQ X