<commit_before>/*
 * Copyright (C) 2015-2015 The Helenus Driver Project Authors.
 *
 * 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 com.github.helenusdriver.driver;

import java.lang.reflect.Field;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

import javax.json.JsonObject;

import com.github.helenusdriver.driver.info.ClassInfo;
import com.github.helenusdriver.persistence.Column;

/**
 * The <code>StatementBuilder</code> class extends the functionality of Cassandra's
 * {@link com.datastax.driver.core.querybuilder.QueryBuilder} class in order to
 * provide support for POJOs.
 *
 * @copyright 2015-2015 The Helenus Driver Project Authors
 *
 * @author  The Helenus Driver Project Authors
 * @version 1 - Jan 15, 2015 - paouelle - Creation
 *
 * @since 1.0
 */
public final class StatementBuilder {
  /**
   * Prevents instantiation
   *
   * @author paouelle
   */
  private StatementBuilder() {}

  /**
   * Gets a class info structure that defines the specified POJO class.
   *
   * @author paouelle
   *
   * @param <T> The type of POJO associated with this statement
   *
   * @param  clazz the class of POJO for which to get a class info object for
   * @return the non-<code>null</code> class info object representing the given
   *         POJO class
   * @throws NullPointerException if <code>clazz</code> is <code>null</code>
   * @throws IllegalArgumentException if <code>clazz</code> doesn't represent
   *         a valid POJO class
   */
  public static <T> ClassInfo<T> getClassInfo(Class<T> clazz) {
    org.apache.commons.lang3.Validate.notNull(clazz, "invalid null POJO class");<commit_msg>added ability to get a stream from a ResultSet<commit_after>/*
 * Copyright (C) 2015-2015 The Helenus Driver Project Authors.
 *
 * 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 com.github.helenusdriver.driver;

import java.lang.reflect.Field;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import javax.json.JsonObject;

import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.github.helenusdriver.driver.info.ClassInfo;
import com.github.helenusdriver.persistence.Column;

/**
 * The <code>StatementBuilder</code> class extends the functionality of Cassandra's
 * {@link com.datastax.driver.core.querybuilder.QueryBuilder} class in order to
 * provide support for POJOs.
 *
 * @copyright 2015-2015 The Helenus Driver Project Authors
 *
 * @author  The Helenus Driver Project Authors
 * @version 1 - Jan 15, 2015 - paouelle - Creation
 *
 * @since 1.0
 */
public final class StatementBuilder {
  /**
   * Prevents instantiation
   *
   * @author paouelle
   */
  private StatementBuilder() {}

  /**
   * Gets a stream of the remaining rows for the specified result set.
   *
   * @author <a href="mailto:<EMAIL>">paouelle</a>
   *
   * @param  set the result set for which to get a stream of rows
   * @return a stream of all remaining rows in the specified result set
   * @throws NullPointerException if <code>set</code> is <code>null</code>
   */
  public static Stream<Row> stream(ResultSet set) {
    return StreamSupport.stream(Spliterators.spliteratorUnknownSize(
      set.iterator(),
      Spliterator.ORDERED | Spliterator.IMMUTABLE | Spliterator.NONNULL
    ), false);
  }

  /**
   * Gets a class info structure that defines the specified POJO class.
   *
   * @author paouelle
   *
   * @param <T> The type of POJO associated with this statement
   *
   * @param  clazz the class of POJO for which to get a class info object for
   * @return the non-<code>null</code> class info object representing the given
   *         POJO class
   * @throws NullPointerException if <code>clazz</code> is <code>null</code>
   * @throws IllegalArgumentException if <code>clazz</code> doesn't represent
   *         a valid POJO class
   */
  public static <T> ClassInfo<T> getClassInfo(Class<T> clazz) {
    org.apache.commons.lang3.Validate.notNull(clazz, "invalid null POJO class");
{'fraction_non_alphanumeric': 0.09486543233441497, 'fraction_numerical': 0.011452567283832793, 'mean_word_length': 3.695340501792115, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '419776', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1500, 'n_words': 541}