------------------------------------------------------------ revno: 15687 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Sun 2014-06-15 15:33:54 +0200 message: add alias map from our basic interfaces => base implementations, useful for looking up exported properties on a core interface where the concrete implementation is the one who is annotated for export. modified: dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java
-- lp:dhis2 https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk Your team DHIS 2 developers is subscribed to branch lp:dhis2. To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java 2014-06-09 14:26:55 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/AbstractPropertyIntrospectorService.java 2014-06-15 13:33:54 +0000 @@ -28,8 +28,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE */ +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import org.hisp.dhis.common.BaseDimensionalObject; +import org.hisp.dhis.common.BaseIdentifiableObject; +import org.hisp.dhis.common.BaseNameableObject; +import org.hisp.dhis.common.DimensionalObject; +import org.hisp.dhis.common.IdentifiableObject; +import org.hisp.dhis.common.NameableObject; import java.util.List; import java.util.Map; @@ -39,6 +46,13 @@ */ public abstract class AbstractPropertyIntrospectorService implements PropertyIntrospectorService { + // simple alias map for our concrete implementations of the core interfaces. + private static final ImmutableMap<Class<?>, Class<?>> BASE_ALIAS_MAP = ImmutableMap.<Class<?>, Class<?>>builder() + .put( IdentifiableObject.class, BaseIdentifiableObject.class ) + .put( NameableObject.class, BaseNameableObject.class ) + .put( DimensionalObject.class, BaseDimensionalObject.class ) + .build(); + private Map<Class<?>, Map<String, Property>> classMapCache = Maps.newHashMap(); @Override @@ -50,6 +64,11 @@ @Override public Map<String, Property> getPropertiesMap( Class<?> klass ) { + if ( BASE_ALIAS_MAP.containsKey( klass ) ) + { + klass = BASE_ALIAS_MAP.get( klass ); + } + if ( !classMapCache.containsKey( klass ) ) { classMapCache.put( klass, scanClass( klass ) );
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp