@Test public void testDeserialize() { Variable.VariableType variableType = Variable.VariableType.PROCESS; String test1 = ""; Variable result1 = Variable.deserialize(test1, variableType); Variable expected1 = new Variable(variableType); assertEquals(expected1, result1); String test2 = DIVIDER + DIVIDER; Variable result2 = Variable.deserialize(test2, variableType); Variable expected2 = new Variable("", variableType); assertEquals(expected2, result2); String test3 = NAME + DIVIDER + DIVIDER; Variable result3 = Variable.deserialize(test3, variableType); Variable expected3 = new Variable(NAME, variableType); assertEquals(expected3, result3); String test4 = NAME + DIVIDER + DATA_TYPE + DIVIDER; Variable result4 = Variable.deserialize(test4, variableType, Arrays.asList(DATA_TYPE)); Variable expected4 = new Variable(NAME, variableType, DATA_TYPE, null); assertEquals(expected4, result4); String test5 = NAME + DIVIDER + CUSTOM_DATA_TYPE + DIVIDER; Variable result5 = Variable.deserialize(test5, variableType, null); Variable expected5 = new Variable(NAME, variableType, null, CUSTOM_DATA_TYPE); assertEquals(expected5, result5); String test6 = NAME + DIVIDER + CUSTOM_DATA_TYPE + DIVIDER; Variable result6 = Variable.deserialize(test6, variableType, Arrays.asList(DATA_TYPE)); Variable expected6 = new Variable(NAME, variableType, null, CUSTOM_DATA_TYPE); assertEquals(expected6, result6); String test7 = NAME + DIVIDER + DIVIDER + "[" + TAG_1 + TAG_DIVIDER + TAG_2 + TAG_DIVIDER + TAG_3 + "]"; Variable result7 = Variable.deserialize(test7, variableType, null); Variable expected7 = new Variable(NAME, variableType, null, null, TAGS); assertEquals(expected7, result7); }
public static Variable deserialize(final String s, final VariableType variableType, final List<String> dataTypes) { Variable var = new Variable(variableType); String[] varParts = s.split(DIVIDER, -1); String name = varParts[0]; var.setName(name); String dataType = varParts.length > 1 ? varParts[1] : null; if (dataTypes != null && dataTypes.contains(dataType)) { var.setDataType(dataType); } else { var.setCustomDataType(dataType); } var.tags = new ArrayList<>(); String tags = varParts.length > 2 ? varParts[2] : ""; final String strippedDownTags = tags.replace("[", "").replace("]", ""); String[] elements = strippedDownTags.split(TAG_DIVIDER); if (!strippedDownTags.isEmpty()) { var.tags.addAll(Arrays.asList(elements)); } return var; }
Variable { public static Variable deserialize(final String s, final VariableType variableType, final List<String> dataTypes) { Variable var = new Variable(variableType); String[] varParts = s.split(DIVIDER, -1); String name = varParts[0]; var.setName(name); String dataType = varParts.length > 1 ? varParts[1] : null; if (dataTypes != null && dataTypes.contains(dataType)) { var.setDataType(dataType); } else { var.setCustomDataType(dataType); } var.tags = new ArrayList<>(); String tags = varParts.length > 2 ? varParts[2] : ""; final String strippedDownTags = tags.replace("[", "").replace("]", ""); String[] elements = strippedDownTags.split(TAG_DIVIDER); if (!strippedDownTags.isEmpty()) { var.tags.addAll(Arrays.asList(elements)); } return var; } }
Variable { public static Variable deserialize(final String s, final VariableType variableType, final List<String> dataTypes) { Variable var = new Variable(variableType); String[] varParts = s.split(DIVIDER, -1); String name = varParts[0]; var.setName(name); String dataType = varParts.length > 1 ? varParts[1] : null; if (dataTypes != null && dataTypes.contains(dataType)) { var.setDataType(dataType); } else { var.setCustomDataType(dataType); } var.tags = new ArrayList<>(); String tags = varParts.length > 2 ? varParts[2] : ""; final String strippedDownTags = tags.replace("[", "").replace("]", ""); String[] elements = strippedDownTags.split(TAG_DIVIDER); if (!strippedDownTags.isEmpty()) { var.tags.addAll(Arrays.asList(elements)); } return var; } Variable(VariableType variableType);  Variable(final String name,
                    final VariableType variableType);  Variable(final String name,
                    final VariableType variableType,
                    final String dataType,
                    final String customDataType);  Variable(final String name,
                    final VariableType variableType,
                    final String dataType,
                    final String customDataType,
                    final List<String> tags); }
