001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.mobile.device;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.HashUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    
022    import java.io.Serializable;
023    
024    import java.util.Objects;
025    
026    /**
027     * @author Milen Dyankov
028     * @author Michael C. Han
029     */
030    @ProviderType
031    public class Capability implements Serializable {
032    
033            public Capability(String name, String value) {
034                    _name = name;
035                    _value = value;
036            }
037    
038            @Override
039            public boolean equals(Object obj) {
040                    if (this == obj) {
041                            return true;
042                    }
043    
044                    if (!(obj instanceof Capability)) {
045                            return false;
046                    }
047    
048                    Capability capability = (Capability)obj;
049    
050                    if (Objects.equals(_name, capability._name) &&
051                            Objects.equals(_value, capability._value)) {
052    
053                            return true;
054                    }
055    
056                    return false;
057            }
058    
059            public String getName() {
060                    return _name;
061            }
062    
063            public String getValue() {
064                    return _value;
065            }
066    
067            @Override
068            public int hashCode() {
069                    int hash = HashUtil.hash(0, _name);
070    
071                    return HashUtil.hash(hash, _value);
072            }
073    
074            @Override
075            public String toString() {
076                    StringBundler sb = new StringBundler(5);
077    
078                    sb.append("{name=");
079                    sb.append(_name);
080                    sb.append(", value=");
081                    sb.append(_value);
082                    sb.append("}");
083    
084                    return sb.toString();
085            }
086    
087            private final String _name;
088            private final String _value;
089    
090    }