<commit_before>package de.rennschnitzel.net;

import java.io.File;
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.common.base.Preconditions;
import com.google.common.net.HostAndPort;
import com.google.common.util.concurrent.Service;

import de.rennschnitzel.net.client.ClientSettings;
import de.rennschnitzel.net.client.ConfigFile;
import de.rennschnitzel.net.client.HomeSettings;
import de.rennschnitzel.net.client.TestFramework;
import de.rennschnitzel.net.client.connection.ConnectService;
import de.rennschnitzel.net.client.connection.LocalConnectService;
import de.rennschnitzel.net.client.connection.OnlineConnectService;
import de.rennschnitzel.net.core.Node.HomeNode;
import de.rennschnitzel.net.core.login.AuthenticationFactory;
import de.rennschnitzel.net.core.login.ClientAuthentication;
import de.rennschnitzel.net.protocol.NetworkProtocol.NodeMessage;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

public @Getter @RequiredArgsConstructor class NetClient {

	@NonNull
	private final NodeMessage.Type type;

	private boolean initialized = false;
	private boolean enabled = false;

	private Logger logger = Logger.getGlobal();
	private File directory;
	private ConfigFile<ClientSettings> configFile;

	private HomeNode home;
	private Network network;
	private ConnectService connectService;
	private ScheduledExecutorService executor;

	private TestFramework testFramework = null;

	private ClientAuthentication authentication = null;

	private HostAndPort routerAddress = null;

	private @Setter @NonNull Runnable shutdownFunction = () -> {
	};
	private @Setter @NonNull Runnable restartFunction = () -> {
	};
	private @Setter @NonNull Consumer<Runnable> syncExecutor = null;

	public synchronized void init( Logger logger, File directory, ScheduledExecutorService executor ) {
		Preconditions.checkState( initialized == false, "NetClient already initialized" );
		Preconditions.checkNotNull( logger );
		directory.mkdirs();
		Preconditions.checkArgument( directory.isDirectory() );
		Preconditions.checkNotNull( executor );
		this.logger = logger;
		this.directory = directory;
		this.executor = executor;
		if(this.syncExecutor == null) {
			this.syncExecutor = executor::execute;
		}
		this.configFile = ConfigFile.create( new File( directory, "settings.json" ), ClientSettings.class );
		saveConfigDefault();
		initialized = true;
	}

	public ClientSettings getConfig() {
		return configFile.getConfig();
	}

	public void reloadConfig() {<commit_msg>Unsupported Operation Exception when using undefined shutdown/restart<commit_after>package de.rennschnitzel.net;

import java.io.File;
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.google.common.base.Preconditions;
import com.google.common.net.HostAndPort;
import com.google.common.util.concurrent.Service;

import de.rennschnitzel.net.client.ClientSettings;
import de.rennschnitzel.net.client.ConfigFile;
import de.rennschnitzel.net.client.HomeSettings;
import de.rennschnitzel.net.client.TestFramework;
import de.rennschnitzel.net.client.connection.ConnectService;
import de.rennschnitzel.net.client.connection.LocalConnectService;
import de.rennschnitzel.net.client.connection.OnlineConnectService;
import de.rennschnitzel.net.core.Node.HomeNode;
import de.rennschnitzel.net.core.login.AuthenticationFactory;
import de.rennschnitzel.net.core.login.ClientAuthentication;
import de.rennschnitzel.net.protocol.NetworkProtocol.NodeMessage;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;

public @Getter @RequiredArgsConstructor class NetClient {

	@NonNull
	private final NodeMessage.Type type;

	private boolean initialized = false;
	private boolean enabled = false;

	private Logger logger = Logger.getGlobal();
	private File directory;
	private ConfigFile<ClientSettings> configFile;

	private HomeNode home;
	private Network network;
	private ConnectService connectService;
	private ScheduledExecutorService executor;

	private TestFramework testFramework = null;

	private ClientAuthentication authentication = null;

	private HostAndPort routerAddress = null;

	private @Setter @NonNull Runnable shutdownFunction = () -> {
		throw new UnsupportedOperationException("Shutdown not supported");
	};
	private @Setter @NonNull Runnable restartFunction = () -> {
		throw new UnsupportedOperationException("Shutdown not supported");
	};
	private @Setter @NonNull Consumer<Runnable> syncExecutor = null;

	public synchronized void init( Logger logger, File directory, ScheduledExecutorService executor ) {
		Preconditions.checkState( initialized == false, "NetClient already initialized" );
		Preconditions.checkNotNull( logger );
		directory.mkdirs();
		Preconditions.checkArgument( directory.isDirectory() );
		Preconditions.checkNotNull( executor );
		this.logger = logger;
		this.directory = directory;
		this.executor = executor;
		if(this.syncExecutor == null) {
			this.syncExecutor = executor::execute;
		}
		this.configFile = ConfigFile.create( new File( directory, "settings.json" ), ClientSettings.class );
		saveConfigDefault();
		initialized = true;
	}

	public ClientSettings getConfig() {
		return configFile.getConfig();
	}

	public void reloadConfig() {
{'fraction_non_alphanumeric': 0.0938710813666784, 'fraction_numerical': 0.0, 'mean_word_length': 6.028465346534653, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '370080', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1601, 'n_words': 362}