diff options
author | Jim Hahn <jrh3@att.com> | 2021-08-03 14:08:09 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-08-06 15:14:31 -0400 |
commit | 0ed6c16727aa92c93965a7da756536b113b262c8 (patch) | |
tree | f7961bccd0db40a9f9985a5936381f183432235c /core/core-protocols/src | |
parent | 9344ec1396b7151262e9b4ac48c72020e2b03e7e (diff) |
Use lombok for apex-pdp #7
Updated thru core-protocols.
Issue-ID: POLICY-3391
Change-Id: I2226fee16b276eba5c7f3fd1921a6cef36654f07
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'core/core-protocols/src')
2 files changed, 17 insertions, 92 deletions
diff --git a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java index b79308e4a..005c181a0 100644 --- a/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java +++ b/core/core-protocols/src/main/java/org/onap/policy/apex/core/protocols/Message.java @@ -22,6 +22,11 @@ package org.onap.policy.apex.core.protocols; import java.io.Serializable; +import lombok.AccessLevel; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; /** @@ -29,8 +34,10 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; * * @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com) */ +@Getter +@ToString +@EqualsAndHashCode public abstract class Message implements Serializable { - private static final int HASH_PRIME = 31; // Serialization ID private static final long serialVersionUID = 2271443377544488309L; @@ -42,12 +49,17 @@ public abstract class Message implements Serializable { private Action action = null; // The artifact key of the artifact to which this message is related + @Getter(AccessLevel.NONE) private AxArtifactKey targetKey = null; // The data of the message + @Setter private String messageData = null; // The timeout time for replies in milliseconds + @Setter + @ToString.Exclude + @EqualsAndHashCode.Exclude private int replyTimeout = DEFAULT_REPLY_TIMEOUT; /** @@ -74,24 +86,6 @@ public abstract class Message implements Serializable { } /** - * Set the message timeout. - * - * @param replyTimeout the timeout on reply messages in milliseconds - */ - public void setReplyTimeout(final int replyTimeout) { - this.replyTimeout = replyTimeout; - } - - /** - * Sets the message data. - * - * @param messageData the new message data - */ - public void setMessageData(final String messageData) { - this.messageData = messageData; - } - - /** * Append to the message data. * * @param newMessageData the message data @@ -121,74 +115,4 @@ public abstract class Message implements Serializable { public final String getTargetName() { return targetKey.getName(); } - - /** - * Gets the action or message type of this message. - * - * @return the action - */ - public final Action getAction() { - return action; - } - - /** - * Gets the message data. - * - * @return the message data - */ - public final String getMessageData() { - return messageData; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object object) { - if (this == object) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - - final Message message = (Message) object; - - if (action != null ? !action.equals(message.action) : message.action != null) { - return false; - } - if (targetKey != null ? !targetKey.equals(message.targetKey) : message.targetKey != null) { - return false; - } - return !(messageData != null ? !messageData.equals(message.messageData) : message.messageData != null); - - } - - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - int result = action != null ? action.hashCode() : 0; - result = HASH_PRIME * result + (targetKey != null ? targetKey.hashCode() : 0); - result = HASH_PRIME * result + (messageData != null ? messageData.hashCode() : 0); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "Message [action=" + action + ", targetKey=" + targetKey + ", data=" + messageData + "]"; - } - - /** - * Get the timeout to wait for a reply. - * - * @return the timeout in milliseconds - */ - public int getReplyTimeout() { - return replyTimeout; - } } diff --git a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java index 1f8ccabb1..f275f4b79 100644 --- a/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java +++ b/core/core-protocols/src/test/java/org/onap/policy/apex/core/protocols/SupportMessageTester.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,8 +41,8 @@ public class SupportMessageTester { DummyMessage dummyMessage = new DummyMessage(new DummyAction(null), new AxArtifactKey("Target:0.0.1")); assertEquals(new DummyAction(null), dummyMessage.getAction()); - assertEquals("Message [action=org.onap.policy.apex.core.protocols.DummyAction@1f, " - + "targetKey=AxArtifactKey:(name=Target,version=0.0.1), data=null]", dummyMessage.toString()); + assertEquals("Message(action=org.onap.policy.apex.core.protocols.DummyAction@1f, " + + "targetKey=AxArtifactKey:(name=Target,version=0.0.1), messageData=null)", dummyMessage.toString()); dummyMessage.setMessageData("Message Data"); assertEquals("Message Data", dummyMessage.getMessageData()); @@ -60,7 +61,7 @@ public class SupportMessageTester { dummyMessage.setMessageData(null); assertNotEquals(0, dummyMessage.hashCode()); dummyMessage = new DummyMessage(null, null, null); - assertEquals(0, dummyMessage.hashCode()); + assertNotEquals(0, dummyMessage.hashCode()); // disabling sonar because this code tests the equals() method assertEquals(dummyMessage, dummyMessage); // NOSONAR |