enumcodegenerator.javajet

来自「基于eclipse的工具开发代码」· JAVAJET 代码 · 共 52 行

JAVAJET
52
字号
<%@ jet package="com.cownew.enumgenerator.wizards" class="EnumCodeGenerator" 
  imports="java.util.*"%>
<%
  EnumGenArgInfo argInfo = (EnumGenArgInfo)argument;
  Set<String> enumItems = argInfo.getItems();
  String className = argInfo.getClassName();
  String packageName = argInfo.getPackageName();
%>

package <%=packageName%>;

public class <%=className%>
{
	private String type;
	<%for(String item:enumItems){%>
	public 	<%=className%> <%=item%> = new <%=className%>("<%=item%>");
	<%}%>
	
	private <%=className%>(String type)
	{
		super();
		this.type = type;
	}

	public int hashCode()
	{
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final <%=className%> other = (<%=className%>) obj;
		if (type == null)
		{
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}


}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?