Skip to content

Commit

Permalink
Merge pull request #192 from vpavic/remove-lombok
Browse files Browse the repository at this point in the history
Remove Lombok
  • Loading branch information
ziyanli-amazon authored Mar 23, 2023
2 parents 3c900f7 + 318e876 commit d98f1b7
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 30 deletions.
12 changes: 0 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
</properties>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>sqs</artifactId>
Expand Down Expand Up @@ -109,13 +104,6 @@
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@

import jakarta.jms.Destination;
import jakarta.jms.Queue;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

/**
* A SQSQueueDestination object encapsulates a queue name and SQS specific queue
* URL. This is the way a client specifies the identity of a queue to JMS API
* methods.
*/
@Getter
@ToString(exclude = {"isFifo"})
@EqualsAndHashCode
public class SQSQueueDestination implements Destination, Queue {

private final String queueName;
Expand All @@ -41,4 +35,60 @@ public class SQSQueueDestination implements Destination, Queue {
this.queueUrl = queueUrl;
this.isFifo = this.queueName.endsWith(".fifo");
}

/**
* Returns the name of this queue.
*
* @return queueName
*/
@Override
public String getQueueName() {
return this.queueName;
}

/**
* Returns the queueUrl of this queue.
*
* @return queueUrl
*/
public String getQueueUrl() {
return this.queueUrl;
}

public boolean isFifo() {
return this.isFifo;
}

@Override
public String toString() {
return "SQSDestination [queueName=" + queueName + ", queueUrl=" + queueUrl + "]";
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((queueName == null) ? 0 : queueName.hashCode());
result = prime * result + ((queueUrl == null) ? 0 : queueUrl.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SQSQueueDestination other = (SQSQueueDestination) obj;
if (queueName == null) {
if (other.queueName != null)
return false;
} else if (!queueName.equals(other.queueName))
return false;
if (queueUrl == null) {
return other.queueUrl == null;
} else return queueUrl.equals(other.queueUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,19 @@

import com.amazon.sqs.javamessaging.message.SQSMessage;
import jakarta.jms.JMSException;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

/**
* Identifies an SQS message, when (negative)acknowledging the message
*/
@ToString(onlyExplicitlyIncluded = true)
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Getter
public class SQSMessageIdentifier {

// The queueUrl where the message was sent or received from
@ToString.Include
@EqualsAndHashCode.Include
private final String queueUrl;

// The receipt handle returned after the delivery of the message from SQS
@ToString.Include
@EqualsAndHashCode.Include
private final String receiptHandle;

// The SQS message id assigned on send.
@ToString.Include
@EqualsAndHashCode.Include
private final String sqsMessageId;

// The group id to which the message belongs
Expand All @@ -63,4 +51,81 @@ public SQSMessageIdentifier(String queueUrl, String receiptHandle, String sqsMes
public static SQSMessageIdentifier fromSQSMessage(SQSMessage sqsMessage) throws JMSException {
return new SQSMessageIdentifier(sqsMessage.getQueueUrl(), sqsMessage.getReceiptHandle(), sqsMessage.getSQSMessageId(), sqsMessage.getSQSMessageGroupId());
}

/**
* Returns the queueUrl where the message was sent or received from.
*
* @return queueUrl
*/
public String getQueueUrl() {
return this.queueUrl;
}

/**
* Returns the receipt handle returned after the delivery of the message
* from SQS.
*
* @return receiptHandle
*/
public String getReceiptHandle() {
return this.receiptHandle;
}

/**
* Returns the SQS message id assigned on send.
*
* @return sqsMessageId
*/
public String getSQSMessageID() {
return this.sqsMessageId;
}

/**
* Returns the group id to which the message belongs. Non-null only for messages received from FIFO queues.
*
* @return groupId
*/
public String getGroupId() {
return this.groupId;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((queueUrl == null) ? 0 : queueUrl.hashCode());
result = prime * result + ((receiptHandle == null) ? 0 : receiptHandle.hashCode());
result = prime * result + ((sqsMessageId == null) ? 0 : sqsMessageId.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SQSMessageIdentifier other = (SQSMessageIdentifier) obj;
if (queueUrl == null) {
if (other.queueUrl != null)
return false;
} else if (!queueUrl.equals(other.queueUrl))
return false;
if (receiptHandle == null) {
if (other.receiptHandle != null)
return false;
} else if (!receiptHandle.equals(other.receiptHandle))
return false;
if (sqsMessageId == null) {
return other.sqsMessageId == null;
} else return sqsMessageId.equals(other.sqsMessageId);
}

@Override
public String toString() {
return "SQSMessageIdentifier [queueUrl=" + queueUrl + ", receiptHandle=" + receiptHandle +
", sqsMessageId=" + sqsMessageId + "]";
}
}

0 comments on commit d98f1b7

Please sign in to comment.