Created
January 25, 2012 17:33
-
-
Save 448jp/1677482 to your computer and use it in GitHub Desktop.
シングルトンパターン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.ceroan { | |
import flash.errors.*; | |
/** | |
* Singleton | |
* @author OKI Yoshiya (ceroan) | |
*/ | |
public class Singleton { | |
private static var _instance:Singleton = new Singleton(); | |
private static var _uid:String; | |
public function Singleton() { | |
if (_instance) throw new IllegalOperationError("Singletonクラスはインスタンスを生成できません。"); | |
} | |
/** | |
* Singletonクラスにアクセスするためのインスタンスを取得します。 | |
* @return Singletonインスタンスを返します。 | |
*/ | |
public static function get instance():Singleton { | |
return _instance; | |
} | |
public function get uid():String { return _uid; } | |
public function set uid(value:String):void { | |
_uid = value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment