static IntRange checkLengthRange(final IntRange lengthRange, final int length) {
		requireNonNull(lengthRange);
		if (lengthRange.min() <= 0) {
			throw new IllegalArgumentException(format(
				"Minimum length must be positive: %d", lengthRange.min()
			));
		}
		if (lengthRange.max() <= 0) {
			throw new IllegalArgumentException(format(
				"Maximum length must be positive: %d", lengthRange.max()
			));
		}
		if (lengthRange.size() <= 0) {
			throw new IllegalArgumentException(format(
				"Maximal length must be positive: %d", lengthRange.size()
			));
		}
		if (length < lengthRange.min() ||
			length >= lengthRange.max())
		{
			throw new IllegalArgumentException(format(
				"Number of genes (%d) not within the allowed range: %s",
				length,
				lengthRange
			));
		}

		return lengthRange;
	}
Create a new {@code VariableChromosome} from the given {@code genes}
and the allowed length range of the chromosome.

@param genes the genes that form the chromosome.
@param lengthRange the allowed length range of the chromosome
@throws NullPointerException if one of the arguments is {@code null}.
@throws IllegalArgumentException if the length of the gene sequence is
        empty or doesn't match with the allowed length range.
@throws IllegalArgumentException if the minimum or maximum of the range
        is smaller or equal zero
@throws IllegalArgumentException if the given range size is zero
jenetics/src/main/java/io/jenetics/VariableChromosome.java