View Javadoc
1   /*
2    * Copyright (C) 2016 Ronald Jack Jenkins Jr.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16   */
17  package info.ronjenkins.slf4bukkit;
18  
19  import java.util.Collections;
20  import java.util.Iterator;
21  
22  import org.bukkit.ChatColor;
23  import org.slf4j.Marker;
24  
25  /**
26   * SLF4J markers that map to {@link ChatColor}s. These markers never contain any
27   * references (other markers).
28   *
29   * @author Ronald Jack Jenkins Jr.
30   */
31  public enum BukkitColorMarker implements Marker {
32  
33    AQUA(ChatColor.AQUA), BLACK(ChatColor.BLACK), BLUE(ChatColor.BLUE),
34    BOLD(ChatColor.BOLD), DARK_AQUA(ChatColor.DARK_AQUA),
35    DARK_BLUE(ChatColor.DARK_BLUE), DARK_GRAY(ChatColor.DARK_GRAY),
36    DARK_GREEN(ChatColor.DARK_GREEN), DARK_PURPLE(ChatColor.DARK_PURPLE),
37    DARK_RED(ChatColor.DARK_RED), GOLD(ChatColor.GOLD), GRAY(ChatColor.GRAY),
38    GREEN(ChatColor.GREEN), ITALIC(ChatColor.ITALIC),
39    LIGHT_PURPLE(ChatColor.LIGHT_PURPLE), MAGIC(ChatColor.MAGIC),
40    RED(ChatColor.RED), RESET(ChatColor.RESET),
41    STRIKETHROUGH(ChatColor.STRIKETHROUGH), UNDERLINE(ChatColor.UNDERLINE),
42    WHITE(ChatColor.WHITE), YELLOW(ChatColor.YELLOW);
43  
44    private final ChatColor value;
45  
46    private BukkitColorMarker(final ChatColor value) {
47      this.value = value;
48    }
49  
50    /**
51     * Not supported.
52     *
53     * @param reference
54     *          unused.
55     * @throws UnsupportedOperationException
56     *           always.
57     */
58    @Override
59    public void add(final Marker reference) {
60      throw new UnsupportedOperationException();
61    }
62  
63    /*
64     * Marker API
65     */
66  
67    /**
68     * These markers never have references.
69     *
70     * @return false.
71     */
72    @Override
73    public boolean contains(final Marker other) {
74      // TODO Auto-generated method stub
75      return false;
76    }
77  
78    /**
79     * These markers never have references.
80     *
81     * @return false.
82     */
83    @Override
84    public boolean contains(final String name) {
85      return false;
86    }
87  
88    /**
89     * Returns the enum name of this marker.
90     *
91     * @return never null.
92     */
93    @Override
94    public String getName() {
95      return this.name();
96    }
97  
98    /**
99     * Returns the Bukkit color object associated with this marker.
100    *
101    * @return never null.
102    */
103   public ChatColor getValue() {
104     return this.value;
105   }
106 
107   /**
108    * These markers never have references.
109    *
110    * @return false.
111    */
112   @Override
113   @SuppressWarnings({ "all", "deprecation" })
114   public boolean hasChildren() {
115     return false;
116   }
117 
118   /**
119    * These markers never have references.
120    *
121    * @return false.
122    */
123   @Override
124   public boolean hasReferences() {
125     // TODO Auto-generated method stub
126     return false;
127   }
128 
129   /**
130    * These markers never have references.
131    *
132    * @return false.
133    */
134   @Override
135   public Iterator<Marker> iterator() {
136     return Collections.emptyIterator();
137   }
138 
139   /**
140    * Not supported.
141    *
142    * @param reference
143    *          unused.
144    * @throws UnsupportedOperationException
145    *           always.
146    */
147   @Override
148   public boolean remove(final Marker reference) {
149     throw new UnsupportedOperationException();
150   }
151 
152 }