Back to project page Kite.
The source code is released under:
Apache License
If you think the Android project Kite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.kite.wire; /*from w w w. jav a 2s. c o m*/ import android.util.SparseArray; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Map; import java.util.Set; /** * A helper class for injecting values. * * @author Nikolay Soroka */ class ClientFacade { private Map<Class<?>, Field> wired; private SparseArray<Method> asyncCallbacks; public static ClientFacade build(Class<?> targetClass) { ClientFacade clientFacade = new ClientFacade(); clientFacade.wired = InterfaceFinder.findAllWired(targetClass); clientFacade.asyncCallbacks = InterfaceFinder.findAsyncCallbacks(targetClass); return clientFacade; } public Set<Class<?>> getWiredClasses(){ return wired.keySet(); } public SparseArray<Method> getAsyncCallbacks() { return asyncCallbacks; } public void fillWith(Object clientInstance, Class<?> type, Object value){ Field field = wired.get(type); if (field != null){ field.setAccessible(true); try { field.set(clientInstance, value); } catch (IllegalAccessException e) { // log this out } } } private ClientFacade(){ } }