use of com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface in project sldeditor by robward-scisys.
the class FunctionManagerTest method testGetFunctionType.
/**
* Test method for
* {@link com.sldeditor.filter.v2.function.FunctionManager#getFunctionType(java.lang.String)}.
*/
@Test
public void testGetFunctionType() {
Class<?> returnType = FunctionManager.getInstance().getFunctionType(null);
assertNull(returnType);
List<FunctionNameFilterInterface> functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
FunctionNameFilterAll allFilter = new FunctionNameFilterAll();
allFilter.accept(null);
functionNameFilterList.add(allFilter);
List<FunctionName> functionNameList = FunctionManager.getInstance().getFunctionNameList(null, null);
for (FunctionName functionName : functionNameList) {
returnType = FunctionManager.getInstance().getFunctionType(functionName.getName());
assertEquals(functionName.getName(), functionName.getReturn().getType(), returnType);
}
}
use of com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface in project sldeditor by robward-scisys.
the class FunctionField method setDataType.
/**
* Sets the field data types.
*
* @param fieldType the new data type
* @param isRasterSymbol the is raster symbol
*/
public void setDataType(Class<?> fieldType, boolean isRasterSymbol) {
functionNameMap.clear();
List<FunctionNameFilterInterface> functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
if (isRasterSymbol) {
functionNameFilterList.add(new FunctionNameFilterRaster());
} else {
functionNameFilterList.add(new FunctionNameFilterAll());
}
List<FunctionName> functionNameList = functionNameMgr.getFunctionNameList(fieldType, functionNameFilterList);
for (FunctionName functionName : functionNameList) {
String functionNameString = functionName.getName();
functionNameMap.put(functionNameString, functionName);
}
populateFunctionComboBox();
}
use of com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface in project sldeditor by robward-scisys.
the class FunctionManager method getFunctionNameList.
/**
* Gets the function name list for the given parameter type A
* expectedType of null returns all functions.
*
* @param expectedType the expected type, restrict functions with this return type
* @param functionNameFilterList the function name filter list
* @return the function name list
*/
@Override
public List<FunctionName> getFunctionNameList(Class<?> expectedType, List<FunctionNameFilterInterface> functionNameFilterList) {
if (expectedType == null) {
return functionNameList;
}
if (functionNameFilterList == null) {
functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
functionNameFilterList.add(new FunctionNameFilterAll());
}
List<FunctionName> list = new ArrayList<FunctionName>();
List<Class<?>> allowedTypes = allowedTypeMap.get(expectedType);
if (allowedTypes != null) {
for (FunctionName functionName : functionNameList) {
Class<?> returnType = functionName.getReturn().getType();
if (allowedTypes.contains(returnType) && matchesFilter(functionName, functionNameFilterList)) {
list.add(functionName);
}
}
}
return list;
}
use of com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface in project sldeditor by robward-scisys.
the class FunctionManagerTest method testGetFunctionNameList2.
/**
* Test method for
* {@link com.sldeditor.filter.v2.function.FunctionManager#getFunctionNameList(java.lang.Class)}.
* Testing FunctionNameFilterRaster
*/
@Test
public void testGetFunctionNameList2() {
Class<?> returnType = FunctionManager.getInstance().getFunctionType(null);
assertNull(returnType);
List<FunctionName> functionNameList = FunctionManager.getInstance().getFunctionNameList(Object.class, null);
FunctionName propertyFunction = null;
FunctionName idFunction = null;
FunctionName areaFunction = null;
FunctionName ceilFunction = null;
for (FunctionName functionName : functionNameList) {
if (functionName.getName().compareTo("property") == 0) {
propertyFunction = functionName;
} else if (functionName.getName().compareTo("id") == 0) {
idFunction = functionName;
} else if (functionName.getName().compareTo("Area") == 0) {
areaFunction = functionName;
} else if (functionName.getName().compareTo("ceil") == 0) {
ceilFunction = functionName;
}
}
assertNotNull(propertyFunction);
assertNotNull(areaFunction);
assertNotNull(ceilFunction);
assertNotNull(idFunction);
List<FunctionNameFilterInterface> functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
FunctionNameFilterRaster rasterFilter = new FunctionNameFilterRaster();
rasterFilter.accept(null);
functionNameFilterList.add(rasterFilter);
List<FunctionName> rasterFunctionNameList = FunctionManager.getInstance().getFunctionNameList(Object.class, functionNameFilterList);
assertFalse(rasterFunctionNameList.contains(propertyFunction));
assertFalse(rasterFunctionNameList.contains(areaFunction));
assertFalse(rasterFunctionNameList.contains(idFunction));
assertTrue(rasterFunctionNameList.contains(ceilFunction));
}
use of com.sldeditor.filter.v2.function.namefilter.FunctionNameFilterInterface in project sldeditor by robward-scisys.
the class FunctionManagerTest method testGetFunctionNameList.
/**
* Test method for
* {@link com.sldeditor.filter.v2.function.FunctionManager#getFunctionNameList(java.lang.Class)}.
*/
@Test
public void testGetFunctionNameList() {
DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
List<FunctionName> functionNameList = functionFactory.getFunctionNames();
// CHECKSTYLE:OFF
Class<?>[] allowedNumberTypes = { Number.class, Double.class, Float.class, Integer.class, Long.class, Object.class };
// CHECKSTYLE:ON
List<Class<?>> allowedNumberTypesList = Arrays.asList(allowedNumberTypes);
int count = 0;
for (FunctionName functionName : functionNameList) {
Class<?> type = functionName.getReturn().getType();
if (allowedNumberTypesList.contains(type)) {
count++;
}
}
List<FunctionNameFilterInterface> functionNameFilterList = new ArrayList<FunctionNameFilterInterface>();
functionNameFilterList.add(new FunctionNameFilterAll());
List<FunctionName> actualList = FunctionManager.getInstance().getFunctionNameList(Number.class, functionNameFilterList);
assertEquals(count, actualList.size());
// Try with null
actualList = FunctionManager.getInstance().getFunctionNameList(null, null);
assertEquals(functionNameList.size(), actualList.size());
// Try with non-matching class
actualList = FunctionManager.getInstance().getFunctionNameList(FunctionManagerTest.class, functionNameFilterList);
assertTrue(actualList.isEmpty());
}
Aggregations