stringid.java
来自「CroftSoft Code Library是一个开源的可移植的纯Java游戏库」· Java 代码 · 共 102 行
JAVA
102 行
package com.croftsoft.core.util.id; import com.croftsoft.core.lang.NullArgumentException;
/*********************************************************************
* An Id implementation backed by a String.
*
* @version
* 2003-06-07 * @since
* 2000-01-16 * @author
* <a href="http://www.croftsoft.com/">David Wallace Croft</a>
*********************************************************************/
public class StringId implements Id
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
{
private static final long serialVersionUID = 0L; //
private final String s;
//////////////////////////////////////////////////////////////////////
// constructor method
//////////////////////////////////////////////////////////////////////
/********************************************************************* * Main constructor. *
* @throws NullArgumentException
*
* If argument is null.
*********************************************************************/
public StringId ( String s )
//////////////////////////////////////////////////////////////////////
{ NullArgumentException.check ( this.s = s );
}
//////////////////////////////////////////////////////////////////////
// accessor method
//////////////////////////////////////////////////////////////////////
public String getS ( ) { return s; }
//////////////////////////////////////////////////////////////////////
// Id interface methods
//////////////////////////////////////////////////////////////////////
public boolean equals ( Object other )
//////////////////////////////////////////////////////////////////////
{
if ( other == null ) return false;
if ( !getClass ( ).equals ( other.getClass ( ) ) ) return false;
return s.equals ( ( ( StringId ) other ).s );
}
public int hashCode ( )
//////////////////////////////////////////////////////////////////////
{
return s.hashCode ( );
}
public Object clone ( )
//////////////////////////////////////////////////////////////////////
{
try
{
return super.clone ( );
}
catch ( CloneNotSupportedException ex )
{
// This will never happen.
throw new RuntimeException ( );
}
}
//////////////////////////////////////////////////////////////////////
// Other methods
//////////////////////////////////////////////////////////////////////
/*********************************************************************
* return s;
*********************************************************************/
public String toString ( )
//////////////////////////////////////////////////////////////////////
{
return s;
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?