public static Path decodePathFromReference(CheckpointStorageLocationReference reference) {
		if (reference.isDefaultReference()) {
			throw new IllegalArgumentException("Cannot decode default reference");
		}

		final byte[] bytes = reference.getReferenceBytes();
		final int headerLen = REFERENCE_MAGIC_NUMBER.length;

		if (bytes.length > headerLen) {
			// compare magic number
			for (int i = 0; i < headerLen; i++) {
				if (bytes[i] != REFERENCE_MAGIC_NUMBER[i]) {
					throw new IllegalArgumentException("Reference starts with the wrong magic number");
				}
			}

			// covert to string and path
			try {
				return new Path(new String(bytes, headerLen, bytes.length - headerLen, StandardCharsets.UTF_8));
			}
			catch (Exception e) {
				throw new IllegalArgumentException("Reference cannot be decoded to a path", e);
			}
		}
		else {
			throw new IllegalArgumentException("Reference too short.");
		}
	}
public static Path decodePathFromReference ( CheckpointStorageLocationReference reference ) { if ( reference . isDefaultReference ( ) ) { throw new IllegalArgumentException ( "Cannot decode default reference" ) ; } final byte [ ] bytes = reference . getReferenceBytes ( ) ; final int headerLen = REFERENCE_MAGIC_NUMBER . length ; if ( bytes . length > headerLen ) { for ( int i = 0 ; i < headerLen ; i ++ ) { if ( bytes [ i ] != REFERENCE_MAGIC_NUMBER [ i ] ) { throw new IllegalArgumentException ( "Reference starts with the wrong magic number" ) ; } } try { return new Path ( new String ( bytes , headerLen , bytes . length - headerLen , StandardCharsets . UTF_8 ) ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Reference cannot be decoded to a path" , e ) ; } } else { throw new IllegalArgumentException ( "Reference too short." ) ; } }
Decodes the given reference into a path. This method validates that the reference bytes start with
the correct magic number (as written by {@link #encodePathAsReference(Path)}) and converts
the remaining bytes back to a proper path.

@param reference The bytes representing the reference.
@return The path decoded from the reference.

@throws IllegalArgumentException Thrown, if the bytes do not represent a proper reference.