Skip to content

Commit

Permalink
- Lombok dependency added.
Browse files Browse the repository at this point in the history
- Getter and setter methods replaced by Lombok annotations.
  • Loading branch information
MalloD12 committed Dec 27, 2024
1 parent 3126d8c commit fb98162
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 456 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<hibernate.version>6.3.1.Final</hibernate.version>
<spring.version>6.2.1</spring.version>
<liquibase.version>4.30.0</liquibase.version>
<lombok.version>1.18.36</lombok.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
Expand Down Expand Up @@ -151,6 +152,12 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
41 changes: 6 additions & 35 deletions src/test/java/com/example/ejb3/auction/AuctionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,20 @@
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
public class AuctionInfo {
@Id
private String id;
@Column(length = 1000)
private String description;
private Date ends;
private Float maxAmount;

@Column(length = 1000)
public String getDescription() {
return description;
}

public Date getEnds() {
return ends;
}

@Id
public String getId() {
return id;
}


public Float getMaxAmount() {
return maxAmount;
}

public void setId(String id) {
this.id = id;
}

public void setDescription(String description) {
this.description = description;
}

public void setEnds(Date ends) {
this.ends = ends;
}

public void setMaxAmount(Float maxAmount) {
this.maxAmount = maxAmount;
}

public AuctionInfo(String id, String description, Date ends, Float maxAmount) {
this.id = id;
this.description = description;
Expand Down
62 changes: 15 additions & 47 deletions src/test/java/com/example/ejb3/auction/AuctionItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,37 @@
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import lombok.Getter;
import lombok.Setter;

@Entity
public class AuctionItem extends Persistent {
@Column(length = 1000)
@Getter
@Setter
private String description;
@Column(length = 200)
@Getter
@Setter
private String shortDescription;
@Setter
private List<Bid> bids;
@Setter
private Bid successfulBid;
@Setter
private User seller;
@Getter
@Setter
private Date ends;
@Getter
@Setter
private int condition;

@OneToMany(mappedBy = "item", cascade = CascadeType.ALL)
public List<Bid> getBids() {
return bids;
}

@Column(length = 1000)
public String getDescription() {
return description;
}

@ManyToOne
public User getSeller() {
return seller;
Expand All @@ -39,51 +49,9 @@ public Bid getSuccessfulBid() {
return successfulBid;
}

public void setBids(List<Bid> bids) {
this.bids = bids;
}

public void setDescription(String string) {
description = string;
}

public void setSeller(User user) {
seller = user;
}

public void setSuccessfulBid(Bid bid) {
successfulBid = bid;
}

public Date getEnds() {
return ends;
}

public void setEnds(Date date) {
ends = date;
}

public int getCondition() {
return condition;
}

public void setCondition(int i) {
condition = i;
}

public String toString() {
return shortDescription + " (" + description + ": " + condition
+ "/10)";
}

@Column(length = 200)
public String getShortDescription() {
return shortDescription;
}

public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}


}
20 changes: 4 additions & 16 deletions src/test/java/com/example/ejb3/auction/AuditedItem.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.ejb3.auction;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.envers.Audited;

import jakarta.persistence.Column;
Expand All @@ -11,6 +13,8 @@

@Audited
@Entity
@Getter
@Setter
public class AuditedItem {

@Id
Expand All @@ -20,20 +24,4 @@ public class AuditedItem {
@Column(unique = true)
private String name;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}
27 changes: 7 additions & 20 deletions src/test/java/com/example/ejb3/auction/Bid.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Date;

import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

Expand All @@ -18,46 +20,31 @@
@DiscriminatorValue("Y")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Bid extends Persistent {
@Setter
private AuctionItem item;
@Setter
@Getter
private float amount;
@Setter
private Date datetime;
@Setter
private User bidder;

@ManyToOne
public AuctionItem getItem() {
return item;
}

public void setItem(AuctionItem item) {
this.item = item;
}

public float getAmount() {
return amount;
}

@Column(nullable = false, name = "datetime")
public Date getDatetime() {
return datetime;
}

public void setAmount(float f) {
amount = f;
}

public void setDatetime(Date date) {
datetime = date;
}

@ManyToOne(optional = false)
public User getBidder() {
return bidder;
}

public void setBidder(User user) {
bidder = user;
}

public String toString() {
return bidder.getUserName() + " $" + amount;
}
Expand Down
27 changes: 4 additions & 23 deletions src/test/java/com/example/ejb3/auction/FirstTable.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.example.ejb3.auction;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@Entity
@SecondaryTable(name = "second_table", pkJoinColumns = @PrimaryKeyJoinColumn(name = "first_table_id"))
public class FirstTable {
Expand All @@ -14,27 +18,4 @@ public class FirstTable {
@Embedded
private SecondTable secondTable;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public SecondTable getSecondTable() {
return secondTable;
}

public void setSecondTable(SecondTable secondTable) {
this.secondTable = secondTable;
}
}
20 changes: 4 additions & 16 deletions src/test/java/com/example/ejb3/auction/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@Entity
public class Item {

Expand All @@ -17,20 +21,4 @@ public class Item {
@Column(unique = true)
private String name;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}
28 changes: 4 additions & 24 deletions src/test/java/com/example/ejb3/auction/Name.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.example.ejb3.auction;

import jakarta.persistence.Embeddable;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@Embeddable
public class Name {
private String firstName;
Expand All @@ -14,30 +18,6 @@ public Name(String first, Character middle, String last) {
lastName = last;
}

public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public Character getInitial() {
return initial;
}

public void setInitial(Character initial) {
this.initial = initial;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String toString() {
StringBuffer buf = new StringBuffer().append(firstName).append(' ');
if (initial != null)
Expand Down
Loading

0 comments on commit fb98162

Please sign in to comment.