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 com.liferay.portal.kernel.util.HashUtil;
018    import com.liferay.portal.kernel.util.StringBundler;
019    import com.liferay.portal.kernel.util.Validator;
020    
021    import java.io.Serializable;
022    
023    /**
024     * @author Milen Dyankov
025     * @author Michael C. Han
026     */
027    public class Capability implements Serializable {
028    
029            public Capability(String name, String value) {
030                    _name = name;
031                    _value = value;
032            }
033    
034            @Override
035            public boolean equals(Object obj) {
036                    if (this == obj) {
037                            return true;
038                    }
039    
040                    if (!(obj instanceof Capability)) {
041                            return false;
042                    }
043    
044                    Capability capability = (Capability)obj;
045    
046                    if (Validator.equals(_name, capability._name) &&
047                            Validator.equals(_value, capability._value)) {
048    
049                            return true;
050                    }
051    
052                    return false;
053            }
054    
055            public String getName() {
056                    return _name;
057            }
058    
059            public String getValue() {
060                    return _value;
061            }
062    
063            @Override
064            public int hashCode() {
065                    int hash = HashUtil.hash(0, _name);
066    
067                    return HashUtil.hash(hash, _value);
068            }
069    
070            @Override
071            public String toString() {
072                    StringBundler sb = new StringBundler(5);
073    
074                    sb.append("{name=");
075                    sb.append(_name);
076                    sb.append(", value=");
077                    sb.append(_value);
078                    sb.append("}");
079    
080                    return sb.toString();
081            }
082    
083            private final String _name;
084            private final String _value;
085    
086    }