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

org.llorllale.youtrack.api.StreamOf Maven / Gradle / Ivy

There is a newer version: 1.1.0-rc59
Show newest version
/*
 * Copyright 2017 George Aristy
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.llorllale.youtrack.api;

import java.util.Collection;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

/**
 * Handy class to encapsulate several inputs as a {@link Stream}.
 *
 * @author George Aristy ([email protected])
 * @param  the stream's type
 * @since 1.0.0
 */
final class StreamOf extends StreamEnvelope {

  /**
   * Encapsulates the collection as a stream.
   * 
   * @param coll collection to encapsulate
   * @since 1.0.0
   */
  StreamOf(Collection coll) {
    super(coll.stream());
  }

  /**
   * Encapsulates the given iterator as a stream.
   * 
   * @param iter the iterator to encapsulate
   * @since 1.0.0
   */
  StreamOf(Iterator iter) {
    super(
        StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(iter, Spliterator.DISTINCT), 
            false
        )
    );
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy