
package de.cosmocode.commons;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;

import javax.annotation.Nullable;

/**
 * Implementation of {@link Enums#name()}.
 *
 * @since 1.9
 * @author Willi Schoenborn
 */
enum EnumNameFunction implements Function<Enum<?>, String> {
    
    INSTANCE;
    
    @Override
    public String apply(@Nullable Enum<?> from) {
        Preconditions.checkNotNull(from, "From");
        return from.name();
    }
    
    @Override
    public String toString() {
        return "Enums.name()";
    }
    
}
