001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006package org.fcrepo.persistence.ocfl.impl; 007 008import org.fcrepo.kernel.api.identifiers.FedoraId; 009 010import java.util.Objects; 011 012import static org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString; 013 014/** 015 * A mapping that links the parent fedora resource to its corresponding OCFL object. 016 * 017 * @author dbernstein 018 */ 019public class FedoraOcflMapping { 020 021 private final FedoraId rootObjectIdentifier; 022 private final String ocflObjectId; 023 024 /** 025 * Default constructor 026 * @param rootObjectIdentifier The fedora root object resource identifier 027 * @param ocflObjectId The OCFL Object identitifer 028 */ 029 public FedoraOcflMapping(final FedoraId rootObjectIdentifier, final String ocflObjectId) { 030 this.rootObjectIdentifier = rootObjectIdentifier; 031 this.ocflObjectId = ocflObjectId; 032 } 033 034 /** 035 * The id for the fedora resource which represents this ocfl object 036 * @return the fedora root object identifier 037 */ 038 public FedoraId getRootObjectIdentifier() { 039 return rootObjectIdentifier; 040 } 041 042 /** 043 * Retrieve the OCFL object identifier associated with the Fedora resource 044 * @return the ocfl object identifier 045 */ 046 public String getOcflObjectId() { 047 return ocflObjectId; 048 } 049 050 @Override 051 public String toString() { 052 return reflectionToString(this); 053 } 054 055 @Override 056 public boolean equals(final Object o) { 057 if (this == o) { 058 return true; 059 } 060 if (o == null || getClass() != o.getClass()) { 061 return false; 062 } 063 final FedoraOcflMapping that = (FedoraOcflMapping) o; 064 return rootObjectIdentifier.equals(that.rootObjectIdentifier) && 065 ocflObjectId.equals(that.ocflObjectId); 066 } 067 068 @Override 069 public int hashCode() { 070 return Objects.hash(rootObjectIdentifier, ocflObjectId); 071 } 072 073}