001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.gui.mappaint; 003 004import java.util.Locale; 005import java.util.Objects; 006 007/** 008 * A MapCSS keyword. 009 * 010 * For example "<code>round</code>" is a keyword in 011 * <pre>linecap: round;</pre> 012 * Keywords are similar to a Java enum value. In accordance with the CSS 013 * specification, they are parsed case insensitive. 014 */ 015public class Keyword { 016 public final String val; 017 018 public Keyword(String val) { 019 this.val = val.toLowerCase(Locale.ENGLISH); 020 } 021 022 @Override 023 public String toString() { 024 return "Keyword{" + val + '}'; 025 } 026 027 @Override 028 public boolean equals(Object obj) { 029 if (this == obj) return true; 030 if (obj == null || getClass() != obj.getClass()) return false; 031 Keyword keyword = (Keyword) obj; 032 return Objects.equals(val, keyword.val); 033 } 034 035 @Override 036 public int hashCode() { 037 return Objects.hash(val); 038 } 039 040 public static final Keyword AUTO = new Keyword("auto"); 041 public static final Keyword BOTTOM = new Keyword("bottom"); 042 public static final Keyword CENTER = new Keyword("center"); 043 public static final Keyword DEFAULT = new Keyword("default"); 044 public static final Keyword RIGHT = new Keyword("right"); 045 public static final Keyword THINNEST = new Keyword("thinnest"); 046}