Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Refactor #1

Merged
merged 6 commits into from
Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@ matrix:
- jdk: oraclejdk9

script: >-
./gradlew test asciidoctor
travis_retry ./gradlew clean test coverage coveralls asciidoctor checkstyleMain checkstyleTest

deploy:
skip_cleanup: true
provider: script
script: ./config/travis/deploy_github_pages.sh
script: bash ./config/travis/deploy_github_pages.sh
on:
branch: master

addons:
apt:
packages:
- oracle-java9-installer

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
2 changes: 1 addition & 1 deletion PlanMySem.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AddressBook/>
<Planner/>
6 changes: 3 additions & 3 deletions src/planmysem/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import java.util.List;

import planmysem.common.Messages;
import planmysem.data.AddressBook;
import planmysem.data.Planner;
import planmysem.data.person.ReadOnlyPerson;

/**
* Represents an executable command.
*/
public abstract class Command {
protected AddressBook addressBook;
protected Planner addressBook;
protected List<? extends ReadOnlyPerson> relevantPersons;
private int targetIndex = -1;

Expand Down Expand Up @@ -49,7 +49,7 @@ public CommandResult execute() {
/**
* Supplies the data the command will operate on.
*/
public void setData(AddressBook addressBook, List<? extends ReadOnlyPerson> relevantPersons) {
public void setData(Planner addressBook, List<? extends ReadOnlyPerson> relevantPersons) {
this.addressBook = addressBook;
this.relevantPersons = relevantPersons;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
/**
* Represents the entire address book. Contains the data of the address book.
*/
public class AddressBook {
public class Planner {

private final UniquePersonList allPersons;

/**
* Creates an empty address book.
*/
public AddressBook() {
public Planner() {
allPersons = new UniquePersonList();
}

Expand All @@ -25,12 +25,12 @@ public AddressBook() {
*
* @param persons external changes to this will not affect this address book
*/
public AddressBook(UniquePersonList persons) {
public Planner(UniquePersonList persons) {
this.allPersons = new UniquePersonList(persons);
}

public static AddressBook empty() {
return new AddressBook();
public static Planner empty() {
return new Planner();
}

/**
Expand Down Expand Up @@ -75,8 +75,8 @@ public UniquePersonList getAllPersons() {
@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof AddressBook // instanceof handles nulls
&& this.allPersons.equals(((AddressBook) other).allPersons));
|| (other instanceof Planner // instanceof handles nulls
&& this.allPersons.equals(((Planner) other).allPersons));
}

@Override
Expand Down
1 change: 0 additions & 1 deletion src/planmysem/data/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* Guarantees: details are present and not null, field values are validated.
*/
public class Person implements ReadOnlyPerson {

private final Set<Tag> tags = new HashSet<>();
private Name name;
private Phone phone;
Expand Down
53 changes: 53 additions & 0 deletions src/planmysem/data/slot/DateTime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package planmysem.data.slot;

import planmysem.data.exception.IllegalValueException;

/**
* Represents a Person's email in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValid(String)}
*/
public class DateTime {

public static final String EXAMPLE = "[email protected]";
public static final String MESSAGE_EMAIL_CONSTRAINTS =
"Person emails should be 2 alphanumeric/period strings separated by '@'";
public static final String EMAIL_VALIDATION_REGEX = "[\\w\\.]+@[\\w\\.]+";

public final String value;
private boolean isPrivate;

/**
* Validates given email.
*
* @throws IllegalValueException if given email address string is invalid.
*/
public DateTime(String value, boolean isPrivate) throws IllegalValueException {
this.isPrivate = isPrivate;
String dateTime = value.trim();
if (!isValid(dateTime)) {
throw new IllegalValueException(MESSAGE_EMAIL_CONSTRAINTS);
}
this.value = dateTime;
}

/**
* Checks if a given string is a valid Date and Time.
*/
public static boolean isValid(String test) {
return test.matches(EMAIL_VALIDATION_REGEX);
}

public boolean isPrivate() {
return isPrivate;
}

@Override
public String toString() {
return value;
}

@Override
public int hashCode() {
return value.hashCode();
}
}
68 changes: 68 additions & 0 deletions src/planmysem/data/slot/Description.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package planmysem.data.slot;

import java.util.Arrays;
import java.util.List;

import planmysem.data.exception.IllegalValueException;

/**
* Represents a Slot's description in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidName(String)}
*/
public class Description {

public static final String EXAMPLE = "John Doe";
public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphanumeric characters";
public static final String NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+";

public final String fullName;
private boolean isPrivate;

/**
* Validates given name.
*
* @throws IllegalValueException if given name string is invalid.
*/
public Description(String value) throws IllegalValueException {
String description = value.trim();
if (!isValidName(description)) {
throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS);
}
this.fullName = description;
}

/**
* Returns true if a given string is a valid slot name.
*/
public static boolean isValidName(String test) {
return test.matches(NAME_VALIDATION_REGEX);
}

/**
* Retrieves a listing of every word in the name, in order.
*/
public List<String> getWordsInName() {
return Arrays.asList(fullName.split("\\s+"));
}
public boolean isPrivate() {
return isPrivate;
}

@Override
public String toString() {
return fullName;
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof Description // instanceof handles nulls
&& this.fullName.equals(((Description) other).fullName)); // state check
}

@Override
public int hashCode() {
return fullName.hashCode();
}

}
14 changes: 14 additions & 0 deletions src/planmysem/data/slot/Location.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package planmysem.data.slot;

/**
* Represents a Person's email in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValid(String)}
*/
public class Location {
private boolean isPrivate;

public boolean isPrivate() {
return isPrivate;
}

}
64 changes: 64 additions & 0 deletions src/planmysem/data/slot/Name.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package planmysem.data.slot;

import java.util.Arrays;
import java.util.List;

import planmysem.data.exception.IllegalValueException;

/**
* Represents a Slot's name in the address book.
* Guarantees: immutable; is valid as declared in {@link #isValidName(String)}
*/
public class Name {

public static final String EXAMPLE = "John Doe";
public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphanumeric characters";
public static final String NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+";

public final String fullName;

/**
* Validates given name.
*
* @throws IllegalValueException if given name string is invalid.
*/
public Name(String value) throws IllegalValueException {
String name = value.trim();
if (!isValidName(name)) {
throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS);
}
this.fullName = name;
}

/**
* Returns true if a given string is a valid slot name.
*/
public static boolean isValidName(String test) {
return test.matches(NAME_VALIDATION_REGEX);
}

/**
* Retrieves a listing of every word in the name, in order.
*/
public List<String> getWordsInName() {
return Arrays.asList(fullName.split("\\s+"));
}

@Override
public String toString() {
return fullName;
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof Name // instanceof handles nulls
&& this.fullName.equals(((Name) other).fullName)); // state check
}

@Override
public int hashCode() {
return fullName.hashCode();
}

}
Loading