Skip to content

Instantly share code, notes, and snippets.

@flavienlaurent
Created September 20, 2013 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flavienlaurent/6636457 to your computer and use it in GitHub Desktop.
Save flavienlaurent/6636457 to your computer and use it in GitHub Desktop.
Using BoundBox
package thisisapackage;
import java.util.List;
public class A {
public void doIt(List<String> strings) {
// do it
}
}
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);
}
}
}
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