
com.speedment.runtime.field.collector.FieldCollectors Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of runtime-field Show documentation
Show all versions of runtime-field Show documentation
Partly generated model of the fields that represent columns in the
database. Fields can be used to produce special predicates and functions
that contain metadata that Speedment can analyze runtime.
/**
*
* Copyright (c) 2006-2017, Speedment, Inc. All Rights Reserved.
*
* 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.speedment.runtime.field.collector;
import com.speedment.runtime.field.BooleanField;
import com.speedment.runtime.field.ByteField;
import com.speedment.runtime.field.CharField;
import com.speedment.runtime.field.DoubleField;
import com.speedment.runtime.field.Field;
import com.speedment.runtime.field.FloatField;
import com.speedment.runtime.field.IntField;
import com.speedment.runtime.field.LongField;
import com.speedment.runtime.field.ReferenceField;
import com.speedment.runtime.field.ShortField;
import com.speedment.runtime.field.StringField;
import com.speedment.runtime.field.internal.collector.FieldCollectorImpl;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
import static java.util.stream.Collectors.toList;
/**
* A number of collectors specialized for entities. These are inspired by the
* {@link java.util.stream.Collectors} class in the java standard libraries.
*
* @author Emil Forslund
* @since 3.0.2
*/
public final class FieldCollectors {
public static Collector>>
groupingBy(LongField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(IntField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(ShortField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(ByteField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(DoubleField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(FloatField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(BooleanField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(CharField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(StringField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>>
groupingBy(ReferenceField field) {
return groupingBy(field, field.getter()::apply, HashMap::new, toList());
}
public static Collector>
groupingBy(LongField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(IntField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(ShortField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(ByteField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(DoubleField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(FloatField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(BooleanField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(CharField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(StringField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static Collector>
groupingBy(ReferenceField field, Collector downstream) {
return groupingBy(field, field.getter()::apply, HashMap::new, downstream);
}
public static >
FieldCollector groupingBy(
Field field,
Function classifier,
Supplier mapFactory,
Collector super T, A, D> downstream) {
Supplier downstreamSupplier = downstream.supplier();
BiConsumer downstreamAccumulator = downstream.accumulator();
BiConsumer
© 2015 - 2025 Weber Informatics LLC | Privacy Policy