001 /* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 * 014 * See the NOTICE file distributed with this work for additional 015 * information regarding copyright ownership. 016 */ 017 018 package com.osbcp.cssparser; 019 020 /** 021 * Represents a CSS selector. 022 * 023 * @author <a href="mailto:christoffer@christoffer.me">Christoffer Pettersson</a> 024 */ 025 026 public final class Selector { 027 028 private String name; 029 030 /** 031 * Creates a new selector. 032 * 033 * @param name Selector name. 034 */ 035 036 public Selector(final String name) { 037 this.name = name; 038 } 039 040 @Override 041 public String toString() { 042 return name; 043 } 044 045 @Override 046 public boolean equals(final Object object) { 047 048 if (object instanceof Selector) { 049 050 Selector target = (Selector) object; 051 052 return target.name.equalsIgnoreCase(name); 053 054 } 055 056 return false; 057 058 } 059 060 @Override 061 public int hashCode() { 062 return toString().hashCode(); 063 } 064 065 }