Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Mocks the test coverage for enums that generate the values and valueOf methods. This
     * is needed to get 100% on code coverage with Jacoco on those methods that are created synthetically.
     *
     * @param enumClass The enum class to partially test cover.
     */
    public static void shallowEnumCodeCoverage(Class<? extends Enum<?>> enumClass) {
        try {
            for (Object object : (Object[]) enumClass.getMethod("values").invoke(null)) {
                enumClass.getMethod("valueOf", String.class).invoke(null, object.toString());
            }
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }
}