Skip to content

Commit

Permalink
Deprecated the default constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
w3stling committed Aug 20, 2023
1 parent c1f3269 commit d20cbb9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/apptasticsoftware/rssreader/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ public class Channel {
private Image image;
private final DateTimeParser dateTimeParser;

/**
* Constructor for Channel
* @deprecated
* Use {@link Channel#Channel(DateTimeParser)} instead.
*/
@Deprecated(since="3.5.0", forRemoval=true)
public Channel() {
dateTimeParser = new DateTime();
}

/**
* Constructor for Channel
* @param dateTimeParser dateTimeParser
*/
public Channel(DateTimeParser dateTimeParser) {
this.dateTimeParser = dateTimeParser;
}
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/apptasticsoftware/rssreader/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,21 @@ public class Item implements Comparable<Item> {
private Channel channel;
private final DateTimeParser dateTimeParser;

/**
* Constructor for Item
* @deprecated
* Use {@link Item#Item(DateTimeParser)} instead.
*/
@Deprecated(since="3.5.0", forRemoval=true)
public Item() {
dateTimeParser = new DateTime();
defaultComparator = ItemComparator.newestItemFirst();
}

/**
* Constructor for Item
* @param dateTimeParser dateTimeParser
*/
public Item(DateTimeParser dateTimeParser) {
this.dateTimeParser = dateTimeParser;
defaultComparator = ItemComparator.newestItemFirst(dateTimeParser);
Expand Down
21 changes: 13 additions & 8 deletions src/test/java/com/apptasticsoftware/rssreader/RssReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void itemHashCodeTest() {
item1.setPubDate("a7");
int h1 = item1.hashCode();

Item item2 = new Item();
Item item2 = new Item(new DateTime());
item2.setAuthor("b1");
item2.setCategory("a2");
item2.setTitle("a3");
Expand All @@ -284,7 +284,7 @@ void itemHashCodeTest() {

@Test
void itemEqualsTest() {
Item item1 = new Item();
Item item1 = new Item(new DateTime());
item1.setAuthor("a1");
item1.setCategory("a2");
item1.setTitle("a3");
Expand All @@ -294,7 +294,7 @@ void itemEqualsTest() {
item1.setLink("a6");
item1.setPubDate("a7");

Item item2 = new Item();
Item item2 = new Item(new DateTime());
item2.setAuthor("b1");
item2.setCategory("a2");
item2.setTitle("a3");
Expand All @@ -304,7 +304,7 @@ void itemEqualsTest() {
item2.setLink("a6");
item2.setPubDate("a7");

Item item3 = new Item();
Item item3 = new Item(new DateTime());
item3.setAuthor("a1");
item3.setCategory("a2");
item3.setTitle("a3");
Expand Down Expand Up @@ -334,9 +334,10 @@ void channelHashCodeTest() {
channel1.setLastBuildDate("20220922T10:11:13");
channel1.setManagingEditor("a9");
channel1.setWebMaster("a10");
channel1.setRating("a11");
int h1 = channel1.hashCode();

Channel channel2 = new Channel();
Channel channel2 = new Channel(new DateTime());
channel2.setTitle("b1");
channel2.setDescription("a2");
channel2.setCategory("a3");
Expand All @@ -349,6 +350,7 @@ void channelHashCodeTest() {
channel2.setLastBuildDate("20220922T10:11:13");
channel2.setManagingEditor("a9");
channel2.setWebMaster("a10");
channel2.setRating("a11");
int h2 = channel2.hashCode();

assertNotEquals(h1, h2);
Expand All @@ -357,7 +359,7 @@ void channelHashCodeTest() {

@Test
void channelEqualsTest() {
Channel channel1 = new Channel();
Channel channel1 = new Channel(new DateTime());
channel1.setTitle("a1");
channel1.setDescription("a2");
channel1.setCategory("a3");
Expand All @@ -370,8 +372,9 @@ void channelEqualsTest() {
channel1.setLastBuildDate("20220922T10:11:13");
channel1.setManagingEditor("a9");
channel1.setWebMaster("a10");
channel1.setRating("a11");

Channel channel2 = new Channel();
Channel channel2 = new Channel(new DateTime());
channel2.setTitle("b1");
channel2.setDescription("a2");
channel2.setCategory("a3");
Expand All @@ -384,8 +387,9 @@ void channelEqualsTest() {
channel2.setLastBuildDate("20220922T10:11:13");
channel2.setManagingEditor("a9");
channel2.setWebMaster("a10");
channel2.setRating("a11");

Channel channel3 = new Channel();
Channel channel3 = new Channel(new DateTime());
channel3.setTitle("a1");
channel3.setDescription("a2");
channel3.setCategory("a3");
Expand All @@ -398,6 +402,7 @@ void channelEqualsTest() {
channel3.setLastBuildDate("20220922T10:11:13");
channel3.setManagingEditor("a9");
channel3.setWebMaster("a10");
channel3.setRating("a11");

assertNotEquals(channel1, channel2);
assertEquals(channel1, channel3);
Expand Down

0 comments on commit d20cbb9

Please sign in to comment.