pit/libpit/src/com/jdbernard/pit/Issue.groovy
Jonathan Bernard b7670e69f3 Added throws declarations for IOExceptions on Issue setters.
The FileIssue implementation now checks to ensure the success of the setters.
2010-05-19 09:54:18 -05:00

70 lines
1.7 KiB
Groovy

package com.jdbernard.pit
import java.lang.IllegalArgumentException as IAE
public abstract class Issue {
protected String id
protected Category category
protected Status status
protected int priority
protected String text
protected Date deliveryDate
protected Date creationDate
Issue(String id, Category c = Category.TASK, Status s = Status.NEW,
int p = 9) {
this.id = id
this.category = c
this.status = s
this.priority = p
this.creationDate = new Date()
this.deliveryDate = null
}
public String getId() { return id; }
public Category getCategory() { return category }
public void setCategory(Category c) throws IOException {
if (c == null)
throw new IAE("Category cannot be null.")
this.category = c
}
public Status getStatus() { return status }
public void setStatus(Status s) throws IOException {
if (s == null)
throw new IAE("Status cannot be null.")
this.status = s
}
public int getPriority() { return priority }
public void setPriority(int p) throws IOException {
priority = Math.min(9, Math.max(0, p))
}
public String getTitle() { return text.readLines()[0] }
public String getText() { return text }
public void setText(String t) throws IOException { text = t }
public boolean hasDelivery() { return deliveryDate == null }
public Date getCreationDate() { return creationDate }
public Date getDeliveryDate() { return deliveryDate }
public void setDeliveryDate(Date dd) { deliveryDate = dd }
@Override
public String toString() { return "${id}(${priority}-${status}): ${category} ${title}" }
public abstract boolean delete()
}