test_class.file: bundles/org.openhab.core.id/src/test/java/org/openhab/core/id/InstanceUUIDTest.java
test_class.identifier: InstanceUUIDTest
test_case.body: @Test
      public void ignoreEmptyFile() throws IOException {
          // we first need to remove the cached value
          InstanceUUID.uuid = null;
          Path path = Paths.get(OpenHAB.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
          Files.createDirectories(path.getParent());
          Files.write(path, "".getBytes());
          String uuid = InstanceUUID.get();
          assertNotEquals("", uuid);
      }
test_case.class_method_signature: InstanceUUIDTest.ignoreEmptyFile()
test_case.full_signature: @Test public void ignoreEmptyFile()
test_case.identifier: ignoreEmptyFile
test_case.invocations: get getUserDataFolder createDirectories getParent write getBytes get assertNotEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void ignoreEmptyFile()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(InstanceUUID.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(InstanceUUID.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: UUID_FILE_NAME = "uuid"
focal_class.modifier: static final
focal_class.original_string: static final String UUID_FILE_NAME = "uuid";
focal_class.type: String
focal_class.var_name: UUID_FILE_NAME
focal_class.declarator: uuid
focal_class.modifier: static
focal_class.original_string: static String uuid;
focal_class.type: String
focal_class.var_name: uuid
focal_class.file: bundles/org.openhab.core.id/src/main/java/org/openhab/core/id/InstanceUUID.java
focal_class.identifier: InstanceUUID
focal_class.class_method_signature: InstanceUUID.get()
focal_class.full_signature: public static synchronized String get()
focal_class.identifier: get
focal_class.modifiers: public static synchronized
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String get()
focal_class.class_method_signature: InstanceUUID.writeFile(File file, String content)
focal_class.full_signature: private static void writeFile(File file, String content)
focal_class.identifier: writeFile
focal_class.modifiers: private static
focal_class.parameters: (File file, String content)
focal_class.return: void
focal_class.signature: void writeFile(File file, String content)
focal_class.class_method_signature: InstanceUUID.readFirstLine(File file)
focal_class.full_signature: private static String readFirstLine(File file)
focal_class.identifier: readFirstLine
focal_class.modifiers: private static
focal_class.parameters: (File file)
focal_class.return: String
focal_class.signature: String readFirstLine(File file)
focal_method.body: public static synchronized String get() {
          if (uuid == null) {
              try {
                  File file = new File(OpenHAB.getUserDataFolder() + File.separator + UUID_FILE_NAME);
                  if (!file.exists()) {
                      uuid = java.util.UUID.randomUUID().toString();
                      writeFile(file, uuid);
                  } else {
                      uuid = readFirstLine(file);
                      if (uuid != null && !uuid.isEmpty()) {
                          LOGGER.debug("UUID '{}' has been restored from file '{}'", file.getAbsolutePath(), uuid);
                      } else {
                          uuid = java.util.UUID.randomUUID().toString();
                          LOGGER.warn("UUID file '{}' has no content, rewriting it now with '{}'", file.getAbsolutePath(),
                                  uuid);
                          writeFile(file, uuid);
                      }
                  }
              } catch (IOException e) {
                  LOGGER.error("Failed writing the UUID file: {}", e.getMessage());
                  return null;
              }
          }
          return uuid;
      }
focal_method.class_method_signature: InstanceUUID.get()
focal_method.full_signature: public static synchronized String get()
focal_method.identifier: get
focal_method.invocations: getUserDataFolder exists toString randomUUID writeFile readFirstLine isEmpty debug getAbsolutePath toString randomUUID warn getAbsolutePath writeFile error getMessage
focal_method.modifiers: public static synchronized
focal_method.parameters: ()
focal_method.return: String
focal_method.signature: String get()