@Test public void testParsing() { final RangeValue actual = FEELRangeParser.parse(input); assertThat(actual).isEqualTo(expected); }
public static RangeValue parse(final String input) { if (Objects.isNull(input)) { return new RangeValue(); } final String trimmedInput = input.trim(); if (!hasLeadingAndEndingParenthesis(trimmedInput)) { return new RangeValue(); } final boolean includeStartValue = trimmedInput.startsWith(INCLUDE_START); final boolean includeEndValue = trimmedInput.endsWith(INCLUDE_END); boolean inQuotes = false; String startValue = ""; String endValue = ""; for (int current = 0; current < trimmedInput.length(); current++) { if (trimmedInput.charAt(current) == '\"') { inQuotes = !inQuotes; } if (isSeparator(current, inQuotes, trimmedInput)) { startValue = trimmedInput.substring(1, current).trim(); endValue = trimmedInput.substring(current + SEPARATOR_LENGTH, trimmedInput.length() - 1).trim(); if (isRangeValueValid(startValue) && isRangeValueValid(endValue)) { final RangeValue rangeValue = new RangeValue(); rangeValue.setIncludeStartValue(includeStartValue); rangeValue.setStartValue(startValue); rangeValue.setIncludeEndValue(includeEndValue); rangeValue.setEndValue(endValue); return rangeValue; } } } return new RangeValue(); }
FEELRangeParser { public static RangeValue parse(final String input) { if (Objects.isNull(input)) { return new RangeValue(); } final String trimmedInput = input.trim(); if (!hasLeadingAndEndingParenthesis(trimmedInput)) { return new RangeValue(); } final boolean includeStartValue = trimmedInput.startsWith(INCLUDE_START); final boolean includeEndValue = trimmedInput.endsWith(INCLUDE_END); boolean inQuotes = false; String startValue = ""; String endValue = ""; for (int current = 0; current < trimmedInput.length(); current++) { if (trimmedInput.charAt(current) == '\"') { inQuotes = !inQuotes; } if (isSeparator(current, inQuotes, trimmedInput)) { startValue = trimmedInput.substring(1, current).trim(); endValue = trimmedInput.substring(current + SEPARATOR_LENGTH, trimmedInput.length() - 1).trim(); if (isRangeValueValid(startValue) && isRangeValueValid(endValue)) { final RangeValue rangeValue = new RangeValue(); rangeValue.setIncludeStartValue(includeStartValue); rangeValue.setStartValue(startValue); rangeValue.setIncludeEndValue(includeEndValue); rangeValue.setEndValue(endValue); return rangeValue; } } } return new RangeValue(); } }
FEELRangeParser { public static RangeValue parse(final String input) { if (Objects.isNull(input)) { return new RangeValue(); } final String trimmedInput = input.trim(); if (!hasLeadingAndEndingParenthesis(trimmedInput)) { return new RangeValue(); } final boolean includeStartValue = trimmedInput.startsWith(INCLUDE_START); final boolean includeEndValue = trimmedInput.endsWith(INCLUDE_END); boolean inQuotes = false; String startValue = ""; String endValue = ""; for (int current = 0; current < trimmedInput.length(); current++) { if (trimmedInput.charAt(current) == '\"') { inQuotes = !inQuotes; } if (isSeparator(current, inQuotes, trimmedInput)) { startValue = trimmedInput.substring(1, current).trim(); endValue = trimmedInput.substring(current + SEPARATOR_LENGTH, trimmedInput.length() - 1).trim(); if (isRangeValueValid(startValue) && isRangeValueValid(endValue)) { final RangeValue rangeValue = new RangeValue(); rangeValue.setIncludeStartValue(includeStartValue); rangeValue.setStartValue(startValue); rangeValue.setIncludeEndValue(includeEndValue); rangeValue.setEndValue(endValue); return rangeValue; } } } return new RangeValue(); }  }
FEELRangeParser { public static RangeValue parse(final String input) { if (Objects.isNull(input)) { return new RangeValue(); } final String trimmedInput = input.trim(); if (!hasLeadingAndEndingParenthesis(trimmedInput)) { return new RangeValue(); } final boolean includeStartValue = trimmedInput.startsWith(INCLUDE_START); final boolean includeEndValue = trimmedInput.endsWith(INCLUDE_END); boolean inQuotes = false; String startValue = ""; String endValue = ""; for (int current = 0; current < trimmedInput.length(); current++) { if (trimmedInput.charAt(current) == '\"') { inQuotes = !inQuotes; } if (isSeparator(current, inQuotes, trimmedInput)) { startValue = trimmedInput.substring(1, current).trim(); endValue = trimmedInput.substring(current + SEPARATOR_LENGTH, trimmedInput.length() - 1).trim(); if (isRangeValueValid(startValue) && isRangeValueValid(endValue)) { final RangeValue rangeValue = new RangeValue(); rangeValue.setIncludeStartValue(includeStartValue); rangeValue.setStartValue(startValue); rangeValue.setIncludeEndValue(includeEndValue); rangeValue.setEndValue(endValue); return rangeValue; } } } return new RangeValue(); }  static RangeValue parse(final String input); }
FEELRangeParser { public static RangeValue parse(final String input) { if (Objects.isNull(input)) { return new RangeValue(); } final String trimmedInput = input.trim(); if (!hasLeadingAndEndingParenthesis(trimmedInput)) { return new RangeValue(); } final boolean includeStartValue = trimmedInput.startsWith(INCLUDE_START); final boolean includeEndValue = trimmedInput.endsWith(INCLUDE_END); boolean inQuotes = false; String startValue = ""; String endValue = ""; for (int current = 0; current < trimmedInput.length(); current++) { if (trimmedInput.charAt(current) == '\"') { inQuotes = !inQuotes; } if (isSeparator(current, inQuotes, trimmedInput)) { startValue = trimmedInput.substring(1, current).trim(); endValue = trimmedInput.substring(current + SEPARATOR_LENGTH, trimmedInput.length() - 1).trim(); if (isRangeValueValid(startValue) && isRangeValueValid(endValue)) { final RangeValue rangeValue = new RangeValue(); rangeValue.setIncludeStartValue(includeStartValue); rangeValue.setStartValue(startValue); rangeValue.setIncludeEndValue(includeEndValue); rangeValue.setEndValue(endValue); return rangeValue; } } } return new RangeValue(); }  static RangeValue parse(final String input);  }