All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jqwik.engine.properties.shrinking.ShrinkableString Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
package net.jqwik.engine.properties.shrinking;

import java.util.*;
import java.util.function.*;
import java.util.stream.*;

import net.jqwik.api.*;

public class ShrinkableString extends ShrinkableContainer {

	private final int minSize;

	public ShrinkableString(List> elements, int minSize) {
		super(elements, minSize);
		this.minSize = minSize;
	}

	@Override
	Collector containerCollector() {
		return new CharacterCollector();
	}

	@Override
	Shrinkable createShrinkable(List> shrunkElements) {
		return new ShrinkableString(shrunkElements, minSize);
	}

	private static class CharacterCollector implements Collector {
		@Override
		public Supplier supplier() {
			return StringBuilder::new;
		}

		@Override
		public BiConsumer accumulator() {
			return StringBuilder::appendCodePoint;
		}

		@Override
		public BinaryOperator combiner() {
			return StringBuilder::append;
		}

		@Override
		public Function finisher() {
			return StringBuilder::toString;
		}

		@Override
		public Set characteristics() {
			return Collections.emptySet();
		}

	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy