class BuildSessionImpl implements BuildSession {

    @NonNull
    @VisibleForTesting
    static BuildSession createBuildSessionSingleton(@NonNull String pluginVersion) {
        Object buildSessionSingleton =
                Verify.verifyNotNull(
                        new JvmWideVariable<>(
                                        BuildSessionImpl.class.getName(),
                                        BuildSessionImpl.class.getSimpleName(),
                                        pluginVersion,
                                        TypeToken.of(Object.class),
                                        BuildSessionImpl::new)
                                .get());

        if (buildSessionSingleton instanceof BuildSession) {
            return (BuildSession) buildSessionSingleton;
        } else {
            return (BuildSession)
                    Proxy.newProxyInstance(
                            BuildSession.class.getClassLoader(),
                            new Class[] {BuildSession.class},
                            new DelegateInvocationHandler(buildSessionSingleton));
        }
    }

}