| 186 | } |
| 187 | |
| 188 | public static class BaseAttributable<E> implements Attributable<E> { |
| 189 | protected final LinkedHashMap<String, Attribute> attributes = new LinkedHashMap<>(); |
| 190 | |
| 191 | @Override |
| 192 | @SuppressWarnings("unchecked") |
| 193 | public E add(Attribute attr) { |
| 194 | attributes.put(attr.name, attr); |
| 195 | return (E) this; |
| 196 | } |
| 197 | |
| 198 | protected void emit(List<String> opts) { |
| 199 | for (Attribute a : attributes.values()) { |
| 200 | a.emit(opts); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | @Override |
| 205 | public String toString() { |
| 206 | return "Attributable{" + "attributes=" + attributes + '}'; |
| 207 | } |
| 208 | |
| 209 | public Map<String, Attribute> getAttributes() { |
| 210 | return attributes; |
| 211 | } |
| 212 | |
| 213 | @Override |
| 214 | public boolean equals(Object o) { |
| 215 | if (this == o) { return true; } |
| 216 | if (o == null || getClass() != o.getClass()) { return false; } |
| 217 | BaseAttributable<?> that = (BaseAttributable<?>) o; |
| 218 | return attributes.equals(that.attributes); |
| 219 | } |
| 220 | |
| 221 | @Override |
| 222 | public int hashCode() { |
| 223 | return Objects.hash(attributes); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | interface Labeled<E> extends Attributable<E> { |
| 228 | default E html(String html) { |
nothing calls this directly
no outgoing calls
no test coverage detected