All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.softicar.platform.common.core.uuid.Uuids Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.core.uuid;

import com.softicar.platform.common.core.utils.DevNull;
import java.util.Optional;
import java.util.UUID;

/**
 * Utility methods for {@link UUID}.
 *
 * @author Oliver Richers
 */
public class Uuids {

	public static boolean isUuid(String uuidString) {

		try {
			if (uuidString != null) {
				UUID uuid = UUID.fromString(uuidString);
				return uuid.toString().equalsIgnoreCase(uuidString);
			} else {
				return false;
			}
		} catch (IllegalArgumentException exception) {
			DevNull.swallow(exception);
			return false;
		}
	}

	public static Optional parseUuid(String uuidString) {

		UUID uuid = null;
		try {
			uuid = UUID.fromString(uuidString);
		} catch (IllegalArgumentException exception) {
			DevNull.swallow(exception);
		}
		return Optional.ofNullable(uuid);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy