This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
/
Patch.java
124 lines (107 loc) · 3.34 KB
/
Patch.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* RHQ Management Platform
* Copyright (C) 2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.common.wildfly;
/**
* Contains the metadata about a Wildfly patch.
*
* @author Lukas Krejci
* @since 4.13
*/
public final class Patch {
public enum Type {
ONE_OFF, CUMULATIVE;
@Override
public String toString() {
switch (this) {
case ONE_OFF:
return "one-off";
case CUMULATIVE:
return "cumulative";
default:
throw new AssertionError("toString() of Patch.Type inconsistent with its definition.");
}
}
}
private final String id;
private final Type type;
private final String identityName;
private final PatchProductType productType;
private final String targetVersion;
private final String description;
private final String contents;
public Patch(String id, Type type, String identityName, String targetVersion, String description, String contents) {
this.id = id;
this.type = type;
this.identityName = identityName;
this.productType = PatchProductType.getValueByProductName(identityName);
this.targetVersion = targetVersion;
this.description = description;
this.contents = contents;
}
public String getId() {
return id;
}
public Type getType() {
return type;
}
public String getIdentityName() {
return identityName;
}
public String getTargetVersion() {
return targetVersion;
}
public String getDescription() {
return description;
}
public String getContents() {
return contents;
}
public PatchProductType getProductType() {
return productType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Patch)) {
return false;
}
Patch patch = (Patch) o;
if (id != null ? !id.equals(patch.id) : patch.id != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
return id != null ? id.hashCode() : 0;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("Patch[");
sb.append("description='").append(description).append('\'');
sb.append(", id='").append(id).append('\'');
sb.append(", identityName='").append(identityName).append('\'');
sb.append(", targetVersion='").append(targetVersion).append('\'');
sb.append(", type=").append(type);
sb.append(']');
return sb.toString();
}
}