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.portlet.asset.model;
016    
017    import com.liferay.portal.kernel.util.HashUtil;
018    import com.liferay.portal.kernel.util.Validator;
019    
020    /**
021     * @author Roberto D??az
022     */
023    public class AssetQueryRule {
024    
025            public AssetQueryRule(
026                    boolean contains, boolean andOperator, String name, String[] values) {
027    
028                    _contains = contains;
029                    _andOperator = andOperator;
030                    _name = name;
031                    _values = values;
032            }
033    
034            @Override
035            public boolean equals(Object obj) {
036                    if (this == obj) {
037                            return true;
038                    }
039    
040                    if (!(obj instanceof AssetQueryRule)) {
041                            return false;
042                    }
043    
044                    AssetQueryRule assetQueryRule = (AssetQueryRule)obj;
045    
046                    if (Validator.equals(_contains, assetQueryRule._contains) &&
047                            Validator.equals(_andOperator, assetQueryRule._andOperator) &&
048                            Validator.equals(_name, assetQueryRule._name)) {
049    
050                            return true;
051                    }
052    
053                    return false;
054            }
055    
056            public String getName() {
057                    return _name;
058            }
059    
060            public String[] getValues() {
061                    return _values;
062            }
063    
064            @Override
065            public int hashCode() {
066                    int hash = HashUtil.hash(0, _contains);
067    
068                    hash = HashUtil.hash(hash, _andOperator);
069    
070                    return HashUtil.hash(hash, _name);
071            }
072    
073            public boolean isAndOperator() {
074                    return _andOperator;
075            }
076    
077            public boolean isContains() {
078                    return _contains;
079            }
080    
081            public void setAndOperator(boolean andOperator) {
082                    _andOperator = andOperator;
083            }
084    
085            public void setContains(boolean contains) {
086                    _contains = contains;
087            }
088    
089            public void setName(String name) {
090                    _name = name;
091            }
092    
093            public void setValues(String[] values) {
094                    _values = values;
095            }
096    
097            private boolean _andOperator;
098            private boolean _contains;
099            private String _name;
100            private String[] _values;
101    
102    }