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

com.extjs.gxt.ui.client.data.BeanModelFactory Maven / Gradle / Ivy

There is a newer version: 2.3.1-gwt22
Show newest version
/*
 * Ext GWT 2.2.0 - Ext for GWT
 * Copyright(c) 2007-2010, Ext JS, LLC.
 * [email protected]
 * 
 * http://extjs.com/license
 */
package com.extjs.gxt.ui.client.data;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * BeanModelFactores are responsible for creating new BeanModel
 * instances from Java POJOs. BeanModels are GXT models and can be
 * used with the GXT data API. BeanModelFactories are obtained from @link
 * {@link BeanModelLookup}.
 * 
 * @see BeanModelLookup
 */
public abstract class BeanModelFactory {

  protected abstract BeanModel newInstance();

  /**
   * Creates a new bean model instance.
   * 
   * @param bean creates a new model
   * @return the new model
   */
  public BeanModel createModel(Object bean) {
    BeanModel model = newInstance();
    model.setBean(bean);
    return model;
  }

  /**
   * Creates a list new bean model instances.
   * 
   * @param beans the list of beans
   * @return the list of models
   */
  public List createModel(Collection beans) {
    List models = new ArrayList();
    for (Object obj : beans) {
      models.add(createModel(obj));
    }
    return models;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy