ジェネレータアレイジェネレータアレイ:プロトタイプアレイプロトタイプアレイ
紹介する
@Getter
@Setter
public class GithubIssue implements Cloneable {
private int id;
private String title;
private GihubRepository repository;
public GithubIssue(GithubRepository repository) {
this.repository = repository;
}
public String getUrl() {
return String.format("https://github.com/%s/%s/issues/%d",
repository.getUser(),
repository.getName(),
this.getId());
}
@Override
protected Override clone() throw CloneNotSupportedException {
//return super(this); -> 얕은 복사: GithubRepository는 주소만 가져온다.
//deep copy
GithubRepository repository = new GithubRepository();
repository.setUser(this.repository.getUser());
repository.setName(this.repository.getName());
GithubRepository githubIssue = new GithubIssue(repository);
githubIssue.setId(this.id);
githubIssue.setTitle(this.title);
return githubIssue;
}
}
Reference
この問題について(ジェネレータアレイジェネレータアレイ:プロトタイプアレイプロトタイプアレイ), 我々は、より多くの情報をここで見つけました https://velog.io/@zenon8485/생성자-패턴-프로토-타입-패턴テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol