1. Update to just keep several line JAVA related msg; 2. Remove file PropertyManager...
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / id / Identification.java
1 /** @file
2 This file is to define Identification class.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13
14 package org.tianocore.build.id;
15
16
17 /**
18 This class is used to identify with its GUID and Version.
19
20 @since GenBuild 1.0
21 **/
22 public class Identification {
23
24 String name;
25
26 String guid;
27
28 String version;
29
30 /**
31 @param name Name
32 @param guid Guid
33 @param version Version
34 **/
35 Identification(String name, String guid, String version){
36 this.name = name;
37 this.guid = guid;
38 this.version = version;
39 }
40
41 /**
42 @param guid Guid
43 @param version Version
44 **/
45 Identification(String guid, String version){
46 this.guid = guid;
47 this.version = version;
48 }
49
50 /* (non-Javadoc)
51 @see java.lang.Object#equals(java.lang.Object)
52 **/
53 public boolean equals(Object obj) {
54 if (obj instanceof Identification) {
55 Identification id = (Identification)obj;
56 if ( guid.equalsIgnoreCase(id.guid)) {
57 if (version == null || id.version == null) {
58 return true;
59 }
60 else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){
61 return true;
62 }
63 else if (version.equalsIgnoreCase(id.version)) {
64 return true;
65 }
66 }
67 return false;
68 }
69 else {
70 return super.equals(obj);
71 }
72 }
73
74 /**
75 @param name Name
76 **/
77 public void setName(String name) {
78 this.name = name;
79 }
80
81 /**
82 @param guid Guid
83 **/
84 public void setGuid(String guid) {
85 this.guid = guid;
86 }
87
88 /**
89 @param version Version
90 **/
91 public void setVersion(String version) {
92 this.version = version;
93 }
94
95 public String getGuid() {
96 return guid;
97 }
98
99 /**
100 @return String Name
101 **/
102 public String getName() {
103 return name;
104 }
105
106 /**
107 @return String Version
108 **/
109 public String getVersion() {
110 return version;
111 }
112
113 public String toGuidString() {
114 if (version == null || version.trim().equalsIgnoreCase("")) {
115 return "[" + guid + "]";
116 }
117 else {
118 return "[" + guid + "] and version [" + version + "]";
119 }
120 }
121
122 /* (non-Javadoc)
123 @see java.lang.Object#hashCode()
124 **/
125 public int hashCode(){
126 return guid.toLowerCase().hashCode();
127 }
128 }