litesoft
@ 953
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 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.core; import org.litesoft.commonfoundation.annotations.*; import java.util.*; public interface ClassToInstanceMapper { public interface NoInstanceFactory<T> { @NotNull Class<T> getFor(); @NotNull T createInstance(); } /** * Get all the currently "registered" Factories */ @NotNull List<NoInstanceFactory<?>> getNoInstanceFactories(); /** * @return current instance registered, or null */ @Nullable <T> T checkGet( @NotNull Class<T> pClass ); /** * Get the previously 'registered' (register &/ replaced) instance of pClass. * NOTE: if there is no instance currently registered, then one is attempted to be added using a previously registered NoInstanceFactory. * * @return instance of pClass * * @throws IllegalStateException if no instance previously 'registered' for pClass */ @NotNull <T> T get( @NotNull Class<T> pClass ) throws IllegalStateException; /** * Register 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. * These factories can be copied into new ClassToInstanceMapper(s) so that a "singleton" instance exists "per" ClassToInstanceMapper. * * @throws IllegalStateException if this is a duplicate Factory */ void register( @NotNull NoInstanceFactory<?> pFactory ) throws IllegalStateException; /** * Register an instance (pInstance) of pClass, that is NOT currently 'registered' (previously registered, but not subsequently removed) * * @throws IllegalStateException if an instance for pClass IS currently 'registered' */ <T, V extends T> void register( @NotNull Class<T> pClass, @NotNull V pInstance ) throws IllegalStateException; /** * Register an instance (pInstance) of pClass, regardless of its current registered state. */ <T, V extends T> void forceRegister( @NotNull Class<T> pClass, @NotNull V pInstance ); /** * Remove the instance (pInstance) of pClass, that IS currently 'registered' (previously register &/ 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( @NotNull Class<T> pClass, V pInstance ) throws IllegalArgumentException, IllegalStateException; void clearAllInstances(); } |
Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/core/ClassToInstanceMapper.java
Revision | Author | Commited | Message |
---|---|---|---|
953 Diff | GeorgeS | Fri 20 Jun, 2014 23:12:43 +0000 | Drop Nas-Video. |
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
947 Diff | GeorgeS | Fri 06 Jun, 2014 23:36:56 +0000 | Correct Spelling of package! |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |