001/*
002 *  Copyright 2018 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.odf.bean;
017
018import org.apache.commons.lang3.StringUtils;
019
020/**
021 * Website object
022 */
023public abstract class AbstractExternalAddress
024{
025    private String _url;
026    private String _label;
027    
028    /**
029     * Constructor
030     * @param url URL of the website
031     * @param label Label of the website
032     */
033    public AbstractExternalAddress(String url, String label)
034    {
035        _url = url;
036        _label = label;
037    }
038
039    /**
040     * Getter for the URL
041     * @return the URL
042     */
043    public String getUrl()
044    {
045        return _url;
046    }
047
048    /**
049     * Setter for the URL
050     * @param url the URL
051     */
052    public void setUrl(String url)
053    {
054        _url = url == null ? "" : url;
055    }
056
057    /**
058     * Getter for the label
059     * @return the label
060     */
061    public String getLabel()
062    {
063        return _label;
064    }
065
066    /**
067     * Setter for the label
068     * @param label the label
069     */
070    public void setLabel(String label)
071    {
072        _label = label == null ? "" : label;
073    }
074    
075    @Override
076    public boolean equals(Object obj)
077    {
078        if (obj == null)
079        {
080            return false;
081        }
082        
083        if (!(obj instanceof AbstractExternalAddress))
084        {
085            return false;
086        }
087        
088        AbstractExternalAddress webSite = (AbstractExternalAddress) obj;
089        if (!StringUtils.equals(this.getUrl(), webSite.getUrl()) || !StringUtils.equals(this.getLabel(), webSite.getLabel()))
090        {
091            return false;
092        }
093        
094        return true;
095    }
096    
097    @Override
098    public int hashCode()
099    {
100        return super.hashCode();
101    }
102}