litesoft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
package org.litesoft.core;
import java.util.*;
public interface ClassToInstanceMapper
{
public interface NoInstanceFactory<T>
{
/**
* @return !null
*/
Class<T> getFor();
/**
* @return should probably not be null
*/
T createInstance();
}
/**
* Get a List (!null) of all the currently "set" Factories
*/
List<NoInstanceFactory<?>> getNoInstanceFactories();
/**
* Set a Factory into this Mapper. This Factory is used to create an Instance (and register it) when "get" is called and no Instance is currently registered.
*
* @param pFactory !null
*
* @throws IllegalArgumentException if pFactory is null
* @throws IllegalStateException if this is a duplicate Factory
*/
void setNoInstanceFactory( NoInstanceFactory<?> pFactory );
/**
* @param pClass !null
*
* @return null if not found or current instance set / replaced
*
* @throws IllegalArgumentException if pClass is null
*/
<T> T checkGet( Class<T> pClass )
throws IllegalArgumentException;
/**
* Get the previously 'registered' (set &/ replaced) instance of pClass.
* NOTE: if there is no instance currently registered, then one is attempted to be added using a previously registered NoInstanceFactory.
*
* @param pClass !null
*
* @return instance of pClass
*
* @throws IllegalArgumentException if pClass is null
* @throws IllegalStateException if no instance previously 'registered' for pClass
*/
<T> T get( Class<T> pClass )
throws IllegalArgumentException, IllegalStateException;
/**
* Set or register an instance (pInstance) of pClass, that is NOT currently 'registered' (previously set &/ replaced, but not subsequently removed)
*
* @param pClass !null
* @param pInstance !null
*
* @throws IllegalArgumentException if either pClass or pInstance is null
* @throws IllegalStateException if an instance for pClass IS currently 'registered'
*/
<T, V extends T> void set( Class<T> pClass, V pInstance )
throws IllegalArgumentException, IllegalStateException;
/**
* Replace or re-register an instance (pInstance) of pClass, that IS currently 'registered' (previously set &/ replaced, but not subsequently removed)
*
* @param pClass !null
* @param pInstance !null
*
* @throws IllegalArgumentException if either pClass or pInstance is null
* @throws IllegalStateException if an instance for pClass is NOT currently 'registered'
*/
<T, V extends T> void replace( Class<T> pClass, V pInstance )
throws IllegalArgumentException, IllegalStateException;
/**
* Remove the instance (pInstance) of pClass, that IS currently 'registered' (previously set &/ replaced, but not subsequently removed)
*
* @param pClass !null
* @param pInstance !null
*
* @throws IllegalArgumentException if either pClass or pInstance is null
* @throws IllegalStateException if pInstance of pClass is NOT currently 'registered' for pClass
*/
<T, V extends T> void remove( Class<T> pClass, V pInstance )
throws IllegalArgumentException, IllegalStateException;
void clearAllInstances();
}
|
Revision |
Author |
Commited |
Message |
2
|
GeorgeS
|
Sun 07 Feb, 2010 12:50:58 +0000 |
|