class RangeArrayPropertyEditor extends PropertyEditorSupport {

	private boolean forceDisjointRanges = false;

	/**
	 * Set force disjoint ranges. If set to TRUE, ranges are validated to be disjoint. For
	 * example: defining ranges '1-10, 5-15' will cause IllegalArgumentException in case
	 * of forceDisjointRanges=TRUE.
	 * @param forceDisjointRanges true to force disjoint ranges.
	 */
	public void setForceDisjointRanges(boolean forceDisjointRanges) {
		this.forceDisjointRanges = forceDisjointRanges;
	}

	@Override
	public void setAsText(String text) throws IllegalArgumentException {

		// split text into ranges
		String[] strRanges = text.split(",");
		Range[] ranges = new Range[strRanges.length];

		// parse ranges and create array of Range objects
		for (int i = 0; i < strRanges.length; i++) {
			String[] range = strRanges[i].split("-");

			int min;
			int max;

			if ((range.length == 1) && (StringUtils.hasText(range[0]))) {
				min = Integer.parseInt(range[0].trim());
				// correct max value will be assigned later
				ranges[i] = new Range(min);
			}
			else if ((range.length == 2) && (StringUtils.hasText(range[0])) && (StringUtils.hasText(range[1]))) {
				min = Integer.parseInt(range[0].trim());
				max = Integer.parseInt(range[1].trim());
				ranges[i] = new Range(min, max);
			}
			else {
				throw new IllegalArgumentException("Range[" + i + "]: range (" + strRanges[i] + ") is invalid");
			}

		}

		setMaxValues(ranges);
		setValue(ranges);
	}

	@Override
	public String getAsText() {<FILL_FUNCTION_BODY>}

	private void setMaxValues(final Range[] ranges) {

		// Array of integers to track range values by index
		Integer[] c = new Integer[ranges.length];
		for (int i = 0; i < c.length; i++) {
			c[i] = i;
		}

		// sort array of Ranges
		Arrays.sort(c, Comparator.comparingInt(r -> ranges[r].getMin()));

		// set max values for all unbound ranges (except last range)
		for (int i = 0; i < c.length - 1; i++) {
			if (!ranges[c[i]].hasMaxValue()) {
				// set max value to (min value - 1) of the next range
				ranges[c[i]] = new Range(ranges[c[i]].getMin(), ranges[c[i + 1]].getMin() - 1);
			}
		}

		if (forceDisjointRanges) {
			verifyRanges(ranges);
		}
	}

	private void verifyRanges(Range[] ranges) {
		// verify that ranges are disjoint
		for (int i = 1; i < ranges.length; i++) {
			Assert.isTrue(ranges[i - 1].getMax() < ranges[i].getMin(), "Ranges must be disjoint. Range[" + (i - 1)
					+ "]: (" + ranges[i - 1] + ") Range[" + i + "]: (" + ranges[i] + ")");
		}
	}

}

		Range[] ranges = (Range[]) getValue();

		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < ranges.length; i++) {
			if (i > 0) {
				sb.append(", ");
			}
			sb.append(ranges[i]);
		}
		return sb.toString();
	
<methods>public void <init>() ,public void <init>(java.lang.Object) ,public synchronized void addPropertyChangeListener(java.beans.PropertyChangeListener) ,public void firePropertyChange() ,public java.lang.String getAsText() ,public java.awt.Component getCustomEditor() ,public java.lang.String getJavaInitializationString() ,public java.lang.Object getSource() ,public java.lang.String[] getTags() ,public java.lang.Object getValue() ,public boolean isPaintable() ,public void paintValue(java.awt.Graphics, java.awt.Rectangle) ,public synchronized void removePropertyChangeListener(java.beans.PropertyChangeListener) ,public void setAsText(java.lang.String) throws java.lang.IllegalArgumentException,public void setSource(java.lang.Object) ,public void setValue(java.lang.Object) ,public boolean supportsCustomEditor() <variables>private Vector<java.beans.PropertyChangeListener> listeners,private java.lang.Object source,private java.lang.Object value