Java List Min min(final List aList, final Double aDefalut)

Here you can find the source of min(final List aList, final Double aDefalut)

Description

min

License

Apache License

Declaration

public static Double min(final List<Double> aList, final Double aDefalut) 

Method Source Code

//package com.java2s;
/**// w w  w.j  a v a 2 s.c o  m
 * 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.
 */

import java.util.List;

public class Main {

    public static Double min(final List<Double> aList, final Double aDefalut) {
        Double min = aDefalut;
        if (null != aList) {
            for (Double value : aList) {
                if (null != value) {
                    if (null == min) {
                        min = value;
                    } else {
                        min = Math.min(min, value);
                    }
                }
            }
        }
        return min;
    }

    public static Float min(final List<Float> aList, final Float aDefault) {
        Float min = aDefault;
        if (null != aList) {
            for (Float value : aList) {
                if (null != value) {
                    if (null == min) {
                        min = value;
                    } else {
                        min = Math.min(min, value);
                    }
                }
            }
        }
        return min;
    }

    public static Integer min(final List<Integer> aList, final Integer aDefalut) {
        Integer min = aDefalut;
        if (null != aList) {
            for (Integer value : aList) {
                if (null != value) {
                    if (null == min) {
                        min = value;
                    } else {
                        min = Math.min(min, value);
                    }
                }
            }
        }
        return min;
    }

    public static Long min(final List<Long> aList, final Long aDefault) {
        Long min = aDefault;
        if (null != aList) {
            for (Long value : aList) {
                if (null != value) {
                    if (null == min) {
                        min = value;
                    } else {
                        min = Math.max(min, value);
                    }
                }
            }
        }
        return min;
    }

    public static Double max(final List<Double> aList, final Double aDefalut) {
        Double max = aDefalut;
        if (null != aList) {
            for (Double value : aList) {
                if (null != value) {
                    if (null == max) {
                        max = value;
                    } else {
                        max = Math.max(max, value);
                    }
                }
            }
        }
        return max;
    }

    public static Float max(final List<Float> aList, final Float aDefault) {
        Float max = aDefault;
        if (null != aList) {
            for (Float value : aList) {
                if (null != value) {
                    if (null == max) {
                        max = value;
                    } else {
                        max = Math.max(max, value);
                    }
                }
            }
        }
        return max;
    }

    public static Integer max(final List<Integer> aList, final Integer aDefalut) {
        Integer max = aDefalut;
        if (null != aList) {
            for (Integer value : aList) {
                if (null != value) {
                    if (null == max) {
                        max = value;
                    } else {
                        max = Math.max(max, value);
                    }
                }
            }
        }
        return max;
    }

    public static Long max(final List<Long> aList, final Long aDefault) {
        Long max = aDefault;
        if (null != aList) {
            for (Long value : aList) {
                if (null != value) {
                    if (null == max) {
                        max = value;
                    } else {
                        max = Math.max(max, value);
                    }
                }
            }
        }
        return max;
    }
}

Related

  1. getMin(List numbers)
  2. getMinId(List ids)
  3. getMinimums(List data)
  4. getMinValue(List values)
  5. getMinWhitespace(final List lines)
  6. min(List values)
  7. min(List a, List b)
  8. min(List booleans)
  9. min(List data)