test_class.file: web-framework/src/test/java/org/unidal/web/jsp/function/MappingFunctionTest.java
test_class.identifier: MappingFunctionTest
test_case.body: @Test
     public void test() {
        String codes = "1|2|3";
        String values = "one|two|three";
        String defaultValue = "not found";
  
        Assert.assertEquals("one", MappingFunction.translate("1", codes, values, defaultValue));
        Assert.assertEquals("two", MappingFunction.translate("2", codes, values, defaultValue));
        Assert.assertEquals("three", MappingFunction.translate("3", codes, values, defaultValue));
        Assert.assertEquals(defaultValue, MappingFunction.translate("4", codes, values, defaultValue));
  
        Assert.assertEquals(defaultValue, MappingFunction.translate("1", codes, null, defaultValue));
        Assert.assertEquals(defaultValue, MappingFunction.translate("1", null, values, defaultValue));
        Assert.assertEquals(defaultValue, MappingFunction.translate("1", "", "", defaultValue));
        
        Assert.assertEquals("2", MappingFunction.translate("TWO", "ONE|TWO|THREE", "1|2", defaultValue));
        Assert.assertEquals(defaultValue, MappingFunction.translate("THREE", "ONE|TWO|THREE", "1|2", defaultValue));
     }
test_case.class_method_signature: MappingFunctionTest.test()
test_case.full_signature: @Test public void test()
test_case.identifier: test
test_case.invocations: assertEquals translate assertEquals translate assertEquals translate assertEquals translate assertEquals translate assertEquals translate assertEquals translate assertEquals translate assertEquals translate
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void test()
focal_class.file: web-framework/src/main/java/org/unidal/web/jsp/function/MappingFunction.java
focal_class.identifier: MappingFunction
focal_class.class_method_signature: MappingFunction.translate(String code, String codes, String values, String defaultValue)
focal_class.full_signature: @FunctionMeta(description = "Translate code based on a mapping table", example = "${w:translate('2', '1|2|3', 'one|two|three', 'not found')}") public static String translate(String code, String codes, String values, String defaultValue)
focal_class.identifier: translate
focal_class.modifiers: @FunctionMeta(description = "Translate code based on a mapping table", example = "${w:translate('2', '1|2|3', 'one|two|three', 'not found')}") public static
focal_class.parameters: (String code, String codes, String values, String defaultValue)
focal_class.return: String
focal_class.signature: String translate(String code, String codes, String values, String defaultValue)
focal_method.body: @FunctionMeta(description = "Translate code based on a mapping table", example = "${w:translate('2', '1|2|3', 'one|two|three', 'not found')}")
     public static String translate(String code, String codes, String values, String defaultValue) {
        List<String> codeList = Splitters.by('|').trim().split(codes);
        List<String> valueList = Splitters.by('|').trim().split(values);
  
        if (codeList != null && valueList != null) {
           int index = 0;
  
           for (String codeItem : codeList) {
              if (codeItem.equals(code)) {
                 if (index < valueList.size()) {
                    return valueList.get(index);
                 } else {
                    break;
                 }
              }
  
              index++;
           }
        }
  
        return defaultValue;
     }
focal_method.class_method_signature: MappingFunction.translate(String code, String codes, String values, String defaultValue)
focal_method.full_signature: @FunctionMeta(description = "Translate code based on a mapping table", example = "${w:translate('2', '1|2|3', 'one|two|three', 'not found')}") public static String translate(String code, String codes, String values, String defaultValue)
focal_method.identifier: translate
focal_method.invocations: split trim by split trim by equals size get
focal_method.modifiers: @FunctionMeta(description = "Translate code based on a mapping table", example = "${w:translate('2', '1|2|3', 'one|two|three', 'not found')}") public static
focal_method.parameters: (String code, String codes, String values, String defaultValue)
focal_method.return: String
focal_method.signature: String translate(String code, String codes, String values, String defaultValue)