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

prompto.value.IIterable Maven / Gradle / Ivy

The newest version!
package prompto.value;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import prompto.intrinsic.IterableWithCounts;
import prompto.runtime.Context;
import prompto.store.IStorable;
import prompto.type.AnyType;

public interface IIterable extends IValue
{
    IterableWithCounts getIterable(Context context);
    default void collectStorables(List storables) {
    	throw new UnsupportedOperationException();
    }
    @Override
    default IValue toDocumentValue(Context context) {
    	// TODO create PromptoList collector
		List values = StreamSupport.stream(getIterable(context).spliterator(), false)
				.map(value->value.toDocumentValue(context))
				.collect(Collectors.toList());
    	return new ListValue(AnyType.instance(), values);
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy