List<Field> fields = new Mirror().on(bean.getClass()).reflectAll().fields(); for (Field field : fields) { if (Logger.class.isAssignableFrom(field.getType()) && new Mirror().on(field).reflect().annotation(InjectLogger.class) != null) { new Mirror().on(bean).set().field(field).withValue(LoggerFactory.getLogger(bean.getClass()));
private Mirror getMirror( RepositorySystemSession session, ArtifactRepository repository ) { if ( session != null ) { org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector(); if ( selector != null ) { RemoteRepository repo = selector.getMirror( RepositoryUtils.toRepo( repository ) ); if ( repo != null ) { Mirror mirror = new Mirror(); mirror.setId( repo.getId() ); mirror.setUrl( repo.getUrl() ); mirror.setLayout( repo.getContentType() ); return mirror; } } } return null; }
private Mirror getMirror( RepositorySystemSession session, ArtifactRepository repository ) { if ( session != null ) { org.eclipse.aether.repository.MirrorSelector selector = session.getMirrorSelector(); if ( selector != null ) { RemoteRepository repo = selector.getMirror( RepositoryUtils.toRepo( repository ) ); if ( repo != null ) { Mirror mirror = new Mirror(); mirror.setId( repo.getId() ); mirror.setUrl( repo.getUrl() ); mirror.setLayout( repo.getContentType() ); return mirror; } } } return null; }
Mirror mirror = new Mirror(); for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
public static <T> Mirror<T> createMirror(T value) { checkTypeSupported(value); return new Mirror(value); }
public boolean isPendingToRequest( final Object tag ) { final Object mObject = new Mirror().on( this.requestQueue ).get().field( "mCurrentRequests" ); final Set<Request<?>> mCurrentRequests = ( Set<Request<?>> ) mObject; for ( final Request<?> request : mCurrentRequests ) { Log.d( "tagIsPendingToRequest ", "tag: " + request.getTag() ); if ( request.getTag().equals( tag ) ) { Log.d( "tagIsPendingToRequest ", "Pendingtag: " + request.getTag() + " mytag:" + tag ); return true; } } return false; }
Field aField; Class clazz; Object value = new Mirror().on(clazz).get().field(aField);
Object target; Object value = new Mirror().on(target).get().field("fieldName");
Class clazz; Object value = new Mirror().on(clazz).get().field("fieldName");
private static String getBtAddressViaReflection() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); Object bluetoothManagerService = new Mirror().on(bluetoothAdapter).get().field("mService"); if (bluetoothManagerService == null) { Log.w(TAG, "couldn't find bluetoothManagerService"); return null; } Object address = new Mirror().on(bluetoothManagerService).invoke().method("getAddress").withoutArgs(); if (address != null && address instanceof String) { Log.w(TAG, "using reflection to get the BT MAC address: " + address); return (String) address; } else { return null; } }
/** * Build a download mirror for a given repository. */ public static FluentMirrorBuilder newMirror() { return new FluentMirrorBuilder(new Mirror()); }
function Mirror() { var ctx = Object.create(null); this.rename = function(obj, name, context, args) { ctx[name] = obj.bind(context || ctx, args || null); return ctx } } // `Room` function Room() { } Room.prototype.controller = function() { console.log(this) } var mirror = new Mirror(); let _room = mirror.rename( Room.prototype.controller , "getController" , new Room()); _room.getController()
for(Class<?> cl : classList){ Mirror mirror = new Mirror().on(cl); for(Field f: mirror.reflectAll().fields()) { if(java.lang.reflect.Modifier.isStatic(f.getModifiers()) { writeln(mirror.get().field(f)); } } }
Mirror mirror = new Mirror(); for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- )
final Mirror tester = new Mirror(); String s = tester.reverse("string"); Integer i41 = tester.reverse(41); Integer i42 = tester.reverse(42); Integer i43 = tester.reverse(43); JFrame j = tester.reverse(new JFrame());