org.thymeleaf.expression.Aggregates Maven / Gradle / Ivy
Show all versions of org.everit.osgi.bundles.org.thymeleaf.thymeleaf Show documentation
/*
* =============================================================================
*
* Copyright (c) 2011-2013, The THYMELEAF team (http://www.thymeleaf.org)
*
* 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.thymeleaf.expression;
import java.math.BigDecimal;
import org.thymeleaf.util.AggregateUtils;
/**
*
* Utility class for performing aggregation operations on numbers (collections or arrays).
*
*
* An object of this class is usually available in variable evaluation expressions with the name
* #aggregates.
*
*
* @author Daniel Fernández
*
* @since 1.0
*
*/
public final class Aggregates {
/**
*
* Returns the sum of all the numbers contained in the provided
* iterable (e.g. a collection).
*
*
* This method delegates on {@link AggregateUtils#sum(Iterable)}.
*
*
* @param target the iterable containing the number objects
* @return the sum, as a BigDecimal
*/
public BigDecimal sum(final Iterable extends Number> target) {
return AggregateUtils.sum(target);
}
/**
*
* Returns the sum of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#sum(Object[])}.
*
*
* @param target the array of numbers
* @return the sum, as a BigDecimal
*/
public BigDecimal sum(final Number[] target) {
return AggregateUtils.sum(target);
}
/**
*
* Returns the sum of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#sum(byte[])}.
*
*
* @param target the array of numbers
* @return the sum, as a BigDecimal
*/
public BigDecimal sum(final byte[] target) {
return AggregateUtils.sum(target);
}
/**
*
* Returns the sum of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#sum(short[])}.
*
*
* @param target the array of numbers
* @return the sum, as a BigDecimal
*/
public BigDecimal sum(final short[] target) {
return AggregateUtils.sum(target);
}
/**
*
* Returns the sum of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#sum(int[])}.
*
*
* @param target the array of numbers
* @return the sum, as a BigDecimal
*/
public BigDecimal sum(final int[] target) {
return AggregateUtils.sum(target);
}
/**
*
* Returns the sum of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#sum(long[])}.
*
*
* @param target the array of numbers
* @return the sum, as a BigDecimal
*/
public BigDecimal sum(final long[] target) {
return AggregateUtils.sum(target);
}
/**
*
* Returns the sum of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#sum(float[])}.
*
*
* @param target the array of numbers
* @return the sum, as a BigDecimal
*/
public BigDecimal sum(final float[] target) {
return AggregateUtils.sum(target);
}
/**
*
* Returns the sum of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#sum(double[])}.
*
*
* @param target the array of numbers
* @return the sum, as a BigDecimal
*/
public BigDecimal sum(final double[] target) {
return AggregateUtils.sum(target);
}
/**
*
* Returns the average of all the numbers contained in the provided
* iterable (e.g. a collection).
*
*
* This method delegates on {@link AggregateUtils#avg(Iterable)}.
*
*
* @param target the iterable containing the number objects
* @return the average, as a BigDecimal
*/
public BigDecimal avg(final Iterable extends Number> target) {
return AggregateUtils.avg(target);
}
/**
*
* Returns the average of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#avg(Object[])}.
*
*
* @param target the array of numbers
* @return the average, as a BigDecimal
*/
public BigDecimal avg(final Number[] target) {
return AggregateUtils.avg(target);
}
/**
*
* Returns the average of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#avg(byte[])}.
*
*
* @param target the array of numbers
* @return the average, as a BigDecimal
*/
public BigDecimal avg(final byte[] target) {
return AggregateUtils.avg(target);
}
/**
*
* Returns the average of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#avg(short[])}.
*
*
* @param target the array of numbers
* @return the average, as a BigDecimal
*/
public BigDecimal avg(final short[] target) {
return AggregateUtils.avg(target);
}
/**
*
* Returns the average of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#avg(int[])}.
*
*
* @param target the array of numbers
* @return the average, as a BigDecimal
*/
public BigDecimal avg(final int[] target) {
return AggregateUtils.avg(target);
}
/**
*
* Returns the average of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#avg(long[])}.
*
*
* @param target the array of numbers
* @return the average, as a BigDecimal
*/
public BigDecimal avg(final long[] target) {
return AggregateUtils.avg(target);
}
/**
*
* Returns the average of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#avg(float[])}.
*
*
* @param target the array of numbers
* @return the average, as a BigDecimal
*/
public BigDecimal avg(final float[] target) {
return AggregateUtils.avg(target);
}
/**
*
* Returns the average of all the numbers contained in the provided array.
*
*
* This method delegates on {@link AggregateUtils#avg(double[])}.
*
*
* @param target the array of numbers
* @return the average, as a BigDecimal
*/
public BigDecimal avg(final double[] target) {
return AggregateUtils.avg(target);
}
/**
*
* Create an object of this class.
*
*
* Normally, this is only executed internally by the expression evaluation subsystems
* in dialects.
*
*/
public Aggregates() {
super();
}
}