package de.retest.recheck.meta.global;

import java.util.HashMap;
import java.util.Map;

import de.retest.recheck.meta.MetadataProvider;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public final class MachineMetadataProvider implements MetadataProvider {

	private static final String WINDOWS_COMPUTER_NAME = "COMPUTERNAME";
	private static final String UNIX_HOST_NAME = "HOSTNAME";

	public static final String MACHINE_NAME = "machine.name";

	@Override
	public Map<String, String> retrieve() {
		final Map<String, String> map = new HashMap<>();

		final String machineName = retrieveMachineName();
		if ( machineName != null ) {
			map.put( MACHINE_NAME, machineName );
		}

		return map;
	}

	// Refer to https://stackoverflow.com/a/33112997 and https://stackoverflow.com/a/40702767
	private String retrieveMachineName() {
		final String computerName = System.getenv( WINDOWS_COMPUTER_NAME );
		if ( computerName != null ) {
			return computerName;
		}
		final String hostname = System.getenv( UNIX_HOST_NAME );
		if ( hostname != null ) {
			return hostname;
		}
		return null;
	}
}

@@ -82,16 +82,62 @@
 l.Map;%0A%0A
+import org.apache.commons.lang3.SystemUtils;%0A%0A
 import d
@@ -296,136 +296,8 @@
  %7B%0A%0A
-%09private static final String WINDOWS_COMPUTER_NAME = %22COMPUTERNAME%22;%0A%09private static final String UNIX_HOST_NAME = %22HOSTNAME%22;%0A%0A
 %09pub
@@ -475,37 +475,38 @@
 ing 
-machineName = retrieveMachine
+hostName = SystemUtils.getHost
 Name
@@ -516,23 +516,20 @@
 %0A%09%09if ( 
-machine
+host
 Name != 
@@ -567,431 +567,37 @@
 ME, 
-machineName );%0A%09%09%7D%0A%0A%09%09return map;%0A%09%7D%0A%0A%09// Refer to https://stackoverflow.com/a/33112997 and https://stackoverflow.com/a/40702767%0A%09private String retrieveMachineName() %7B%0A%09%09final String computerName = System.getenv( WINDOWS_COMPUTER_NAME );%0A%09%09if ( computerName != null ) %7B%0A%09%09%09return computerName;%0A%09%09%7D%0A%09%09final String hostname = System.getenv( UNIX_HOST_NAME );%0A%09%09if ( hostname != null ) %7B%0A%09%09%09return hostname;%0A%09%09%7D%0A%09%09return null
+hostName );%0A%09%09%7D%0A%0A%09%09return map
 ;%0A%09%7D

Replace method with SystemUtils#getHostName