package to.etc.domui.component.misc;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import to.etc.domui.dom.html.Span;

import java.util.Objects;

/**
 * Generic set of font-based icons which must be implemented by at least one of the
 * font sets used.
 *
 * @author <a href="mailto:jal@etc.to">Frits Jalvingh</a>
 * Created on 4-8-17.
 */
@NonNullByDefault
final public class FontIcon extends Span {
	@Nullable
	private String m_iconName;

	public FontIcon(@Nullable String name) {
		m_iconName = name;
	}

	@Override
	public FontIcon css(String... classNames) {
		super.css(classNames);
		return this;
	}

	@Override public void createContent() throws Exception {
		//removeFaClasses();
		addCssClass("fa");
		if(null != m_iconName)
			addCssClass(m_iconName);
	}

	private void removeFaClasses() {
		String cssClass = getCssClass();
		if(null == cssClass)
			return;

		String[] split = cssClass.split("\\s+");
		for(String s : split) {
			if(s.equals("fa") || s.startsWith("fa-")) {
				removeCssClass(s);
			}
		}
	}

	public void setIconName(String iconName) {
		if(Objects.equals(iconName, m_iconName))
			return;
		String oldName = m_iconName;
		if(null != oldName)
			removeCssClass(oldName);
		if(null != iconName)
			addCssClass(iconName);
		m_iconName = iconName;
	}
}

@@ -465,22 +465,25 @@
 private 
-String
+IFontIcon
  m_iconN
@@ -515,22 +515,25 @@
 ullable 
-String
+IFontIcon
  name) %7B
@@ -760,16 +760,51 @@
 (%22fa%22);%0A
+%09%09IFontIcon iconName = m_iconName;%0A
 %09%09if(nul
@@ -808,18 +808,16 @@
 null != 
-m_
 iconName
@@ -833,26 +833,24 @@
 ssClass(
-m_
 iconName
 );%0A%09%7D%0A%0A%09
@@ -837,24 +837,42 @@
 ass(iconName
+.getCssClassName()
 );%0A%09%7D%0A%0A%09priv
@@ -1147,22 +1147,25 @@
 conName(
-String
+IFontIcon
  iconNam
@@ -1225,22 +1225,25 @@
 turn;%0A%09%09
-String
+IFontIcon
  oldName
@@ -1300,24 +1300,42 @@
 lass(oldName
+.getCssClassName()
 );%0A%09%09if(null
@@ -1371,16 +1371,34 @@
 iconName
+.getCssClassName()
 );%0A%09%09m_i

Make FontIcon accept only IFontIcon enums.