Skip to content

Commit 5e0d11a

Browse files
committed
Add mapping for NSUUID.
1 parent 0475321 commit 5e0d11a

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package ch.cyberduck.binding.foundation;
2+
3+
/*
4+
* Copyright (c) 2002-2025 iterate GmbH. All rights reserved.
5+
* https://cyberduck.io/
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*/
17+
18+
import org.rococoa.ObjCClass;
19+
20+
/**
21+
* A universally unique value that can be used to identify types, interfaces, and other items.
22+
*/
23+
public abstract class NSUUID extends NSObject {
24+
private static final NSUUID._Class CLASS = org.rococoa.Rococoa.createClass("NSUUID", NSUUID._Class.class);
25+
26+
public static NSUUID UUID() {
27+
return CLASS.UUID();
28+
}
29+
30+
public static NSUUID UUID(final String string) {
31+
return CLASS.alloc().initWithUUIDString(string);
32+
}
33+
34+
public interface _Class extends ObjCClass {
35+
NSUUID UUID();
36+
37+
NSUUID alloc();
38+
}
39+
40+
/**
41+
* @param string The source string containing the UUID. The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067.
42+
*/
43+
public abstract NSUUID initWithUUIDString(String string);
44+
45+
public abstract String UUIDString();
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package ch.cyberduck.binding.foundation;
2+
3+
/*
4+
* Copyright (c) 2002-2025 iterate GmbH. All rights reserved.
5+
* https://cyberduck.io/
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*/
17+
18+
import ch.cyberduck.core.library.Native;
19+
20+
import org.junit.Test;
21+
22+
import static org.junit.Assert.assertEquals;
23+
import static org.junit.Assert.assertNotNull;
24+
25+
public class NSUUIDTest {
26+
27+
static {
28+
Native.load("core");
29+
}
30+
31+
@Test
32+
public void testUUIDString() {
33+
final NSUUID uuid = NSUUID.UUID();
34+
assertNotNull(uuid);
35+
assertNotNull(uuid.UUIDString());
36+
}
37+
38+
@Test
39+
public void testCustom() {
40+
final NSUUID uuid = NSUUID.UUID("DDB85013-288D-4870-91F1-5DD193079E9E");
41+
assertNotNull(uuid);
42+
assertEquals("DDB85013-288D-4870-91F1-5DD193079E9E", uuid.UUIDString());
43+
}
44+
}

0 commit comments

Comments
 (0)