Skip to content

Commit

Permalink
Make IPInterface functions return itself and not an implementation of…
Browse files Browse the repository at this point in the history
… it to allow better overriding
  • Loading branch information
michielvandriessche committed Oct 14, 2022
1 parent 2bcfda0 commit c503fc7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 65 deletions.
54 changes: 27 additions & 27 deletions src/main/java/org/roda_project/commons_ip2/model/IPInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,83 +22,83 @@

public interface IPInterface {

IP setId(String id);
IPInterface setId(String id);

String getId();

IP setIds(List<String> ids);
IPInterface setIds(List<String> ids);

List<String> getIds();

IP setProfile(String profile);
IPInterface setProfile(String profile);

String getProfile();

IP setType(IPType type);
IPInterface setType(IPType type);

String getType();

IP setContentType(IPContentType contentType);
IPInterface setContentType(IPContentType contentType);

IPContentType getContentType();

IP setContentInformationType(IPContentInformationType contentInformationType);
IPInterface setContentInformationType(IPContentInformationType contentInformationType);

IPContentInformationType getContentInformationType();

IP setStatus(IPStatus status);
IPInterface setStatus(IPStatus status);

IPStatus getStatus();

IP setCreateDate(XMLGregorianCalendar date);
IPInterface setCreateDate(XMLGregorianCalendar date);

Optional<XMLGregorianCalendar> getCreateDate();

IP setModificationDate(XMLGregorianCalendar date);
IPInterface setModificationDate(XMLGregorianCalendar date);

Optional<XMLGregorianCalendar> getModificationDate();

IP setBasePath(Path basePath);
IPInterface setBasePath(Path basePath);

Path getBasePath();

IP setAncestors(List<String> ancestors);
IPInterface setAncestors(List<String> ancestors);

List<String> getAncestors();

IP setDescription(String description);
IPInterface setDescription(String description);

String getDescription();

IP addAgent(IPAgent agent);
IPInterface addAgent(IPAgent agent);

IP addDescriptiveMetadata(IPDescriptiveMetadata descriptiveMetadata) throws IPException;
IPInterface addDescriptiveMetadata(IPDescriptiveMetadata descriptiveMetadata) throws IPException;

IP addPreservationMetadata(IPMetadata preservationMetadata) throws IPException;
IPInterface addPreservationMetadata(IPMetadata preservationMetadata) throws IPException;

IP addOtherMetadata(IPMetadata otherMetadata) throws IPException;
IPInterface addOtherMetadata(IPMetadata otherMetadata) throws IPException;

IP addRepresentation(IPRepresentation representation) throws IPException;
IPInterface addRepresentation(IPRepresentation representation) throws IPException;

IP addSchema(IPFileInterface schema);
IPInterface addSchema(IPFileInterface schema);

IP addDocumentation(IPFileInterface documentation);
IPInterface addDocumentation(IPFileInterface documentation);

IP addAgentToRepresentation(String representationID, IPAgent agent) throws IPException;
IPInterface addAgentToRepresentation(String representationID, IPAgent agent) throws IPException;

IP addDescriptiveMetadataToRepresentation(String representationID, IPDescriptiveMetadata descriptiveMetadata)
IPInterface addDescriptiveMetadataToRepresentation(String representationID, IPDescriptiveMetadata descriptiveMetadata)
throws IPException;

IP addPreservationMetadataToRepresentation(String representationID, IPMetadata preservationMetadata)
IPInterface addPreservationMetadataToRepresentation(String representationID, IPMetadata preservationMetadata)
throws IPException;

IP addOtherMetadataToRepresentation(String representationID, IPMetadata otherMetadata) throws IPException;
IPInterface addOtherMetadataToRepresentation(String representationID, IPMetadata otherMetadata) throws IPException;

IP addFileToRepresentation(String representationID, IPFileInterface file) throws IPException;
IPInterface addFileToRepresentation(String representationID, IPFileInterface file) throws IPException;

IP addSchemaToRepresentation(String representationID, IPFileInterface schema) throws IPException;
IPInterface addSchemaToRepresentation(String representationID, IPFileInterface schema) throws IPException;

IP addDocumentationToRepresentation(String representationID, IPFileInterface documentation) throws IPException;
IPInterface addDocumentationToRepresentation(String representationID, IPFileInterface documentation) throws IPException;

List<IPAgent> getAgents();

Expand Down Expand Up @@ -144,4 +144,4 @@ static IPInterface parse(Path source, Path destinationDirectory) throws ParseExc
throw new ParseException("One must implement static method parse in a concrete class");
}

}
}
65 changes: 27 additions & 38 deletions src/main/java/org/roda_project/commons_ip2/model/impl/AIPWrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,7 @@
import org.roda_project.commons_ip.utils.IPEnums;
import org.roda_project.commons_ip.utils.IPException;
import org.roda_project.commons_ip.utils.ZipEntryInfo;
import org.roda_project.commons_ip2.model.AIP;
import org.roda_project.commons_ip2.model.IP;
import org.roda_project.commons_ip2.model.IPAgent;
import org.roda_project.commons_ip2.model.IPContentInformationType;
import org.roda_project.commons_ip2.model.IPContentType;
import org.roda_project.commons_ip2.model.IPDescriptiveMetadata;
import org.roda_project.commons_ip2.model.IPFile;
import org.roda_project.commons_ip2.model.IPFileInterface;
import org.roda_project.commons_ip2.model.IPHeader;
import org.roda_project.commons_ip2.model.IPMetadata;
import org.roda_project.commons_ip2.model.IPRepresentation;
import org.roda_project.commons_ip2.model.ValidationReport;
import org.roda_project.commons_ip2.model.*;

