// Copyright (c) 1998-2008 Adrian Kuhn <akuhn(a)students.unibe.ch> // // This file is part of ch.akuhn.util. // // ch.akuhn.util is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by the // Free Software Foundation, either version 3 of the License, or (at your // option) any later version. // // ch.akuhn.util is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public // License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with ch.akuhn.util. If not, see <http://www.gnu.org/licenses/>. // package ch.akuhn.util; /** * Methods for static import. * * @author Adrian Kuhn * */ @SuppressWarnings("unchecked") public abstract class Extensions { // private final static Object NONE = new Object(); public static Class<?> leastUpperBound(Class<?> initial, Object... os) { Class $ = initial; for (Object o : os) { while (!$.isAssignableFrom(o.getClass())) { $ = $.getSuperclass(); if ($ == null) return Object.class; } } return $; } private Extensions() { throw new AssertionError(); } }