Skip to content

Commit

Permalink
Merge pull request #235 from AY1920S1-CS2103-T16-3/gary/path-package
Browse files Browse the repository at this point in the history
Rename imagePath package to path and move DirectoryPath inside
  • Loading branch information
gary-lgy committed Nov 8, 2019
2 parents 20e8658 + 5a08b36 commit d2160ca
Show file tree
Hide file tree
Showing 48 changed files with 181 additions and 164 deletions.
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ifdef::env-github[]
endif::[]
:repoURL: https://github.com/AY1920S1-CS2103-T16-3/main

By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT`
By: `CS2103-T16-3`      Since: `September 2019`      Licence: `MIT`

== Setting up

Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Package Tag {
Class Tag
}

Package ImagePath {
Package Path {
Class ImagePath
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/TemplateClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Class Name
Class UniqueTemplateList
}

Package ImagePath {
Package Path {
Class ImagePath
}
}
Expand Down
Binary file modified docs/images/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/TemplateClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/main/java/seedu/weme/commons/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import javafx.scene.image.Image;

import seedu.weme.model.DirectoryPath;
import seedu.weme.model.path.DirectoryPath;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import seedu.weme.model.Model;
import seedu.weme.model.ModelContext;
import seedu.weme.model.ReadOnlyUserPrefs;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.meme.Description;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.tag.Tag;
import seedu.weme.model.template.exceptions.MemeCreationException;
import seedu.weme.model.util.ImageUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import seedu.weme.logic.commands.Command;
import seedu.weme.logic.commands.CommandResult;
import seedu.weme.logic.commands.exceptions.CommandException;
import seedu.weme.model.DirectoryPath;
import seedu.weme.model.Model;
import seedu.weme.model.path.DirectoryPath;

/**
* Exports memes from staging area to a specified path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import seedu.weme.logic.commands.exceptions.CommandException;
import seedu.weme.logic.commands.memecommand.MemeEditCommand;
import seedu.weme.model.Model;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.meme.Description;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.tag.Tag;

/**
Expand Down Expand Up @@ -46,7 +46,7 @@ public class ImportEditCommand extends Command {
private final MemeEditCommand.EditMemeDescriptor editMemeDescriptor;

/**
* @param index of the meme in the filtered meme list to edit
* @param index of the meme in the filtered meme list to edit
* @param editMemeDescriptor details to edit the meme with
*/
public ImportEditCommand(Index index, MemeEditCommand.EditMemeDescriptor editMemeDescriptor) {
Expand All @@ -57,6 +57,20 @@ public ImportEditCommand(Index index, MemeEditCommand.EditMemeDescriptor editMem
this.editMemeDescriptor = new MemeEditCommand.EditMemeDescriptor(editMemeDescriptor);
}

/**
* Creates and returns a {@code Meme} with the details of {@code memeToEdit}
* edited with {@code editMemeDescriptor}.
*/
private static Meme createEditedMeme(Meme memeToEdit, MemeEditCommand.EditMemeDescriptor editMemeDescriptor) {
assert memeToEdit != null;

ImagePath updatedPath = editMemeDescriptor.getFilePath().orElse(memeToEdit.getImagePath());
Description updatedDescription = editMemeDescriptor.getDescription().orElse(memeToEdit.getDescription());
Set<Tag> updatedTags = editMemeDescriptor.getTags().orElse(memeToEdit.getTags());

return new Meme(updatedPath, updatedDescription, updatedTags);
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
Expand All @@ -79,20 +93,6 @@ public CommandResult execute(Model model) throws CommandException {
return result;
}

/**
* Creates and returns a {@code Meme} with the details of {@code memeToEdit}
* edited with {@code editMemeDescriptor}.
*/
private static Meme createEditedMeme(Meme memeToEdit, MemeEditCommand.EditMemeDescriptor editMemeDescriptor) {
assert memeToEdit != null;

ImagePath updatedPath = editMemeDescriptor.getFilePath().orElse(memeToEdit.getImagePath());
Description updatedDescription = editMemeDescriptor.getDescription().orElse(memeToEdit.getDescription());
Set<Tag> updatedTags = editMemeDescriptor.getTags().orElse(memeToEdit.getTags());

return new Meme(updatedPath, updatedDescription, updatedTags);
}

@Override
public boolean equals(Object other) {
// short circuit if same object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import seedu.weme.logic.commands.Command;
import seedu.weme.logic.commands.CommandResult;
import seedu.weme.logic.commands.exceptions.CommandException;
import seedu.weme.model.DirectoryPath;
import seedu.weme.model.Model;
import seedu.weme.model.path.DirectoryPath;

/**
* Loads memes from a directory to the import context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import seedu.weme.logic.commands.CommandResult;
import seedu.weme.logic.commands.exceptions.CommandException;
import seedu.weme.model.Model;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.meme.Description;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.tag.Tag;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import seedu.weme.logic.commands.CommandResult;
import seedu.weme.logic.commands.exceptions.CommandException;
import seedu.weme.model.Model;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.meme.Description;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.tag.Tag;

/**
Expand Down Expand Up @@ -51,7 +51,7 @@ public class MemeEditCommand extends Command {
private final EditMemeDescriptor editMemeDescriptor;

/**
* @param index of the meme in the filtered meme list to edit
* @param index of the meme in the filtered meme list to edit
* @param editMemeDescriptor details to edit the meme with
*/
public MemeEditCommand(Index index, EditMemeDescriptor editMemeDescriptor) {
Expand All @@ -62,6 +62,21 @@ public MemeEditCommand(Index index, EditMemeDescriptor editMemeDescriptor) {
this.editMemeDescriptor = new EditMemeDescriptor(editMemeDescriptor);
}

/**
* Creates and returns a {@code Meme} with the details of {@code memeToEdit}
* edited with {@code editMemeDescriptor}.
*/
private static Meme createEditedMeme(Meme memeToEdit, EditMemeDescriptor editMemeDescriptor) {
assert memeToEdit != null;

ImagePath updatedPath = editMemeDescriptor.getFilePath().orElse(memeToEdit.getImagePath());
Description updatedDescription = editMemeDescriptor.getDescription().orElse(memeToEdit.getDescription());
Set<Tag> updatedTags = editMemeDescriptor.getTags().orElse(memeToEdit.getTags());
boolean isArchived = memeToEdit.isArchived();

return new Meme(updatedPath, updatedDescription, updatedTags, isArchived);
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
Expand Down Expand Up @@ -89,21 +104,6 @@ public CommandResult execute(Model model) throws CommandException {
return result;
}

/**
* Creates and returns a {@code Meme} with the details of {@code memeToEdit}
* edited with {@code editMemeDescriptor}.
*/
private static Meme createEditedMeme(Meme memeToEdit, EditMemeDescriptor editMemeDescriptor) {
assert memeToEdit != null;

ImagePath updatedPath = editMemeDescriptor.getFilePath().orElse(memeToEdit.getImagePath());
Description updatedDescription = editMemeDescriptor.getDescription().orElse(memeToEdit.getDescription());
Set<Tag> updatedTags = editMemeDescriptor.getTags().orElse(memeToEdit.getTags());
boolean isArchived = memeToEdit.isArchived();

return new Meme(updatedPath, updatedDescription, updatedTags, isArchived);
}

@Override
public boolean equals(Object other) {
// short circuit if same object
Expand Down Expand Up @@ -131,7 +131,8 @@ public static class EditMemeDescriptor {
private Description description;
private Set<Tag> tags;

public EditMemeDescriptor() {}
public EditMemeDescriptor() {
}

/**
* Copy constructor.
Expand All @@ -150,28 +151,20 @@ public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(filePath, description, tags);
}

public void setFilePath(ImagePath filePath) {
this.filePath = filePath;
}

public Optional<ImagePath> getFilePath() {
return Optional.ofNullable(filePath);
}

public void setDescription(Description description) {
this.description = description;
public void setFilePath(ImagePath filePath) {
this.filePath = filePath;
}

public Optional<Description> getDescription() {
return Optional.ofNullable(description);
}

/**
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
*/
public void setTags(Set<Tag> tags) {
this.tags = (tags != null) ? new HashSet<>(tags) : null;
public void setDescription(Description description) {
this.description = description;
}

/**
Expand All @@ -183,6 +176,14 @@ public Optional<Set<Tag>> getTags() {
return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty();
}

/**
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
*/
public void setTags(Set<Tag> tags) {
this.tags = (tags != null) ? new HashSet<>(tags) : null;
}

@Override
public boolean equals(Object other) {
// short circuit if same object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import seedu.weme.logic.commands.CommandResult;
import seedu.weme.logic.commands.exceptions.CommandException;
import seedu.weme.model.Model;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.meme.Description;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.tag.Tag;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import seedu.weme.logic.commands.CommandResult;
import seedu.weme.logic.commands.exceptions.CommandException;
import seedu.weme.model.Model;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.template.Name;
import seedu.weme.model.template.Template;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import seedu.weme.logic.commands.CommandResult;
import seedu.weme.logic.commands.exceptions.CommandException;
import seedu.weme.model.Model;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.template.Name;
import seedu.weme.model.template.Template;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.weme.logic.parser.util.ArgumentMultimap;
import seedu.weme.logic.parser.util.ArgumentTokenizer;
import seedu.weme.logic.parser.util.ParserUtil;
import seedu.weme.model.DirectoryPath;
import seedu.weme.model.path.DirectoryPath;

/**
* Parses input arguments and creates a new ExportCommand object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.weme.logic.parser.util.ArgumentMultimap;
import seedu.weme.logic.parser.util.ArgumentTokenizer;
import seedu.weme.logic.parser.util.ParserUtil;
import seedu.weme.model.DirectoryPath;
import seedu.weme.model.path.DirectoryPath;

/**
* Parses input arguments and creates a new LoadCommand object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import seedu.weme.logic.parser.util.ArgumentMultimap;
import seedu.weme.logic.parser.util.ArgumentTokenizer;
import seedu.weme.logic.parser.util.ParserUtil;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.meme.Description;
import seedu.weme.model.meme.Meme;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.tag.Tag;

/**
Expand All @@ -26,6 +26,7 @@ public class MemeAddCommandParser implements Parser<MemeAddCommand> {
/**
* Parses the given {@code String} of arguments in the context of the MemeAddCommand
* and returns an MemeAddCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public MemeAddCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import seedu.weme.logic.parser.util.ArgumentMultimap;
import seedu.weme.logic.parser.util.ArgumentTokenizer;
import seedu.weme.logic.parser.util.ParserUtil;
import seedu.weme.model.imagePath.ImagePath;
import seedu.weme.model.path.ImagePath;
import seedu.weme.model.template.Name;
import seedu.weme.model.template.Template;

Expand Down
Loading

0 comments on commit d2160ca

Please sign in to comment.