/**
* AIP decorator (wrapper).
Expand Down Expand Up @@ -58,7 +47,7 @@ public String toString() {
}

@Override
public IP setId(final String id) {
public IPInterface setId(final String id) {
return aip.setId(id);
}

Expand All @@ -68,7 +57,7 @@ public String getId() {
}

@Override
public IP setIds(final List<String> ids) {
public IPInterface setIds(final List<String> ids) {
return aip.setIds(ids);
}

Expand All @@ -78,7 +67,7 @@ public List<String> getIds() {
}

@Override
public IP setProfile(final String profile) {
public IPInterface setProfile(final String profile) {
return aip.setProfile(profile);
}

Expand All @@ -88,7 +77,7 @@ public String getProfile() {
}

@Override
public IP setType(final IPEnums.IPType type) {
public IPInterface setType(final IPEnums.IPType type) {
return aip.setType(type);
}

Expand All @@ -108,7 +97,7 @@ public String getState() {
}

@Override
public IP setContentType(final IPContentType contentType) {
public IPInterface setContentType(final IPContentType contentType) {
return aip.setContentType(contentType);
}

Expand All @@ -118,7 +107,7 @@ public IPContentType getContentType() {
}

@Override
public IP setContentInformationType(IPContentInformationType contentInformationType) {
public IPInterface setContentInformationType(IPContentInformationType contentInformationType) {
return aip.setContentInformationType(contentInformationType);
}

Expand All @@ -128,7 +117,7 @@ public IPContentInformationType getContentInformationType() {
}

@Override
public IP setStatus(final IPEnums.IPStatus status) {
public IPInterface setStatus(final IPEnums.IPStatus status) {
return aip.setStatus(status);
}

Expand All @@ -138,7 +127,7 @@ public IPEnums.IPStatus getStatus() {
}

@Override
public IP setCreateDate(final XMLGregorianCalendar date) {
public IPInterface setCreateDate(final XMLGregorianCalendar date) {
return aip.setCreateDate(date);
}

Expand All @@ -148,7 +137,7 @@ public Optional<XMLGregorianCalendar> getCreateDate() {
}

@Override
public IP setModificationDate(final XMLGregorianCalendar date) {
public IPInterface setModificationDate(final XMLGregorianCalendar date) {
return aip.setModificationDate(date);
}

Expand All @@ -163,12 +152,12 @@ public List<String> getAncestors() {
}

@Override
public IP setAncestors(final List<String> ancestors) {
public IPInterface setAncestors(final List<String> ancestors) {
return aip.setAncestors(ancestors);
}

@Override
public IP setBasePath(final Path basePath) {
public IPInterface setBasePath(final Path basePath) {
return aip.setBasePath(basePath);
}

Expand All @@ -178,7 +167,7 @@ public Path getBasePath() {
}

@Override
public IP setDescription(final String description) {
public IPInterface setDescription(final String description) {
return aip.setDescription(description);
}

Expand All @@ -188,32 +177,32 @@ public String getDescription() {
}

@Override
public IP addAgent(final IPAgent aipAgent) {
public IPInterface addAgent(final IPAgent aipAgent) {
return aip.addAgent(aipAgent);
}

@Override
public IP addPreservationMetadata(final IPMetadata metadata) throws IPException {
public IPInterface addPreservationMetadata(final IPMetadata metadata) throws IPException {
return aip.addPreservationMetadata(metadata);
}

@Override
public IP addOtherMetadata(final IPMetadata metadata) throws IPException {
public IPInterface addOtherMetadata(final IPMetadata metadata) throws IPException {
return aip.addOtherMetadata(metadata);
}

@Override
public IP addDescriptiveMetadata(final IPDescriptiveMetadata metadata) throws IPException {
public IPInterface addDescriptiveMetadata(final IPDescriptiveMetadata metadata) throws IPException {
return aip.addDescriptiveMetadata(metadata);
}

@Override
public IP addRepresentation(final IPRepresentation aipRepresentation) throws IPException {
public IPInterface addRepresentation(final IPRepresentation aipRepresentation) throws IPException {
return aip.addRepresentation(aipRepresentation);
}

@Override
public IP addSchema(final IPFileInterface schema) {
public IPInterface addSchema(final IPFileInterface schema) {
return aip.addSchema(schema);
}

Expand All @@ -223,45 +212,45 @@ public AIP addSubmission(final IPFileInterface submission) {
}

@Override
public IP addDocumentation(final IPFileInterface documentationPath) {
public IPInterface addDocumentation(final IPFileInterface documentationPath) {
return aip.addDocumentation(documentationPath);
}

@Override
public IP addAgentToRepresentation(final String representationID, final IPAgent agent) throws IPException {
public IPInterface addAgentToRepresentation(final String representationID, final IPAgent agent) throws IPException {
return aip.addAgentToRepresentation(representationID, agent);
}

@Override
public IP addDescriptiveMetadataToRepresentation(final String representationID,
public IPInterface addDescriptiveMetadataToRepresentation(final String representationID,
final IPDescriptiveMetadata descriptiveMetadata) throws IPException {
return aip.addDescriptiveMetadataToRepresentation(representationID, descriptiveMetadata);
}

@Override
public IP addPreservationMetadataToRepresentation(final String representationID,
public IPInterface addPreservationMetadataToRepresentation(final String representationID,
final IPMetadata preservationMetadata) throws IPException {
return aip.addPreservationMetadataToRepresentation(representationID, preservationMetadata);
}

@Override
public IP addOtherMetadataToRepresentation(final String representationID, final IPMetadata otherMetadata)
public IPInterface addOtherMetadataToRepresentation(final String representationID, final IPMetadata otherMetadata)
throws IPException {
return aip.addOtherMetadataToRepresentation(representationID, otherMetadata);
}

@Override
public IP addFileToRepresentation(final String representationID, final IPFileInterface file) throws IPException {
public IPInterface addFileToRepresentation(final String representationID, final IPFileInterface file) throws IPException {
return aip.addFileToRepresentation(representationID, file);
}

@Override
public IP addSchemaToRepresentation(final String representationID, final IPFileInterface schema) throws IPException {
public IPInterface addSchemaToRepresentation(final String representationID, final IPFileInterface schema) throws IPException {
return aip.addSchemaToRepresentation(representationID, schema);
}

@Override
public IP addDocumentationToRepresentation(final String representationID, final IPFileInterface documentation)
public IPInterface addDocumentationToRepresentation(final String representationID, final IPFileInterface documentation)
throws IPException {
return aip.addDocumentationToRepresentation(representationID, documentation);
}
Expand Down

0 comments on commit c503fc7

Please sign in to comment.