Skip to content

Commit 0a1c9e9

Browse files
authored
Merge pull request #485 from oracle/fix_domain_beans
Fix domain beans
2 parents 018c6c8 + b6e9286 commit 0a1c9e9

File tree

6 files changed

+173
-0
lines changed

6 files changed

+173
-0
lines changed

model/src/main/java/oracle/kubernetes/weblogic/domain/v1/DomainSpec.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ public int hashCode() {
879879
builder.append(imagePullSecrets).append(adminServer).append(managedServers).append(clusters);
880880
else
881881
builder
882+
.append(imagePullSecret)
882883
.append(replicas)
883884
.append(startupControl)
884885
.append(clusterStartup)
@@ -915,6 +916,7 @@ public boolean equals(Object other) {
915916
.append(clusters, rhs.clusters);
916917
else
917918
builder
919+
.append(imagePullSecret, rhs.imagePullSecret)
918920
.append(replicas, rhs.replicas)
919921
.append(startupControl, rhs.startupControl)
920922
.append(clusterStartup, rhs.clusterStartup)

model/src/main/java/oracle/kubernetes/weblogic/domain/v1/ServerSpec.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import java.util.Optional;
2424
import javax.annotation.Nonnull;
2525
import oracle.kubernetes.operator.KubernetesConstants;
26+
import org.apache.commons.lang3.builder.EqualsBuilder;
27+
import org.apache.commons.lang3.builder.HashCodeBuilder;
28+
import org.apache.commons.lang3.builder.ToStringBuilder;
2629

2730
/** Represents the effective configuration for a server, as seen by the operator runtime. */
2831
@SuppressWarnings("WeakerAccess")
@@ -184,4 +187,27 @@ public V1PodSecurityContext getPodSecurityContext() {
184187
public V1SecurityContext getContainerSecurityContext() {
185188
return null;
186189
}
190+
191+
@Override
192+
public String toString() {
193+
return new ToStringBuilder(this).append("domainSpec", domainSpec).toString();
194+
}
195+
196+
@Override
197+
public boolean equals(Object o) {
198+
if (this == o) return true;
199+
200+
if (o == null || getClass() != o.getClass()) return false;
201+
202+
if (!(o instanceof ServerSpec)) return false;
203+
204+
ServerSpec that = (ServerSpec) o;
205+
206+
return new EqualsBuilder().append(domainSpec, that.domainSpec).isEquals();
207+
}
208+
209+
@Override
210+
public int hashCode() {
211+
return new HashCodeBuilder(17, 37).append(domainSpec).toHashCode();
212+
}
187213
}

model/src/main/java/oracle/kubernetes/weblogic/domain/v1/ServerSpecV1Impl.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import java.util.Collections;
1313
import java.util.List;
1414
import java.util.Optional;
15+
import org.apache.commons.lang3.builder.EqualsBuilder;
16+
import org.apache.commons.lang3.builder.HashCodeBuilder;
17+
import org.apache.commons.lang3.builder.ToStringBuilder;
1518

1619
/** The effective configuration for a server configured by the version 1 domain model. */
1720
public class ServerSpecV1Impl extends ServerSpec {
@@ -80,4 +83,41 @@ private int getReplicaCount() {
8083
private boolean isSpecified() {
8184
return serverStartup != null || clusterStartup != null;
8285
}
86+
87+
@Override
88+
public String toString() {
89+
return new ToStringBuilder(this)
90+
.appendSuper(super.toString())
91+
.append("clusterName", clusterName)
92+
.append("serverStartup", serverStartup)
93+
.append("clusterStartup", clusterStartup)
94+
.toString();
95+
}
96+
97+
@Override
98+
public int hashCode() {
99+
return new HashCodeBuilder()
100+
.appendSuper(super.hashCode())
101+
.append(clusterName)
102+
.append(serverStartup)
103+
.append(clusterStartup)
104+
.toHashCode();
105+
}
106+
107+
@Override
108+
public boolean equals(Object other) {
109+
if (other == this) {
110+
return true;
111+
}
112+
if ((other instanceof ServerSpecV1Impl) == false) {
113+
return false;
114+
}
115+
ServerSpecV1Impl rhs = ((ServerSpecV1Impl) other);
116+
return new EqualsBuilder()
117+
.appendSuper(super.equals(rhs))
118+
.append(clusterName, rhs.clusterName)
119+
.append(serverStartup, rhs.serverStartup)
120+
.append(clusterStartup, rhs.clusterStartup)
121+
.isEquals();
122+
}
83123
}

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/ManagedServer.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import com.google.gson.annotations.Expose;
88
import com.google.gson.annotations.SerializedName;
99
import javax.annotation.Nonnull;
10+
import org.apache.commons.lang3.builder.EqualsBuilder;
11+
import org.apache.commons.lang3.builder.HashCodeBuilder;
12+
import org.apache.commons.lang3.builder.ToStringBuilder;
1013

1114
public class ManagedServer extends Server {
1215
/** The name of the managed server. Required. */
@@ -26,4 +29,36 @@ ManagedServer withServerName(@Nonnull String serverName) {
2629
setServerName(serverName);
2730
return this;
2831
}
32+
33+
@Override
34+
public String toString() {
35+
return new ToStringBuilder(this)
36+
.appendSuper(super.toString())
37+
.append("serverName", serverName)
38+
.toString();
39+
}
40+
41+
@Override
42+
public boolean equals(Object o) {
43+
if (this == o) return true;
44+
45+
if (o == null || getClass() != o.getClass()) return false;
46+
47+
if (!(o instanceof ManagedServer)) return false;
48+
49+
ManagedServer that = (ManagedServer) o;
50+
51+
return new EqualsBuilder()
52+
.appendSuper(super.equals(o))
53+
.append(serverName, that.serverName)
54+
.isEquals();
55+
}
56+
57+
@Override
58+
public int hashCode() {
59+
return new HashCodeBuilder(17, 37)
60+
.appendSuper(super.hashCode())
61+
.append(serverName)
62+
.toHashCode();
63+
}
2964
}

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/Server.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import com.google.gson.annotations.Expose;
88
import com.google.gson.annotations.SerializedName;
9+
import org.apache.commons.lang3.builder.EqualsBuilder;
10+
import org.apache.commons.lang3.builder.HashCodeBuilder;
11+
import org.apache.commons.lang3.builder.ToStringBuilder;
912

1013
public class Server extends BaseConfiguration {
1114
/** The node port associated with this server. The introspector will override this value. */
@@ -27,4 +30,33 @@ public void setNodePort(Integer nodePort) {
2730
public Integer getNodePort() {
2831
return nodePort;
2932
}
33+
34+
@Override
35+
public String toString() {
36+
return new ToStringBuilder(this)
37+
.appendSuper(super.toString())
38+
.append("nodePort", nodePort)
39+
.toString();
40+
}
41+
42+
@Override
43+
public boolean equals(Object o) {
44+
if (this == o) return true;
45+
46+
if (o == null || getClass() != o.getClass()) return false;
47+
48+
if (!(o instanceof Server)) return false;
49+
50+
Server that = (Server) o;
51+
52+
return new EqualsBuilder()
53+
.appendSuper(super.equals(o))
54+
.append(nodePort, that.nodePort)
55+
.isEquals();
56+
}
57+
58+
@Override
59+
public int hashCode() {
60+
return new HashCodeBuilder(17, 37).appendSuper(super.hashCode()).append(nodePort).toHashCode();
61+
}
3062
}

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/ServerSpecV2Impl.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import javax.annotation.Nonnull;
1616
import oracle.kubernetes.weblogic.domain.v1.DomainSpec;
1717
import oracle.kubernetes.weblogic.domain.v1.ServerSpec;
18+
import org.apache.commons.lang3.builder.EqualsBuilder;
19+
import org.apache.commons.lang3.builder.HashCodeBuilder;
20+
import org.apache.commons.lang3.builder.ToStringBuilder;
1821

1922
/** The effective configuration for a server configured by the version 2 domain model. */
2023
public abstract class ServerSpecV2Impl extends ServerSpec {
@@ -94,4 +97,39 @@ public V1Probe getLivenessProbe() {
9497
public V1Probe getReadinessProbe() {
9598
return server.getReadinessProbe();
9699
}
100+
101+
@Override
102+
public String toString() {
103+
return new ToStringBuilder(this)
104+
.appendSuper(super.toString())
105+
.append("server", server)
106+
.append("clusterLimit", clusterLimit)
107+
.toString();
108+
}
109+
110+
@Override
111+
public boolean equals(Object o) {
112+
if (this == o) return true;
113+
114+
if (o == null || getClass() != o.getClass()) return false;
115+
116+
if (!(o instanceof ServerSpecV2Impl)) return false;
117+
118+
ServerSpecV2Impl that = (ServerSpecV2Impl) o;
119+
120+
return new EqualsBuilder()
121+
.appendSuper(super.equals(o))
122+
.append(server, that.server)
123+
.append(clusterLimit, that.clusterLimit)
124+
.isEquals();
125+
}
126+
127+
@Override
128+
public int hashCode() {
129+
return new HashCodeBuilder(17, 37)
130+
.appendSuper(super.hashCode())
131+
.append(server)
132+
.append(clusterLimit)
133+
.toHashCode();
134+
}
97135
}

0 commit comments

Comments
 (0)