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

org.tinygroup.tinydb.config.TableConfigurationContainer Maven / Gradle / Ivy

There is a newer version: 2.2.3
Show newest version
/**
 *  Copyright (c) 1997-2013, www.tinygroup.org ([email protected]).
 *
 *  Licensed under the GPL, Version 3.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.gnu.org/licenses/gpl.html
 *
 *  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.tinygroup.tinydb.config;

import org.tinygroup.commons.tools.CollectionUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 存储表配置信息的容器
 * @author renhui
 *
 */
public class TableConfigurationContainer {
    /**
     * 存储所有表配置信息的列表
     */
	private List tableConfigurations=new ArrayList();
	/**
	 * 保存模式下所有表信息
	 */
	private Map> schemaTables=new HashMap>();
	/**
	 * 保存所有模式配置
	 */
	private List schemaConfigs=new ArrayList();
	
	public void addTableConfiguration(TableConfiguration configuration){
		if(!tableConfigurations.contains(configuration)){
			tableConfigurations.add(configuration);
		}
		List tables=schemaTables.get(configuration.getSchema());
		if(tables==null){
			tables=new ArrayList();
			schemaTables.put(configuration.getSchema(), tables);
		}
		tables.add(configuration);
	}
	
	public TableConfiguration getTableConfiguration(String schema,String tableName){
	     List tableConfigs=schemaTables.get(schema);
	     if(!CollectionUtil.isEmpty(tableConfigs)){
	    	 for (TableConfiguration tableConfig : tableConfigs) {
				if(tableConfig.getName().equalsIgnoreCase(tableName)){
					return tableConfig;
				}
			 }
	     }
		return null;
	}
	
	public List getSchemaConfigs(){
		return schemaConfigs;
	}
	
	public boolean isExistTable(String schema,String tableName){
		TableConfiguration configuration=getTableConfiguration(schema, tableName);
        return configuration!=null;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy