Skip to content

Commit

Permalink
Add substitutionFrom and teacherTo attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
johan12345 committed Jun 5, 2016
1 parent e9a6fed commit ace2cf4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
39 changes: 31 additions & 8 deletions parser/src/main/java/me/vertretungsplan/objects/Substitution.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class Substitution {
private String previousRoom;
private String desc;
private String color;
private String substitutionFrom;
private String teacherTo;

public Substitution() {
classes = new HashSet<>();
Expand All @@ -46,6 +48,8 @@ public Substitution(Substitution substitution, Set<String> classes) {
this.previousRoom = substitution.previousRoom;
this.desc = substitution.desc;
this.color = substitution.color;
this.substitutionFrom = substitution.substitutionFrom;
this.teacherTo = substitution.teacherTo;
}

/**
Expand All @@ -70,11 +74,6 @@ public String getTeachers() {
return SubstitutionTextUtils.getTeachers(this);
}

@SuppressWarnings({"EmptyMethod", "UnusedParameters"})
public void setText(String text) {
// does nothing, needs to be there for Jackson
}

public Set<String> getClasses() {
return classes;
}
Expand Down Expand Up @@ -163,6 +162,22 @@ public void setColor(String color) {
this.color = color;
}

public String getSubstitutionFrom() {
return substitutionFrom;
}

public void setSubstitutionFrom(String substitutionFrom) {
this.substitutionFrom = substitutionFrom;
}

public String getTeacherTo() {
return teacherTo;
}

public void setTeacherTo(String teacherTo) {
this.teacherTo = teacherTo;
}

@SuppressWarnings("NegatedConditionalExpression")
public boolean equalsExcludingClasses(Object o) {
if (this == o) return true;
Expand All @@ -181,8 +196,13 @@ public boolean equalsExcludingClasses(Object o) {
if (room != null ? !room.equals(that.room) : that.room != null) return false;
if (previousRoom != null ? !previousRoom.equals(that.previousRoom) : that.previousRoom != null) return false;
if (desc != null ? !desc.equals(that.desc) : that.desc != null) return false;
return !(color != null ? !color.equals(that.color) : that.color != null);

if (color != null ? !color.equals(that.color) : that.color != null) return false;
if (substitutionFrom != null ? !substitutionFrom.equals(that.substitutionFrom) :
that.substitutionFrom != null) {
return false;
}
if (teacherTo != null ? !teacherTo.equals(that.teacherTo) : that.teacherTo != null) return false;
return true;
}

public int hashCodeExcludingClasses() {
Expand All @@ -196,6 +216,8 @@ public int hashCodeExcludingClasses() {
result = 31 * result + (previousRoom != null ? previousRoom.hashCode() : 0);
result = 31 * result + (desc != null ? desc.hashCode() : 0);
result = 31 * result + (color != null ? color.hashCode() : 0);
result = 31 * result + (substitutionFrom != null ? substitutionFrom.hashCode() : 0);
result = 31 * result + (teacherTo != null ? teacherTo.hashCode() : 0);
return result;
}

Expand All @@ -209,7 +231,8 @@ public String toString(SubstitutionSchedule.Type type) {
case STUDENT:
return classes.toString() + " " + getType() + " " + getText();
case TEACHER:
return getTeachers() + " " + getType() + " " + getTeacherText();
return getTeachers() + " " + getType() + " " + getTeacherText() + " (" + (substitutionFrom != null ?
substitutionFrom : "") + "/" + (teacherTo != null ? teacherTo : "") + ")";
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ protected void parseVertretungsplanTable(Element table, JSONObject data,
case "previousRoom":
v.setPreviousRoom(text);
break;
case "substitutionFrom":
v.setSubstitutionFrom(text);
break;
case "teacherTo":
v.setTeacherTo(text);
break;
}
i++;
}
Expand Down Expand Up @@ -317,6 +323,12 @@ protected void parseVertretungsplanTable(Element table, JSONObject data,
case "previousTeacher":
v.setPreviousTeacher(text);
break;
case "substitutionFrom":
v.setSubstitutionFrom(text);
break;
case "teacherTo":
v.setTeacherTo(text);
break;
case "class":
klassen = getClassName(text, data);
break;
Expand Down

0 comments on commit ace2cf4

Please sign in to comment.