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    @Override
050    public int compareTo(RepositoryLocation o) {
051        return name.compareTo(o.name);
052    }
053
054    @Override
055    public boolean equals(Object other) {
056        if (this == other) {
057            return true;
058        }
059        if (!(other instanceof RepositoryLocation)) {
060            return false;
061        }
062        return name.equals(((RepositoryLocation) other).name);
063    }
064
065    @Override
066    public int hashCode() {
067        return this.name.hashCode();
068    }
069
070}