com.bstek.urule.model.library.ResourceLibrary Maven / Gradle / Ivy
/*******************************************************************************
* Copyright 2017 Bstek
*
* 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 com.bstek.urule.model.library;
import java.util.ArrayList;
import java.util.List;
import com.bstek.urule.RuleException;
import com.bstek.urule.model.library.action.ActionLibrary;
import com.bstek.urule.model.library.constant.ConstantCategory;
import com.bstek.urule.model.library.constant.ConstantLibrary;
import com.bstek.urule.model.library.variable.VariableCategory;
import com.bstek.urule.model.library.variable.VariableLibrary;
/**
* @author Jacky.gao
* @since 2015年1月6日
*/
public class ResourceLibrary {
private List constantCategories;
private List actionLibraries;
private List variableCategories;
public ResourceLibrary() {
}
public ResourceLibrary(List variableLibraries,List actionLibraries,List constantLibraries){
this.variableCategories=new ArrayList();
this.actionLibraries=new ArrayList();
this.constantCategories=new ArrayList();
for(VariableLibrary vl:variableLibraries){
for(VariableCategory category:vl.getVariableCategories()){
variableCategories.add(category);
}
}
this.actionLibraries.addAll(actionLibraries);
for(ConstantLibrary cl:constantLibraries){
for(ConstantCategory cc:cl.getCategories()){
this.constantCategories.add(cc);
}
}
}
public VariableCategory getVariableCategory(String categoryName) {
for(VariableCategory category:variableCategories){
if(category.getName().equals(categoryName)){
return category;
}
}
throw new RuleException("Variable category ["+categoryName+"] not exist");
}
public List getActionLibraries() {
return actionLibraries;
}
public List getVariableCategories() {
return variableCategories;
}
public List getConstantCategories() {
return constantCategories;
}
}