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

com.emc.mongoose.common.supply.async.AsyncPatternDefinedSupplier Maven / Gradle / Ivy

The newest version!
package com.emc.mongoose.common.supply.async;

import com.emc.mongoose.common.exception.OmgDoesNotPerformException;
import com.emc.mongoose.common.exception.UserShootHisFootException;
import com.emc.mongoose.common.supply.RangePatternDefinedSupplier;
import com.emc.mongoose.common.supply.PatternDefinedSupplier;

public final class AsyncPatternDefinedSupplier
extends AsyncUpdatingValueSupplier
implements PatternDefinedSupplier {
	
	private final PatternDefinedSupplier wrappedSupplier;
	
	public AsyncPatternDefinedSupplier(final String pattern)
	throws UserShootHisFootException {
		this(new RangePatternDefinedSupplier(pattern, AsyncStringSupplierFactory.getInstance()));
	}
	
	private AsyncPatternDefinedSupplier(final PatternDefinedSupplier wrappedSupplier)
	throws OmgDoesNotPerformException {
		super(
			null,
			new InitializedCallableBase() {
				private final StringBuilder result = new StringBuilder();
				@Override
				public final String call()
				throws Exception {
					result.setLength(0);
					return wrappedSupplier.format(result);
				}
			}
		);
		this.wrappedSupplier = wrappedSupplier;
	}
	
	@Override
	public String getPattern() {
		return wrappedSupplier.getPattern();
	}

	@Override
	public String format(final StringBuilder result) {
		return wrappedSupplier.format(result);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy