woolpack.factory
クラス FactoryUtils

java.lang.Object
  上位を拡張 woolpack.factory.FactoryUtils

public final class FactoryUtils
extends Object

ファクトリのユーティリティです。


フィールドの概要
static Fn<Object,Map<String,Object>,RuntimeException> LINKED_MAP_FACTORY
          LinkedHashMapを生成する関数です。
 
メソッドの概要
static
<C,K,E extends Exception>
Fn<C,Void,E>
cache(Fn<? super C,? extends Map<? super K,Object>,? extends E> mapGetter, Fn<? super C,? extends K,? extends E> keyGetter, Fn<? super C,?,? extends E> maker, EL el)
          委譲先で生成したオブジェクトをMapにキャッシュして コンテキスト役に設定する関数を生成します。
static
<C,K,E extends Exception>
Fn<C,Object,E>
cache(Fn<? super C,? extends Map<? super K,Object>,? extends E> mapGetter, Fn<? super C,K,? extends E> keyGetter, Fn<? super C,?,? extends E> maker)
          委譲先で生成したオブジェクトをMapにキャッシュして返す関数を生成します。
static
<C,K,E extends Exception>
Fn<C,Void,E>
concurrentCache(Fn<? super C,? extends ConcurrentMap<? super K,Object>,? extends E> mapGetter, Fn<? super C,? extends K,? extends E> keyGetter, Fn<? super C,?,? extends E> maker, EL el)
          委譲先で生成したオブジェクトをConcurrentMapにキャッシュして コンテキスト役に設定する関数を生成します。
static
<C,K,E extends Exception>
Fn<C,Object,E>
concurrentCache(Fn<? super C,? extends ConcurrentMap<? super K,Object>,? extends E> mapGetter, Fn<? super C,K,? extends E> keyGetter, Fn<? super C,?,? extends E> maker)
          委譲先で生成したオブジェクトをConcurrentMapにキャッシュして返す関数を生成します。
static Fn<Object,Object,RuntimeException> doEL(GettingEL gettingEL)
          GettingELに委譲する関数を生成します。
static
<C> Fn<C,Reader,IOException>
inputStreamReaderFactory(Fn<? super C,? extends InputStream,? extends IOException> inputStreamFactory, String charset)
          委譲先で取得したInputStreamReaderに変換する関数を生成します。
static
<R> Fn<Object,R,Exception>
newInstance(Class<R> clazz)
          Class.newInstance()を使用するオブジェクトファクトリを生成します。
static Fn<Object,InputStream,UnsupportedEncodingException> stringInputStreamFactory(String charset, String content)
          文字列のバイト配列表現を返すテスト用の関数を生成します。
static Fn<Object,StringReader,RuntimeException> stringReaderFactory(String content)
          StringReaderを返すテスト用の関数を生成します。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

LINKED_MAP_FACTORY

public static final Fn<Object,Map<String,Object>,RuntimeException> LINKED_MAP_FACTORY
LinkedHashMapを生成する関数です。
適用しているデザインパターン:MapのAbstract Factory。

メソッドの詳細

cache

public static <C,K,E extends Exception> Fn<C,Object,E> cache(Fn<? super C,? extends Map<? super K,Object>,? extends E> mapGetter,
                                                             Fn<? super C,K,? extends E> keyGetter,
                                                             Fn<? super C,?,? extends E> maker)
委譲先で生成したオブジェクトをMapにキャッシュして返す関数を生成します。
適用しているデザインパターン:オブジェクト生成処理のProxy、Flyweight。

型パラメータ:
C -
K -
E -
パラメータ:
mapGetter - キャッシュ用マップを取得する委譲先。
keyGetter - キャッシュに格納する際のキーを取得する委譲先。
maker - キャッシュするファイルを生成するファクトリ。
戻り値:
関数。

concurrentCache

public static <C,K,E extends Exception> Fn<C,Object,E> concurrentCache(Fn<? super C,? extends ConcurrentMap<? super K,Object>,? extends E> mapGetter,
                                                                       Fn<? super C,K,? extends E> keyGetter,
                                                                       Fn<? super C,?,? extends E> maker)
委譲先で生成したオブジェクトをConcurrentMapにキャッシュして返す関数を生成します。 ConcurrentMap.putIfAbsent(Object, Object)を使用して返却値の一意性を保証しますが、 ひとつの返却値に対応するインスタンス生成の委譲が複数回発生する可能性があります。
適用しているデザインパターン:オブジェクト生成処理のProxy、Flyweight。

型パラメータ:
C -
K -
E -
パラメータ:
mapGetter - キャッシュ用マップを取得する委譲先。
keyGetter - キャッシュに格納する際のキーを取得する委譲先。
maker - キャッシュするファイルを生成するファクトリ。
戻り値:
関数。

cache

public static <C,K,E extends Exception> Fn<C,Void,E> cache(Fn<? super C,? extends Map<? super K,Object>,? extends E> mapGetter,
                                                           Fn<? super C,? extends K,? extends E> keyGetter,
                                                           Fn<? super C,?,? extends E> maker,
                                                           EL el)
委譲先で生成したオブジェクトをMapにキャッシュして コンテキスト役に設定する関数を生成します。
適用しているデザインパターン:オブジェクト生成処理のProxy、Flyweight。

型パラメータ:
C -
K -
E -
パラメータ:
mapGetter - キャッシュ用マップを取得する委譲先。
keyGetter - キャッシュに格納する際のキーを取得する委譲先。
maker - キャッシュするファイルを生成するファクトリ。
el - makerと本インスタンスによって値が格納される位置。
戻り値:
関数。

concurrentCache

public static <C,K,E extends Exception> Fn<C,Void,E> concurrentCache(Fn<? super C,? extends ConcurrentMap<? super K,Object>,? extends E> mapGetter,
                                                                     Fn<? super C,? extends K,? extends E> keyGetter,
                                                                     Fn<? super C,?,? extends E> maker,
                                                                     EL el)
委譲先で生成したオブジェクトをConcurrentMapにキャッシュして コンテキスト役に設定する関数を生成します。 ConcurrentMap.putIfAbsent(Object, Object)を使用して返却値の一意性を保証しますが、 ひとつの返却値に対応するインスタンス生成の委譲が複数回発生する可能性があります。
適用しているデザインパターン:オブジェクト生成処理のProxy、Flyweight。

型パラメータ:
C -
K -
E -
パラメータ:
mapGetter - キャッシュ用マップを取得する委譲先。
keyGetter - キャッシュに格納する際のキーを取得する委譲先。
maker - キャッシュするファイルを生成するファクトリ。
el - makerと本インスタンスによって値が格納される位置。
戻り値:
関数。

doEL

public static Fn<Object,Object,RuntimeException> doEL(GettingEL gettingEL)
GettingELに委譲する関数を生成します。
適用しているデザインパターン:Adapter。

パラメータ:
gettingEL - 委譲先。
戻り値:
関数。

inputStreamReaderFactory

public static <C> Fn<C,Reader,IOException> inputStreamReaderFactory(Fn<? super C,? extends InputStream,? extends IOException> inputStreamFactory,
                                                                    String charset)
委譲先で取得したInputStreamReaderに変換する関数を生成します。 文字セットが不正な場合、取得したInputStream.close()を呼び出します。
適用しているデザインパターン:InputStreamのAbstract FactoryのAdapter。

型パラメータ:
C -
パラメータ:
inputStreamFactory - InputStreamのファクトリ。
charset - 文字セット。
戻り値:
関数。

newInstance

public static <R> Fn<Object,R,Exception> newInstance(Class<R> clazz)
Class.newInstance()を使用するオブジェクトファクトリを生成します。
適用しているデザインパターン:オブジェクトのAbstract Factory。

型パラメータ:
R -
パラメータ:
clazz - 生成するクラスの型。
戻り値:
関数。

stringInputStreamFactory

public static Fn<Object,InputStream,UnsupportedEncodingException> stringInputStreamFactory(String charset,
                                                                                           String content)
文字列のバイト配列表現を返すテスト用の関数を生成します。
適用しているデザインパターン:InputStreamのAbstract Factory。

パラメータ:
charset - 文字セット。
content - 文字列。
戻り値:
関数。

stringReaderFactory

public static Fn<Object,StringReader,RuntimeException> stringReaderFactory(String content)
StringReaderを返すテスト用の関数を生成します。
適用しているデザインパターン:StringReaderのAbstract Factory。

パラメータ:
content - 文字列。
戻り値:
関数。


Copyright (C) 2006-2007 Takahiro Nakamura. All rights reserved.