001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.persistence.ocfl.impl; 019 020import org.fcrepo.kernel.api.identifiers.FedoraId; 021 022import java.util.Objects; 023 024import static org.apache.commons.lang3.builder.ToStringBuilder.reflectionToString; 025 026/** 027 * A mapping that links the parent fedora resource to its corresponding OCFL object. 028 * 029 * @author dbernstein 030 */ 031public class FedoraOcflMapping { 032 033 private final FedoraId rootObjectIdentifier; 034 private final String ocflObjectId; 035 036 /** 037 * Default constructor 038 * @param rootObjectIdentifier The fedora root object resource identifier 039 * @param ocflObjectId The OCFL Object identitifer 040 */ 041 public FedoraOcflMapping(final FedoraId rootObjectIdentifier, final String ocflObjectId) { 042 this.rootObjectIdentifier = rootObjectIdentifier; 043 this.ocflObjectId = ocflObjectId; 044 } 045 046 /** 047 * The id for the fedora resource which represents this ocfl object 048 * @return the fedora root object identifier 049 */ 050 public FedoraId getRootObjectIdentifier() { 051 return rootObjectIdentifier; 052 } 053 054 /** 055 * Retrieve the OCFL object identifier associated with the Fedora resource 056 * @return the ocfl object identifier 057 */ 058 public String getOcflObjectId() { 059 return ocflObjectId; 060 } 061 062 @Override 063 public String toString() { 064 return reflectionToString(this); 065 } 066 067 @Override 068 public boolean equals(final Object o) { 069 if (this == o) { 070 return true; 071 } 072 if (o == null || getClass() != o.getClass()) { 073 return false; 074 } 075 final FedoraOcflMapping that = (FedoraOcflMapping) o; 076 return rootObjectIdentifier.equals(that.rootObjectIdentifier) && 077 ocflObjectId.equals(that.ocflObjectId); 078 } 079 080 @Override 081 public int hashCode() { 082 return Objects.hash(rootObjectIdentifier, ocflObjectId); 083 } 084 085}