Java Array Max Value max(final T p_enum1, final T p_enum2, final T[] enumValues)

Here you can find the source of max(final T p_enum1, final T p_enum2, final T[] enumValues)

Description

max

License

Open Source License

Declaration

public static <T extends Enum<T>> T max(final T p_enum1, final T p_enum2, final T[] enumValues) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 Lab-STICC Universite de Bretagne Sud, Lorient.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the CeCILL-B license available
 * at ://  w w  w .  ja va 2s  .  c o m
 * en : http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 * fr : http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.html
 * 
 * Contributors:
 * Dominique BLOUIN (Lab-STICC UBS), dominique.blouin@univ-ubs.fr
 ******************************************************************************/

public class Main {
    public static <T extends Enum<T>> T max(final T p_enum1, final T p_enum2, final T[] enumValues) {
        if (p_enum1 == null) {
            return p_enum2;
        }

        if (p_enum2 == null) {
            return p_enum1;
        }

        return enumValues[Math.max(p_enum1.ordinal(), p_enum2.ordinal())];
    }
}

Related

  1. max(final int[] result, final int[] vec1, final int[] vec2)
  2. max(final int[] values)
  3. max(final int[] values)
  4. max(final long[] longs)
  5. max(final Number... numbers)
  6. max(final T... elements)
  7. max(float... a)
  8. max(float... fs)
  9. max(float... fs)