Created
September 20, 2013 12:01
-
-
Save flavienlaurent/6636457 to your computer and use it in GitHub Desktop.
Using BoundBox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package thisisapackage; | |
import java.util.List; | |
public class A { | |
public void doIt(List<String> strings) { | |
// do it | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package thisisapackage; | |
import java.lang.String; | |
import java.lang.reflect.Constructor; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
import java.util.List; | |
import org.boundbox.BoundBoxException; | |
@SuppressWarnings("all") | |
public final class BoundBoxOfA { | |
private A boundObject; | |
private static Class<A> boundClass = A.class; | |
public BoundBoxOfA(A boundObject) { | |
this.boundObject = boundObject; | |
} | |
// ****************************** | |
// Access to constructors | |
// ****************************** | |
public static A boundBox_new() { | |
try { | |
Constructor<? extends A> method = boundClass.getDeclaredConstructor(); | |
method.setAccessible(true); | |
return (A) method.newInstance(); | |
} | |
catch( IllegalAccessException e ) { | |
throw new BoundBoxException(e); | |
} | |
catch( IllegalArgumentException e ) { | |
throw new BoundBoxException(e); | |
} | |
catch( InvocationTargetException e ) { | |
throw new BoundBoxException(e); | |
} | |
catch( NoSuchMethodException e ) { | |
throw new BoundBoxException(e); | |
} | |
catch( InstantiationException e ) { | |
throw new BoundBoxException(e); | |
} | |
} | |
// ****************************** | |
// Direct access to fields | |
// ****************************** | |
// ****************************** | |
// Access to methods | |
// ****************************** | |
public void doIt(List<String> arg0) { | |
try { | |
Method method = com.oodrive.mobile.android.sharebox.A.class.getDeclaredMethod("doIt",java.util.List<java.lang.String>.class); | |
method.setAccessible(true); | |
method.invoke(boundObject, arg0); | |
} | |
catch( IllegalAccessException e ) { | |
throw new BoundBoxException(e); | |
} | |
catch( IllegalArgumentException e ) { | |
throw new BoundBoxException(e); | |
} | |
catch( InvocationTargetException e ) { | |
throw new BoundBoxException(e); | |
} | |
catch( NoSuchMethodException e ) { | |
throw new BoundBoxException(e); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package thisisanotherpackage; | |
import org.boundbox.BoundBox; | |
import thisisapackage.A; | |
@BoundBox(boundClass = A.class) | |
public class TestingBoundBox { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment