001/* 002 * (C) Copyright 2006-2016 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Razvan Caraghin 018 * Thierry Delprat 019 * Florent Guillaume 020 */ 021package org.nuxeo.ecm.platform.util; 022 023import java.io.Serializable; 024 025/** 026 * Represents a repository location. TODO: move to another package. 027 * 028 * @author Razvan Caraghin 029 * @author Thierry Delprat 030 * @author Florent Guillaume 031 */ 032public class RepositoryLocation implements Serializable, Comparable<RepositoryLocation> { 033 034 private static final long serialVersionUID = -4802281621945117577L; 035 036 protected final String name; 037 038 public RepositoryLocation(String name) { 039 if (name == null) { 040 throw new IllegalArgumentException("Null repository location"); 041 } 042 this.name = name; 043 } 044 045 public String getName() { 046 return name; 047 } 048 049 public int compareTo(RepositoryLocation o) { 050 return name.compareTo(o.name); 051 } 052 053 @Override 054 public boolean equals(Object other) { 055 if (this == other) { 056 return true; 057 } 058 if (!(other instanceof RepositoryLocation)) { 059 return false; 060 } 061 return name.equals(((RepositoryLocation) other).name); 062 } 063 064 @Override 065 public int hashCode() { 066 return this.name.hashCode(); 067 } 068 069}