]>
Commit | Line | Data |
---|---|---|
a29c47e0 | 1 | package org.tianocore.build.id;\r |
2 | \r | |
3 | import java.io.File;\r | |
4 | \r | |
5 | import org.tianocore.build.global.GlobalData;\r | |
6 | \r | |
7 | public class ModuleIdentification extends Identification {\r | |
8 | \r | |
9 | private PackageIdentification packageId;\r | |
10 | \r | |
11 | private File msaFile;\r | |
12 | \r | |
13 | private String moduleType;\r | |
14 | \r | |
15 | private boolean isLibrary = false;\r | |
16 | \r | |
17 | public ModuleIdentification(String guid, String version){\r | |
18 | super(guid, version);\r | |
19 | }\r | |
20 | \r | |
21 | public ModuleIdentification(String guid, String version, PackageIdentification packageId){\r | |
22 | super(guid, version);\r | |
23 | this.packageId = packageId;\r | |
24 | }\r | |
25 | \r | |
26 | public ModuleIdentification(String name, String guid, String version){\r | |
27 | super(name, guid, version);\r | |
28 | }\r | |
29 | \r | |
30 | public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){\r | |
31 | super(name, guid, version);\r | |
32 | this.packageId = packageId;\r | |
33 | }\r | |
34 | \r | |
35 | public boolean isLibrary() {\r | |
36 | return isLibrary;\r | |
37 | }\r | |
38 | \r | |
39 | public void setLibrary(boolean isLibrary) {\r | |
40 | this.isLibrary = isLibrary;\r | |
41 | }\r | |
42 | \r | |
43 | public File getMsaFile() {\r | |
44 | prepareMsaFile();\r | |
45 | return msaFile;\r | |
46 | }\r | |
47 | \r | |
48 | public String getModuleRelativePath() {\r | |
49 | prepareMsaFile();\r | |
50 | if (msaFile.getParent().length() == packageId.getPackageDir().length()) {\r | |
51 | return ".";\r | |
52 | }\r | |
53 | return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);\r | |
54 | }\r | |
55 | \r | |
56 | private void prepareMsaFile(){\r | |
57 | if (msaFile == null) {\r | |
58 | GlobalData.refreshModuleIdentification(this);\r | |
59 | }\r | |
60 | }\r | |
61 | \r | |
62 | public void setMsaFile(File msaFile) {\r | |
63 | this.msaFile = msaFile;\r | |
64 | }\r | |
65 | \r | |
66 | public boolean equals(Object obj) {\r | |
67 | if (obj instanceof ModuleIdentification) {\r | |
68 | ModuleIdentification id = (ModuleIdentification)obj;\r | |
69 | if (guid.equalsIgnoreCase(id.getGuid()) && packageId.equals(id.getPackage())) {\r | |
70 | if (version == null || id.version == null) {\r | |
71 | return true;\r | |
72 | }\r | |
73 | else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){\r | |
74 | return true;\r | |
75 | }\r | |
76 | else if (version.equalsIgnoreCase(id.version)) {\r | |
77 | return true;\r | |
78 | }\r | |
79 | }\r | |
80 | return false;\r | |
81 | }\r | |
82 | else {\r | |
83 | return super.equals(obj);\r | |
84 | }\r | |
85 | }\r | |
86 | \r | |
87 | public String toString(){\r | |
88 | if (name == null) {\r | |
89 | GlobalData.refreshModuleIdentification(this);\r | |
90 | }\r | |
91 | if (version == null || version.trim().equalsIgnoreCase("")) {\r | |
92 | return "Module [" + name + "] in " + packageId;\r | |
93 | }\r | |
94 | else {\r | |
95 | return "Module [" + name + " " + version + "] in " + packageId; \r | |
96 | }\r | |
97 | }\r | |
98 | \r | |
99 | public void setPackage(PackageIdentification packageId) {\r | |
100 | this.packageId = packageId;\r | |
101 | }\r | |
102 | \r | |
103 | public PackageIdentification getPackage() {\r | |
104 | return packageId;\r | |
105 | }\r | |
106 | \r | |
107 | public String getModuleType() {\r | |
108 | if (moduleType == null) {\r | |
109 | GlobalData.refreshModuleIdentification(this);\r | |
110 | }\r | |
111 | return moduleType;\r | |
112 | }\r | |
113 | \r | |
114 | public void setModuleType(String moduleType) {\r | |
115 | this.moduleType = moduleType;\r | |
116 | }\r | |
117 | \r | |
118 | public String getName() {\r | |
119 | if (name == null) {\r | |
120 | GlobalData.refreshModuleIdentification(this);\r | |
121 | }\r | |
122 | return name;\r | |
123 | }\r | |
124 | }\r |