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

org.apache.calcite.linq4j.DefaultEnumerable Maven / Gradle / Ivy

There is a newer version: 1.38.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to you 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.apache.calcite.linq4j;

import org.apache.calcite.linq4j.function.BigDecimalFunction1;
import org.apache.calcite.linq4j.function.DoubleFunction1;
import org.apache.calcite.linq4j.function.EqualityComparer;
import org.apache.calcite.linq4j.function.FloatFunction1;
import org.apache.calcite.linq4j.function.Function0;
import org.apache.calcite.linq4j.function.Function1;
import org.apache.calcite.linq4j.function.Function2;
import org.apache.calcite.linq4j.function.IntegerFunction1;
import org.apache.calcite.linq4j.function.LongFunction1;
import org.apache.calcite.linq4j.function.NullableBigDecimalFunction1;
import org.apache.calcite.linq4j.function.NullableDoubleFunction1;
import org.apache.calcite.linq4j.function.NullableFloatFunction1;
import org.apache.calcite.linq4j.function.NullableIntegerFunction1;
import org.apache.calcite.linq4j.function.NullableLongFunction1;
import org.apache.calcite.linq4j.function.Predicate1;
import org.apache.calcite.linq4j.function.Predicate2;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

/**
 * Implementation of the {@link org.apache.calcite.linq4j.Enumerable} interface
 * that implements the extension methods by calling into the {@link Extensions}
 * class.
 *
 * 

The are two abstract methods: * {@link #enumerator()} and {@link #iterator()}. * The derived class can implement each separately, or implement one in terms of * the other.

* * @param Element type */ public abstract class DefaultEnumerable implements OrderedEnumerable { /** * Derived classes might wish to override this method to return the "outer" * enumerable. */ protected Enumerable getThis() { return this; } /** * Derived classes might wish to override this method to return the "outer" * ordered-enumerable. */ protected OrderedEnumerable getThisOrdered() { return this; } public R foreach(Function1 func) { R result = null; try (Enumerator enumerator = enumerator()) { while (enumerator.moveNext()) { T t = enumerator.current(); result = func.apply(t); } return result; } } public Queryable asQueryable() { return Extensions.asQueryable(this); } // NOTE: Not part of the Queryable interface. protected OrderedQueryable asOrderedQueryable() { return EnumerableDefaults.asOrderedQueryable(this); } public T aggregate(Function2 func) { return EnumerableDefaults.aggregate(getThis(), func); } public TAccumulate aggregate(TAccumulate seed, Function2 func) { return EnumerableDefaults.aggregate(getThis(), seed, func); } public TResult aggregate(TAccumulate seed, Function2 func, Function1 selector) { return EnumerableDefaults.aggregate(getThis(), seed, func, selector); } public boolean all(Predicate1 predicate) { return EnumerableDefaults.all(getThis(), predicate); } public boolean any() { return EnumerableDefaults.any(getThis()); } public boolean any(Predicate1 predicate) { return EnumerableDefaults.any(getThis(), predicate); } public Enumerable asEnumerable() { return EnumerableDefaults.asEnumerable(getThis()); } public BigDecimal average(BigDecimalFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public BigDecimal average(NullableBigDecimalFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public double average(DoubleFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public Double average(NullableDoubleFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public int average(IntegerFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public Integer average(NullableIntegerFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public long average(LongFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public Long average(NullableLongFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public float average(FloatFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public Float average(NullableFloatFunction1 selector) { return EnumerableDefaults.average(getThis(), selector); } public Enumerable cast(Class clazz) { return EnumerableDefaults.cast(getThis(), clazz); } public Enumerable concat(Enumerable enumerable1) { return EnumerableDefaults.concat(getThis(), enumerable1); } public boolean contains(T element) { return EnumerableDefaults.contains(getThis(), element); } public boolean contains(T element, EqualityComparer comparer) { return EnumerableDefaults.contains(getThis(), element, comparer); } public int count() { return EnumerableDefaults.count(getThis()); } public int count(Predicate1 predicate) { return EnumerableDefaults.count(getThis(), predicate); } public OrderedEnumerable createOrderedEnumerable( Function1 keySelector, Comparator comparator, boolean descending) { return EnumerableDefaults.createOrderedEnumerable(getThisOrdered(), keySelector, comparator, descending); } public Enumerable defaultIfEmpty() { return EnumerableDefaults.defaultIfEmpty(getThis()); } public Enumerable defaultIfEmpty(T value) { return EnumerableDefaults.defaultIfEmpty(getThis(), value); } public Enumerable distinct() { return EnumerableDefaults.distinct(getThis()); } public Enumerable distinct(EqualityComparer comparer) { return EnumerableDefaults.distinct(getThis(), comparer); } public T elementAt(int index) { return EnumerableDefaults.elementAt(getThis(), index); } public T elementAtOrDefault(int index) { return EnumerableDefaults.elementAtOrDefault(getThis(), index); } public Enumerable except(Enumerable enumerable1) { return except(enumerable1, false); } public Enumerable except(Enumerable enumerable1, boolean all) { return EnumerableDefaults.except(getThis(), enumerable1, all); } public Enumerable except(Enumerable enumerable1, EqualityComparer comparer) { return except(enumerable1, comparer, false); } public Enumerable except(Enumerable enumerable1, EqualityComparer comparer, boolean all) { return EnumerableDefaults.except(getThis(), enumerable1, comparer, all); } public T first() { return EnumerableDefaults.first(getThis()); } public T first(Predicate1 predicate) { return EnumerableDefaults.first(getThis(), predicate); } public T firstOrDefault() { return EnumerableDefaults.firstOrDefault(getThis()); } public T firstOrDefault(Predicate1 predicate) { return EnumerableDefaults.firstOrDefault(getThis(), predicate); } public Enumerable> groupBy( Function1 keySelector) { return EnumerableDefaults.groupBy(getThis(), keySelector); } public Enumerable> groupBy( Function1 keySelector, EqualityComparer comparer) { return EnumerableDefaults.groupBy(getThis(), keySelector, comparer); } public Enumerable> groupBy( Function1 keySelector, Function1 elementSelector) { return EnumerableDefaults.groupBy(getThis(), keySelector, elementSelector); } public Enumerable> groupBy( Function1 keySelector, Function1 elementSelector, EqualityComparer comparer) { return EnumerableDefaults.groupBy(getThis(), keySelector, elementSelector, comparer); } public Enumerable groupBy( Function1 keySelector, Function2, TResult> elementSelector, EqualityComparer comparer) { return EnumerableDefaults.groupBy(getThis(), keySelector, elementSelector, comparer); } public Enumerable groupBy( Function1 keySelector, Function2, TResult> resultSelector) { return EnumerableDefaults.groupBy(getThis(), keySelector, resultSelector); } public Enumerable groupBy( Function1 keySelector, Function1 elementSelector, Function2, TResult> resultSelector) { return EnumerableDefaults.groupBy(getThis(), keySelector, elementSelector, resultSelector); } public Enumerable groupBy( Function1 keySelector, Function1 elementSelector, Function2, TResult> resultSelector, EqualityComparer comparer) { return EnumerableDefaults.groupBy(getThis(), keySelector, elementSelector, resultSelector, comparer); } public Enumerable groupBy( Function1 keySelector, Function0 accumulatorInitializer, Function2 accumulatorAdder, Function2 resultSelector) { return EnumerableDefaults.groupBy(getThis(), keySelector, accumulatorInitializer, accumulatorAdder, resultSelector); } public Enumerable groupBy( Function1 keySelector, Function0 accumulatorInitializer, Function2 accumulatorAdder, Function2 resultSelector, EqualityComparer comparer) { return EnumerableDefaults.groupBy(getThis(), keySelector, accumulatorInitializer, accumulatorAdder, resultSelector, comparer); } public Enumerable groupJoin( Enumerable inner, Function1 outerKeySelector, Function1 innerKeySelector, Function2, TResult> resultSelector) { return EnumerableDefaults.groupJoin(getThis(), inner, outerKeySelector, innerKeySelector, resultSelector); } public Enumerable groupJoin( Enumerable inner, Function1 outerKeySelector, Function1 innerKeySelector, Function2, TResult> resultSelector, EqualityComparer comparer) { return EnumerableDefaults.groupJoin(getThis(), inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } public Enumerable intersect(Enumerable enumerable1) { return intersect(enumerable1, false); } public Enumerable intersect(Enumerable enumerable1, boolean all) { return EnumerableDefaults.intersect(getThis(), enumerable1, all); } public Enumerable intersect(Enumerable enumerable1, EqualityComparer comparer) { return intersect(enumerable1, comparer, false); } public Enumerable intersect(Enumerable enumerable1, EqualityComparer comparer, boolean all) { return EnumerableDefaults.intersect(getThis(), enumerable1, comparer, all); } public > C into(C sink) { return EnumerableDefaults.into(getThis(), sink); } public > C removeAll(C sink) { return EnumerableDefaults.remove(getThis(), sink); } public Enumerable hashJoin( Enumerable inner, Function1 outerKeySelector, Function1 innerKeySelector, Function2 resultSelector) { return EnumerableDefaults.hashJoin(getThis(), inner, outerKeySelector, innerKeySelector, resultSelector); } public Enumerable hashJoin( Enumerable inner, Function1 outerKeySelector, Function1 innerKeySelector, Function2 resultSelector, EqualityComparer comparer) { return EnumerableDefaults.hashJoin(getThis(), inner, outerKeySelector, innerKeySelector, resultSelector, comparer); } public Enumerable hashJoin( Enumerable inner, Function1 outerKeySelector, Function1 innerKeySelector, Function2 resultSelector, EqualityComparer comparer, boolean generateNullsOnLeft, boolean generateNullsOnRight) { return EnumerableDefaults.hashJoin(getThis(), inner, outerKeySelector, innerKeySelector, resultSelector, comparer, generateNullsOnLeft, generateNullsOnRight); } public Enumerable hashJoin( Enumerable inner, Function1 outerKeySelector, Function1 innerKeySelector, Function2 resultSelector, EqualityComparer comparer, boolean generateNullsOnLeft, boolean generateNullsOnRight, Predicate2 predicate) { return EnumerableDefaults.hashJoin(getThis(), inner, outerKeySelector, innerKeySelector, resultSelector, comparer, generateNullsOnLeft, generateNullsOnRight, predicate); } public Enumerable correlateJoin( JoinType joinType, Function1> inner, Function2 resultSelector) { return EnumerableDefaults.correlateJoin(joinType, getThis(), inner, resultSelector); } public T last() { return EnumerableDefaults.last(getThis()); } public T last(Predicate1 predicate) { return EnumerableDefaults.last(getThis(), predicate); } public T lastOrDefault() { return EnumerableDefaults.lastOrDefault(getThis()); } public T lastOrDefault(Predicate1 predicate) { return EnumerableDefaults.lastOrDefault(getThis(), predicate); } public long longCount() { return EnumerableDefaults.longCount(getThis()); } public long longCount(Predicate1 predicate) { return EnumerableDefaults.longCount(getThis(), predicate); } public T max() { return (T) EnumerableDefaults.max((Enumerable) getThis()); } public BigDecimal max(BigDecimalFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public BigDecimal max(NullableBigDecimalFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public double max(DoubleFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public Double max(NullableDoubleFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public int max(IntegerFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public Integer max(NullableIntegerFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public long max(LongFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public Long max(NullableLongFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public float max(FloatFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public Float max(NullableFloatFunction1 selector) { return EnumerableDefaults.max(getThis(), selector); } public > TResult max( Function1 selector) { return EnumerableDefaults.max(getThis(), selector); } public T min() { return (T) EnumerableDefaults.min((Enumerable) getThis()); } public BigDecimal min(BigDecimalFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public BigDecimal min(NullableBigDecimalFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public double min(DoubleFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public Double min(NullableDoubleFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public int min(IntegerFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public Integer min(NullableIntegerFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public long min(LongFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public Long min(NullableLongFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public float min(FloatFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public Float min(NullableFloatFunction1 selector) { return EnumerableDefaults.min(getThis(), selector); } public > TResult min( Function1 selector) { return EnumerableDefaults.min(getThis(), selector); } public Enumerable ofType(Class clazz) { return EnumerableDefaults.ofType(getThis(), clazz); } public Enumerable orderBy( Function1 keySelector) { return EnumerableDefaults.orderBy(getThis(), keySelector); } public Enumerable orderBy(Function1 keySelector, Comparator comparator) { return EnumerableDefaults.orderBy(getThis(), keySelector, comparator); } public Enumerable orderByDescending( Function1 keySelector) { return EnumerableDefaults.orderByDescending(getThis(), keySelector); } public Enumerable orderByDescending(Function1 keySelector, Comparator comparator) { return EnumerableDefaults.orderByDescending(getThis(), keySelector, comparator); } public Enumerable reverse() { return EnumerableDefaults.reverse(getThis()); } public Enumerable select(Function1 selector) { return EnumerableDefaults.select(getThis(), selector); } public Enumerable select( Function2 selector) { return EnumerableDefaults.select(getThis(), selector); } public Enumerable selectMany( Function1> selector) { return EnumerableDefaults.selectMany(getThis(), selector); } public Enumerable selectMany( Function2> selector) { return EnumerableDefaults.selectMany(getThis(), selector); } public Enumerable selectMany( Function2> collectionSelector, Function2 resultSelector) { return EnumerableDefaults.selectMany(getThis(), collectionSelector, resultSelector); } public Enumerable selectMany( Function1> collectionSelector, Function2 resultSelector) { return EnumerableDefaults.selectMany(getThis(), collectionSelector, resultSelector); } public boolean sequenceEqual(Enumerable enumerable1) { return EnumerableDefaults.sequenceEqual(getThis(), enumerable1); } public boolean sequenceEqual(Enumerable enumerable1, EqualityComparer comparer) { return EnumerableDefaults.sequenceEqual(getThis(), enumerable1, comparer); } public T single() { return EnumerableDefaults.single(getThis()); } public T single(Predicate1 predicate) { return EnumerableDefaults.single(getThis(), predicate); } public T singleOrDefault() { return EnumerableDefaults.singleOrDefault(getThis()); } public T singleOrDefault(Predicate1 predicate) { return EnumerableDefaults.singleOrDefault(getThis(), predicate); } public Enumerable skip(int count) { return EnumerableDefaults.skip(getThis(), count); } public Enumerable skipWhile(Predicate1 predicate) { return EnumerableDefaults.skipWhile(getThis(), predicate); } public Enumerable skipWhile(Predicate2 predicate) { return EnumerableDefaults.skipWhile(getThis(), predicate); } public BigDecimal sum(BigDecimalFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public BigDecimal sum(NullableBigDecimalFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public double sum(DoubleFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public Double sum(NullableDoubleFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public int sum(IntegerFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public Integer sum(NullableIntegerFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public long sum(LongFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public Long sum(NullableLongFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public float sum(FloatFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public Float sum(NullableFloatFunction1 selector) { return EnumerableDefaults.sum(getThis(), selector); } public Enumerable take(int count) { return EnumerableDefaults.take(getThis(), count); } public Enumerable takeWhile(Predicate1 predicate) { return EnumerableDefaults.takeWhile(getThis(), predicate); } public Enumerable takeWhile(Predicate2 predicate) { return EnumerableDefaults.takeWhile(getThis(), predicate); } public > OrderedEnumerable thenBy( Function1 keySelector) { return EnumerableDefaults.thenBy(getThisOrdered(), keySelector); } public OrderedEnumerable thenBy(Function1 keySelector, Comparator comparator) { return EnumerableDefaults.thenByDescending(getThisOrdered(), keySelector, comparator); } public > OrderedEnumerable thenByDescending( Function1 keySelector) { return EnumerableDefaults.thenByDescending(getThisOrdered(), keySelector); } public OrderedEnumerable thenByDescending( Function1 keySelector, Comparator comparator) { return EnumerableDefaults.thenBy(getThisOrdered(), keySelector, comparator); } public Map toMap(Function1 keySelector) { return EnumerableDefaults.toMap(getThis(), keySelector); } public Map toMap(Function1 keySelector, EqualityComparer comparer) { return EnumerableDefaults.toMap(getThis(), keySelector, comparer); } public Map toMap( Function1 keySelector, Function1 elementSelector) { return EnumerableDefaults.toMap(getThis(), keySelector, elementSelector); } public Map toMap( Function1 keySelector, Function1 elementSelector, EqualityComparer comparer) { return EnumerableDefaults.toMap(getThis(), keySelector, elementSelector, comparer); } public List toList() { return EnumerableDefaults.toList(getThis()); } public Lookup toLookup(Function1 keySelector) { return EnumerableDefaults.toLookup(getThis(), keySelector); } public Lookup toLookup(Function1 keySelector, EqualityComparer comparer) { return EnumerableDefaults.toLookup(getThis(), keySelector, comparer); } public Lookup toLookup( Function1 keySelector, Function1 elementSelector) { return EnumerableDefaults.toLookup(getThis(), keySelector, elementSelector); } public Lookup toLookup( Function1 keySelector, Function1 elementSelector, EqualityComparer comparer) { return EnumerableDefaults.toLookup(getThis(), keySelector, elementSelector, comparer); } public Enumerable union(Enumerable source1) { return EnumerableDefaults.union(getThis(), source1); } public Enumerable union(Enumerable source1, EqualityComparer comparer) { return EnumerableDefaults.union(getThis(), source1, comparer); } public Enumerable where(Predicate1 predicate) { return EnumerableDefaults.where(getThis(), predicate); } public Enumerable where(Predicate2 predicate) { return EnumerableDefaults.where(getThis(), predicate); } public Enumerable zip(Enumerable source1, Function2 resultSelector) { return EnumerableDefaults.zip(getThis(), source1, resultSelector); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy