forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataPlatformUrn.java
49 lines (37 loc) · 1.46 KB
/
DataPlatformUrn.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.linkedin.common.urn;
import com.linkedin.data.template.Custom;
import com.linkedin.data.template.DirectCoercer;
import com.linkedin.data.template.TemplateOutputCastException;
import java.net.URISyntaxException;
public final class DataPlatformUrn extends Urn {
public static final String ENTITY_TYPE = "dataPlatform";
private final String platformNameEntity;
public DataPlatformUrn(String platformName) {
super(ENTITY_TYPE, platformName);
this.platformNameEntity = platformName;
}
public String getPlatformNameEntity() {
return platformNameEntity;
}
public static DataPlatformUrn createFromString(String rawUrn) throws URISyntaxException {
String platformName = new Urn(rawUrn).getContent();
return new DataPlatformUrn(platformName);
}
public static DataPlatformUrn deserialize(String rawUrn) throws URISyntaxException {
return createFromString(rawUrn);
}
static {
Custom.registerCoercer(new DirectCoercer<DataPlatformUrn>() {
public Object coerceInput(DataPlatformUrn object) throws ClassCastException {
return object.toString();
}
public DataPlatformUrn coerceOutput(Object object) throws TemplateOutputCastException {
try {
return DataPlatformUrn.createFromString((String) object);
} catch (URISyntaxException e) {
throw new TemplateOutputCastException("Invalid URN syntax: " + e.getMessage(), e);
}
}
}, DataPlatformUrn.class);
}
}