001/*
002 *  Copyright 2016 Anyware Services
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 */
016package org.ametys.cms.search.solr.schema;
017
018/**
019 * A copy field identifier (source and destination).
020 */
021public class CopyFieldId
022{
023    /** The copy field source. */
024    protected String _source;
025    
026    /** The copy field destination. */
027    protected String _destination;
028    
029    /**
030     * Build a copy field.
031     * @param source The copy field source.
032     * @param destination The copy field destination.
033     */
034    public CopyFieldId(String source, String destination)
035    {
036        this._source = source;
037        this._destination = destination;
038    }
039    
040    /**
041     * Get the copy field source.
042     * @return The copy field source.
043     */
044    public String getSource()
045    {
046        return _source;
047    }
048    
049    /**
050     * Set the copy field source.
051     * @param source The copy field source to set.
052     */
053    public void setSource(String source)
054    {
055        this._source = source;
056    }
057    
058    /**
059     * Get the copy field destination.
060     * @return The copy field destination.
061     */
062    public String getDestination()
063    {
064        return _destination;
065    }
066    
067    /**
068     * Set the copy field destination.
069     * @param destination The copy field destination to set.
070     */
071    public void setDestination(String destination)
072    {
073        this._destination = destination;
074    }
075    
076    @Override
077    public String toString()
078    {
079        return "{source=" + _source + ", destination=" + _destination + "}";
080    }
081    
082    @Override
083    public int hashCode()
084    {
085        final int prime = 31;
086        int result = 1;
087        result = prime * result + ((_destination == null) ? 0 : _destination.hashCode());
088        result = prime * result + ((_source == null) ? 0 : _source.hashCode());
089        return result;
090    }
091
092    @Override
093    public boolean equals(Object obj)
094    {
095        if (this == obj)
096        {
097            return true;
098        }
099        if (obj == null)
100        {
101            return false;
102        }
103        if (getClass() != obj.getClass())
104        {
105            return false;
106        }
107        CopyFieldId other = (CopyFieldId) obj;
108        if (_destination == null)
109        {
110            if (other._destination != null)
111            {
112                return false;
113            }
114        }
115        else if (!_destination.equals(other._destination))
116        {
117            return false;
118        }
119        if (_source == null)
120        {
121            if (other._source != null)
122            {
123                return false;
124            }
125        }
126        else if (!_source.equals(other._source))
127        {
128            return false;
129        }
130        return true;
131    }
132}