Variable { public static Variable deserialize(final String s, final VariableType variableType, final List<String> dataTypes) { Variable var = new Variable(variableType); String[] varParts = s.split(DIVIDER, -1); String name = varParts[0]; var.setName(name); String dataType = varParts.length > 1 ? varParts[1] : null; if (dataTypes != null && dataTypes.contains(dataType)) { var.setDataType(dataType); } else { var.setCustomDataType(dataType); } var.tags = new ArrayList<>(); String tags = varParts.length > 2 ? varParts[2] : ""; final String strippedDownTags = tags.replace("[", "").replace("]", ""); String[] elements = strippedDownTags.split(TAG_DIVIDER); if (!strippedDownTags.isEmpty()) { var.tags.addAll(Arrays.asList(elements)); } return var; } Variable(VariableType variableType);  Variable(final String name,
                    final VariableType variableType);  Variable(final String name,
                    final VariableType variableType,
                    final String dataType,
                    final String customDataType);  Variable(final String name,
                    final VariableType variableType,
                    final String dataType,
                    final String customDataType,
                    final List<String> tags); List<String> getTags(); void setTags(List<String> tags); VariableType getVariableType(); void setVariableType(final VariableType variableType); String getName(); void setName(final String name); String getDataType(); void setDataType(final String dataType); String getCustomDataType(); void setCustomDataType(final String customDataType); String toString(); static Variable deserialize(final String s,
                                       final VariableType variableType,
                                       final List<String> dataTypes); static Variable deserialize(final String s,
                                       final VariableType variableType); @Override boolean equals(final Object o); @Override int hashCode(); }
Variable { public static Variable deserialize(final String s, final VariableType variableType, final List<String> dataTypes) { Variable var = new Variable(variableType); String[] varParts = s.split(DIVIDER, -1); String name = varParts[0]; var.setName(name); String dataType = varParts.length > 1 ? varParts[1] : null; if (dataTypes != null && dataTypes.contains(dataType)) { var.setDataType(dataType); } else { var.setCustomDataType(dataType); } var.tags = new ArrayList<>(); String tags = varParts.length > 2 ? varParts[2] : ""; final String strippedDownTags = tags.replace("[", "").replace("]", ""); String[] elements = strippedDownTags.split(TAG_DIVIDER); if (!strippedDownTags.isEmpty()) { var.tags.addAll(Arrays.asList(elements)); } return var; } Variable(VariableType variableType);  Variable(final String name,
                    final VariableType variableType);  Variable(final String name,
                    final VariableType variableType,
                    final String dataType,
                    final String customDataType);  Variable(final String name,
                    final VariableType variableType,
                    final String dataType,
                    final String customDataType,
                    final List<String> tags); List<String> getTags(); void setTags(List<String> tags); VariableType getVariableType(); void setVariableType(final VariableType variableType); String getName(); void setName(final String name); String getDataType(); void setDataType(final String dataType); String getCustomDataType(); void setCustomDataType(final String customDataType); String toString(); static Variable deserialize(final String s,
                                       final VariableType variableType,
                                       final List<String> dataTypes); static Variable deserialize(final String s,
                                       final VariableType variableType); @Override boolean equals(final Object o); @Override int hashCode();  }