@Test public void listFromConstantOk() { EvaluationFunction evFunction = engine.buildEvaluationFunction(FUNCTION_NAME) .withValueParam(PARAM_FILE_LIST, ValueType.FILE_LIST, new ValueEvaluation(LIST)); ValueEvaluation evaluation = evFunction.evaluate(); assertEquals(LIST.get(0), evaluation.getData()); }
@Override public ValueEvaluation evaluate() { try { checkContractCompliance(); boolean returnNullIfEmpty = false; List<ValueParam> returnNullIfEmptyParams = valueParams.getParams(PARAM_RETURN_NULL_IF_EMPTY); if (returnNullIfEmptyParams.size() == 1) { ValueEvaluation paramNsAware = returnNullIfEmptyParams.get(0).getEvaluation(); returnNullIfEmpty = (boolean) paramNsAware.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILE_LIST).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return errorResultParamNull(PARAM_FILE_LIST, paramFiles); } else if (files.isEmpty()) { if (returnNullIfEmpty) { return okResult(null); } else { return errorResult("seznam souborů je prázdný"); } } else { return okResult(files.get(0)); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } }
EfGetFirstFileFromFileList extends EvaluationFunction { @Override public ValueEvaluation evaluate() { try { checkContractCompliance(); boolean returnNullIfEmpty = false; List<ValueParam> returnNullIfEmptyParams = valueParams.getParams(PARAM_RETURN_NULL_IF_EMPTY); if (returnNullIfEmptyParams.size() == 1) { ValueEvaluation paramNsAware = returnNullIfEmptyParams.get(0).getEvaluation(); returnNullIfEmpty = (boolean) paramNsAware.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILE_LIST).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return errorResultParamNull(PARAM_FILE_LIST, paramFiles); } else if (files.isEmpty()) { if (returnNullIfEmpty) { return okResult(null); } else { return errorResult("seznam souborů je prázdný"); } } else { return okResult(files.get(0)); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } } }
EfGetFirstFileFromFileList extends EvaluationFunction { @Override public ValueEvaluation evaluate() { try { checkContractCompliance(); boolean returnNullIfEmpty = false; List<ValueParam> returnNullIfEmptyParams = valueParams.getParams(PARAM_RETURN_NULL_IF_EMPTY); if (returnNullIfEmptyParams.size() == 1) { ValueEvaluation paramNsAware = returnNullIfEmptyParams.get(0).getEvaluation(); returnNullIfEmpty = (boolean) paramNsAware.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILE_LIST).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return errorResultParamNull(PARAM_FILE_LIST, paramFiles); } else if (files.isEmpty()) { if (returnNullIfEmpty) { return okResult(null); } else { return errorResult("seznam souborů je prázdný"); } } else { return okResult(files.get(0)); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } } EfGetFirstFileFromFileList(String name, Engine engine); }
EfGetFirstFileFromFileList extends EvaluationFunction { @Override public ValueEvaluation evaluate() { try { checkContractCompliance(); boolean returnNullIfEmpty = false; List<ValueParam> returnNullIfEmptyParams = valueParams.getParams(PARAM_RETURN_NULL_IF_EMPTY); if (returnNullIfEmptyParams.size() == 1) { ValueEvaluation paramNsAware = returnNullIfEmptyParams.get(0).getEvaluation(); returnNullIfEmpty = (boolean) paramNsAware.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILE_LIST).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return errorResultParamNull(PARAM_FILE_LIST, paramFiles); } else if (files.isEmpty()) { if (returnNullIfEmpty) { return okResult(null); } else { return errorResult("seznam souborů je prázdný"); } } else { return okResult(files.get(0)); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } } EfGetFirstFileFromFileList(String name, Engine engine); @Override ValueEvaluation evaluate(); }
EfGetFirstFileFromFileList extends EvaluationFunction { @Override public ValueEvaluation evaluate() { try { checkContractCompliance(); boolean returnNullIfEmpty = false; List<ValueParam> returnNullIfEmptyParams = valueParams.getParams(PARAM_RETURN_NULL_IF_EMPTY); if (returnNullIfEmptyParams.size() == 1) { ValueEvaluation paramNsAware = returnNullIfEmptyParams.get(0).getEvaluation(); returnNullIfEmpty = (boolean) paramNsAware.getData(); } ValueEvaluation paramFiles = valueParams.getParams(PARAM_FILE_LIST).get(0).getEvaluation(); List<File> files = (List<File>) paramFiles.getData(); if (files == null) { return errorResultParamNull(PARAM_FILE_LIST, paramFiles); } else if (files.isEmpty()) { if (returnNullIfEmpty) { return okResult(null); } else { return errorResult("seznam souborů je prázdný"); } } else { return okResult(files.get(0)); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } } EfGetFirstFileFromFileList(String name, Engine engine); @Override ValueEvaluation evaluate();  }