/*
 * Copyright (c) 2004-2017, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package lc.mecha.util;

/**
 * Utilities for interacting with classes.
 *
 * @author Alex Leigh
 */
public final class ClassUtil {
    /**
     * For the provided class, return a string identifying the package that this
     * class resides in. This method always returns a string.
     *
     * @param c
     * @return
     */
    public static String getPackageName(final Class<?> c) {
        final String packageName = c.getName();
        final int index = packageName.lastIndexOf(".");
        if (index > -1) {
            return packageName.substring(0, index + 1);
        }

        return "";
    }
}
