Java Code Examples for java.lang.reflect.Field
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project activemq-apollo, under directory /apollo-util/src/main/scala/org/apache/activemq/apollo/util/.
Source file: Combinator.java

private void setField(Class<? extends Object> clazz,Object instance,String key,Object value) throws NoSuchFieldException, IllegalAccessException { while (clazz != null) { try { Field declaredField=clazz.getDeclaredField(key); declaredField.setAccessible(true); declaredField.set(instance,value); return; } catch ( NoSuchFieldException e) { clazz=clazz.getSuperclass(); } } }
Example 2
From project AdminCmd, under directory /src/main/java/be/Balor/Tools/.
Source file: ClassUtils.java

@SuppressWarnings("unchecked") public static <T>T getPrivateField(final Object object,final String field) throws SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException { final Field objectField=getObjectField(object,field); objectField.setAccessible(true); final T obj=(T)objectField.get(object); objectField.setAccessible(false); return obj; }
Example 3
From project aether-ant, under directory /src/main/java/org/eclipse/aether/ant/.
Source file: AntSettingsDecryptorFactory.java

public DefaultSettingsDecrypter newInstance(){ AntSecDispatcher secDispatcher=new AntSecDispatcher(); DefaultSettingsDecrypter decrypter=new DefaultSettingsDecrypter(); try { Field field=decrypter.getClass().getDeclaredField("securityDispatcher"); field.setAccessible(true); field.set(decrypter,secDispatcher); } catch ( Exception e) { throw new IllegalStateException(e); } return decrypter; }
Example 4
From project almira-sample, under directory /almira-sample-core/src/test/java/almira/sample/dao/.
Source file: CatapultDaoHibernateSearchTest.java

@Test public void testPersistenceClassIsSet() throws NoSuchFieldException, IllegalAccessException { Field f=AbstractDaoHibernate.class.getDeclaredField("entityBeanType"); f.setAccessible(true); Object persistentClass=f.get(dao); Assert.assertEquals(Catapult.class,persistentClass); }
Example 5
From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/bean/.
Source file: FieldDictionary.java

/** * Returns an specific field of some class. If definedIn is null, it searchs for the field named 'name' inside the class cls. If definedIn is different than null, tries to find the specified field name in the specified class cls which should be defined in class definedIn (either equals cls or a one of it's superclasses) * @param cls the class where the field is to be searched * @param name the field name * @param definedIn the superclass (or the class itself) of cls where the field was defined * @return the field itself */ public Field field(Class cls,String name,Class definedIn){ Map fields=buildMap(cls,definedIn != null); Field field=(Field)fields.get(definedIn != null ? (Object)new FieldKey(name,definedIn,0) : (Object)name); if (field == null) { throw new ObjectAccessException("No such field " + cls.getName() + "."+ name); } else { return field; } }
Example 6
From project amplafi-sworddance, under directory /src/test/java/com/sworddance/beans/.
Source file: TestBeanWorker.java

/** * tests get/set using the same BeanWorker ( this tests duck-typing ) on 2 different classes that are not related to each other. * @param beanWorker * @param testClass * @param childTestClass * @throws Exception */ @Test(dataProvider="testClassInstances") public void testPropertyGetSet(BeanWorker beanWorker,Object testClass,Object childTestClass) throws Exception { Field deleteField=childTestClass.getClass().getField("delete"); assertEquals(deleteField.get(childTestClass),true); boolean childDelete=(Boolean)beanWorker.getValue(testClass,"testClass.delete"); assertTrue(childDelete); beanWorker.setValue(testClass,"testClass.delete",false); childDelete=(Boolean)beanWorker.getValue(testClass,"testClass.delete"); assertFalse(childDelete); assertEquals(deleteField.get(childTestClass),false); assertSame(testClass.getClass().getField("testClass").get(testClass),childTestClass); }
Example 7
From project Android-automation, under directory /Tmts_Java/src/com/taobao/tmts/framework/.
Source file: Tmts.java

/** * Transform {@link String} id into {@link int} id. * @param name String name of view id, the string after @+id/ defined in layout files. * @return {@link View}'s id defined in R.java. * @throws Exception Exception. */ public static int getIdByName(String name) throws Exception { String className=targetPkg + ".R$id"; Class<?> id=null; id=Class.forName(className); Field idField=null; idField=id.getField(name); if (null != idField) { return idField.getInt(idField); } else { return -1; } }
Example 8
From project android-sdk, under directory /src/test/java/com/mobeelizer/mobile/android/model/.
Source file: MobeelizerReflectionUtilTest.java

@Test public void shouldGetFieldUsingManyTypes() throws Exception { Set<Class<?>> types=new HashSet<Class<?>>(); types.add(String.class); types.add(Boolean.TYPE); Field field=MobeelizerReflectionUtil.getField(TestEntity.class,"guid",types); assertEquals("guid",field.getName()); assertEquals(String.class,field.getType()); }
Example 9
From project Android-Simple-Social-Sharing, under directory /SimpleSocialSharing/src/com/nostra13/socialsharing/twitter/extpack/winterwell/json/.
Source file: JSONObject.java

/** * Construct a JSONObject from an Object, using reflection to find the public members. The resulting JSONObject's keys will be the strings from the names array, and the values will be the field values associated with those keys in the object. If a key is not found or not visible, then it will not be copied into the new JSONObject. * @param object An object that has fields that should be used to make aJSONObject. * @param names An array of strings, the names of the fields to be usedfrom the object. */ public JSONObject(Object object,String names[]){ this(); Class c=object.getClass(); for (int i=0; i < names.length; i+=1) { try { String name=names[i]; Field field=c.getField(name); Object value=field.get(object); this.put(name,value); } catch ( Exception e) { } } }
Example 10
From project androidannotations, under directory /AndroidAnnotations/functional-test-1-5-tests/src/test/java/com/googlecode/androidannotations/test15/.
Source file: ServiceInjectionTest.java

@Before public void setup() throws Exception { Field serviceMapField=ShadowApplication.class.getDeclaredField("SYSTEM_SERVICE_MAP"); serviceMapField.setAccessible(true); @SuppressWarnings("unchecked") Map<String,String> SYSTEM_SERVICE_MAP=(Map<String,String>)serviceMapField.get(null); SYSTEM_SERVICE_MAP.put(Context.CLIPBOARD_SERVICE,"com.googlecode.androidannotations.test15.FakeClipboardManager"); }
Example 11
From project android_external_guava, under directory /src/com/google/common/base/internal/.
Source file: Finalizer.java

public static Field getInheritableThreadLocalsField(){ try { Field inheritableThreadLocals=Thread.class.getDeclaredField("inheritableThreadLocals"); inheritableThreadLocals.setAccessible(true); return inheritableThreadLocals; } catch ( Throwable t) { logger.log(Level.INFO,"Couldn't access Thread.inheritableThreadLocals." + " Reference finalizer threads will inherit thread local" + " values."); return null; } }
Example 12
From project ant4eclipse, under directory /org.ant4eclipse.ant.core/src/org/ant4eclipse/ant/core/.
Source file: AntCall.java

/** * <p> Helper method that reads the (private) field <code>antfile</code> from the {@link Ant} class. If the private fieldcan't be read, <code>null</code> will be returned. </p> * @return the content of the <code>antfile</code> field */ private String getAntFile(){ try { Field field=Ant.class.getDeclaredField("antFile"); field.setAccessible(true); File file=new File((String)field.get(this)); return file.getAbsolutePath(); } catch ( Exception e) { return null; } }
Example 13
private static boolean isProjectLibrary(Library lib){ final Field field; try { field=lib.getClass().getDeclaredField("LIB"); } catch ( NoSuchFieldException ignore) { return false; } if (!Library.class.isAssignableFrom(field.getType())) { return false; } final int mods=field.getModifiers(); return Modifier.isStatic(mods) && Modifier.isFinal(mods); }
Example 14
From project arquillian-core, under directory /container/test-impl-base/src/main/java/org/jboss/arquillian/container/test/impl/client/deployment/tool/.
Source file: ToolingDeploymentFormatter.java

@SuppressWarnings("unchecked") private <T>T getInternalFieldValue(Class<T> type,String fieldName,Object obj){ try { Field field=obj.getClass().getDeclaredField(fieldName); field.setAccessible(true); return (T)field.get(obj); } catch ( Exception e) { throw new RuntimeException("Could not extract field " + fieldName + " on "+ obj,e); } }
Example 15
From project arquillian-extension-drone, under directory /drone-impl/src/main/java/org/jboss/arquillian/drone/impl/.
Source file: DroneCreator.java

@SuppressWarnings("unchecked") public void createWebTestBrowser(@Observes DroneConfigured event,DroneRegistry registry,DroneContext droneContext){ Field field=event.getInjected(); Class<?> typeClass=field.getType(); Class<? extends Annotation> qualifier=event.getQualifier(); DroneConfiguration<?> configuration=event.getConfiguration(); @SuppressWarnings("rawtypes") Instantiator instantiator=registry.getEntryFor(typeClass,Instantiator.class); if (log.isLoggable(Level.FINE)) { log.fine("Using instantiator defined in class: " + instantiator.getClass().getName() + ", with precedence "+ instantiator.getPrecedence()); } droneContext.add(typeClass,qualifier,instantiator.createInstance(configuration)); }
Example 16
From project agile, under directory /agile-apps/agile-app-search/src/main/java/org/headsupdev/agile/app/search/.
Source file: SearchRenderModel.java

private Object getField(Object o,String fieldName){ try { String methodName="get" + fieldName.substring(0,1).toUpperCase() + fieldName.substring(1); Method method=o.getClass().getMethod(methodName); return method.invoke(o); } catch ( Exception e) { System.err.println("method fail = " + e.getMessage()); try { Field field=o.getClass().getDeclaredField(fieldName); field.setAccessible(true); return field.get(o); } catch ( Exception e2) { System.err.println("field fail = " + e2.getMessage()); } } return null; }
Example 17
From project ajah, under directory /ajah-spring-jdbc/src/main/java/com/ajah/spring/jdbc/.
Source file: AbstractAjahDao.java

private Object[] getInsertValues(final T entity){ final Object[] values=new Object[getColumns().size()]; try { final BeanInfo componentBeanInfo=Introspector.getBeanInfo(entity.getClass()); final PropertyDescriptor[] props=componentBeanInfo.getPropertyDescriptors(); for (int i=0; i < values.length; i++) { final Field field=this.colMap.get(this.columns.get(i)); values[i]=ReflectionUtils.propGetSafeAuto(entity,field,getProp(field,props)); if (log.isLoggable(Level.FINEST)) { log.finest(field.getName() + " set to " + values[i]); } } } catch ( final IntrospectionException e) { log.log(Level.SEVERE,entity.getClass().getName() + ": " + e.getMessage(),e); } return values; }
Example 18
From project Android-SQL-Helper, under directory /tests/AndroidSQLHelperTest/src/com/sgxmobileapps/androidsqlhelper/test/.
Source file: FieldTestCase.java

@Test public void uniqueAndNullableFieldSpecified() throws IOException { writeDefaultSchema(); ArrayList<String> sources=new ArrayList<String>(); sources.add("src/com/sgxmobileapps/androidsqlhelper/test/entities/FullEntity.java"); ArrayList<String> options=new ArrayList<String>(); addStandardClassPath(options); assertTrue(compileFiles(options,sources)); assertTrue(checkGeneratedSource("outpackage/test/TestDbAdapter","outpackage/test/TestDbMetadata")); String createTable=null; try { Class<?> adapterClazz=loadGeneratedClass("outpackage.test.TestDbAdapter"); Field createTableField=adapterClazz.getDeclaredField("SQL_FULLENTITY_CREATE_TABLE"); createTableField.setAccessible(true); createTable=(String)createTableField.get(null); } catch ( Exception e) { fail(e.getMessage()); } printToOutput(createTable); assertTrue(createTable.contains("LONGO INTEGER NOT NULL UNIQUE") && createTable.contains("INTO INTEGER NOT NULL UNIQUE")); }
Example 19
From project AndroidBillingLibrary, under directory /AndroidBillingLibrary/src/net/robotmedia/billing/utils/.
Source file: Compatibility.java

private static void initCompatibility(){ try { final Field field=Service.class.getField("START_NOT_STICKY"); START_NOT_STICKY=field.getInt(null); } catch ( Exception e) { START_NOT_STICKY=2; } try { startIntentSender=Activity.class.getMethod("startIntentSender",START_INTENT_SENDER_SIG); } catch ( SecurityException e) { startIntentSender=null; } catch ( NoSuchMethodException e) { startIntentSender=null; } }
Example 20
From project AndroidCommon, under directory /src/com/asksven/android/common/wifi/.
Source file: WifiManagerProxy.java

/** * returns the number of help WifiLocks * @return */ public static int getWifiLocks(Context ctx){ init(ctx); int ret=0; try { Field privateStringField=WifiManager.class.getDeclaredField("mActiveLockCount"); privateStringField.setAccessible(true); Integer fieldValue=(Integer)privateStringField.get(m_manager); Log.d(TAG,"mActiveLockCount is " + fieldValue); ret=fieldValue; } catch ( Exception e) { Log.e(TAG,"An exception occured in getWifiLocks(): " + e.getMessage()); ret=-1; } Log.d(TAG,ret + " Wifilocks detected"); return ret; }
Example 21
From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.
Source file: NLS.java

private static void computeMissingMessages(String bundleName,Class clazz,Map fieldMap,Field[] fieldArray,boolean isAccessible){ final int MOD_EXPECTED=Modifier.PUBLIC | Modifier.STATIC; final int MOD_MASK=MOD_EXPECTED | Modifier.FINAL; final int numFields=fieldArray.length; for (int i=0; i < numFields; i++) { Field field=fieldArray[i]; if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED) continue; if (fieldMap.get(field.getName()) == ASSIGNED) continue; try { String value="NLS missing message: " + field.getName() + " in: "+ bundleName; if (Debug.SHOW_FULL_DETAIL == 1) System.out.println(value); log(SEVERITY_WARNING,value,null); if (!isAccessible) field.setAccessible(true); field.set(null,value); } catch ( Exception e) { log(SEVERITY_ERROR,"Error setting the missing message value for: " + field.getName(),e); } } }
Example 22
From project android_packages_apps_Gallery2, under directory /gallerycommon/src/com/android/gallery3d/common/.
Source file: EntrySchema.java

public <T extends Entry>T cursorToObject(Cursor cursor,T object){ try { for ( ColumnInfo column : mColumnInfo) { int columnIndex=column.projectionIndex; Field field=column.field; switch (column.type) { case TYPE_STRING: field.set(object,cursor.isNull(columnIndex) ? null : cursor.getString(columnIndex)); break; case TYPE_BOOLEAN: field.setBoolean(object,cursor.getShort(columnIndex) == 1); break; case TYPE_SHORT: field.setShort(object,cursor.getShort(columnIndex)); break; case TYPE_INT: field.setInt(object,cursor.getInt(columnIndex)); break; case TYPE_LONG: field.setLong(object,cursor.getLong(columnIndex)); break; case TYPE_FLOAT: field.setFloat(object,cursor.getFloat(columnIndex)); break; case TYPE_DOUBLE: field.setDouble(object,cursor.getDouble(columnIndex)); break; case TYPE_BLOB: field.set(object,cursor.isNull(columnIndex) ? null : cursor.getBlob(columnIndex)); break; } } return object; } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
Example 23
public static void updateStats(Stats stats,Card card,int ease,String oldState){ char[] newState=oldState.toCharArray(); stats.mReps+=1; double delay=card.totalTime(); if (delay >= 60) { stats.mReviewTime+=60; } else { stats.mReviewTime+=delay; stats.mAverageTime=(stats.mReviewTime / stats.mReps); } newState[0]=Character.toUpperCase(newState[0]); String attr="m" + String.valueOf(newState) + String.format("Ease%d",ease); try { Field f=stats.getClass().getDeclaredField(attr); f.setInt(stats,f.getInt(stats) + 1); } catch ( Exception e) { Log.e(AnkiDroidApp.TAG,"Failed to update " + attr + " : "+ e.getMessage()); } stats.toDB(); }
Example 24
From project ANNIS, under directory /annis-service/src/main/java/annis/.
Source file: TableFormatter.java

private String fieldValue(Object item,String fieldName,List<String> columns){ Class<?> clazz=item.getClass(); String value=null; try { Field field=clazz.getDeclaredField(fieldName); field.setAccessible(true); Object object=field.get(item); value=object != null ? object.toString() : ""; } catch ( SecurityException e) { log.warn("can't access " + clazz.getName() + "."+ fieldName,e); } catch ( NoSuchFieldException e) { log.warn("Can't print " + clazz.getName() + "."+ fieldName+ ", because it does not exist.",e); columns.remove(fieldName); } catch ( IllegalArgumentException e) { log.warn("can't access " + clazz.getName() + "."+ fieldName,e); } catch ( IllegalAccessException e) { log.warn("can't access " + clazz.getName() + "."+ fieldName,e); } return value; }
Example 25
From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/server/.
Source file: RootSearchScope.java

protected View[] getTopLevelViews(){ try { Class<?> wmClass=getWindowManagerImplClass(); Object wm=wmClass.getDeclaredMethod("getDefault").invoke(null); Field views=wmClass.getDeclaredField("mViews"); views.setAccessible(true); synchronized (wm) { return ((View[])views.get(wm)).clone(); } } catch ( ClassNotFoundException exception) { throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception); } catch ( NoSuchMethodException exception) { throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception); } catch ( NoSuchFieldException exception) { throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception); } catch ( IllegalArgumentException exception) { throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception); } catch ( InvocationTargetException exception) { throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception); } catch ( SecurityException exception) { throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception); } catch ( IllegalAccessException exception) { throw new WebDriverException(REFLECTION_ERROR_MESSAGE,exception); } }
Example 26
public static Object[] structArgs(Object struct) throws IllegalAccessException, BusException { Class<?> type=struct.getClass(); Field[] fields=type.getFields(); Object[] args=new Object[fields.length]; for ( Field field : fields) { Position position=field.getAnnotation(Position.class); if (position == null) { throw new BusException("field " + field + " of "+ type+ " does not annotate position"); } args[position.value()]=field.get(struct); } return args; }
Example 27
From project ALP, under directory /workspace/alp-flexpilot/src/main/java/com/lohika/alp/flexpilot/pagefactory/.
Source file: FlexPilotDefaultFieldDecorator.java

public Object decorate(ClassLoader loader,Field field){ if (!FlexElement.class.isAssignableFrom(field.getType())) { return null; } FlexElementLocator locator=factory.createLocator(field); if (locator == null) { return null; } return proxyForLocator(loader,locator); }
Example 28
From project alphaportal_dev, under directory /sys-src/alphaportal/web/src/main/java/alpha/portal/webapp/taglib/.
Source file: ConstantsTag.java

/** * Main method that does processing and exposes Constants in specified scope. * @return int * @throws JspException if processing fails */ @Override public int doStartTag() throws JspException { Class c=null; int toScope=PageContext.PAGE_SCOPE; if (this.scope != null) { toScope=this.getScope(this.scope); } try { c=Class.forName(this.clazz); } catch ( final ClassNotFoundException cnf) { this.log.error("ClassNotFound - maybe a typo?"); throw new JspException(cnf.getMessage()); } try { if (this.var == null) { final Field[] fields=c.getDeclaredFields(); AccessibleObject.setAccessible(fields,true); for ( final Field field : fields) { this.pageContext.setAttribute(field.getName(),field.get(this),toScope); } } else { try { final Object value=c.getField(this.var).get(this); this.pageContext.setAttribute(c.getField(this.var).getName(),value,toScope); } catch ( final NoSuchFieldException nsf) { this.log.error(nsf.getMessage()); throw new JspException(nsf); } } } catch ( final IllegalAccessException iae) { this.log.error("Illegal Access Exception - maybe a classloader issue?"); throw new JspException(iae); } return (Tag.SKIP_BODY); }
Example 29
From project android-inject, under directory /src/main/java/com/teamcodeflux/android/inject/.
Source file: DependencyInjector.java

private void lookupAndInjectDependency(final Field field){ if (namedDependencies.containsKey(field.getName())) { injectNamedDependency(field); } else { injectDependency(field); } }
Example 30
From project android-thaiime, under directory /latinime/src/com/android/inputmethod/compat/.
Source file: CompatUtils.java

public static Field getField(Class<?> targetClass,String name){ if (targetClass == null || TextUtils.isEmpty(name)) return null; try { return targetClass.getField(name); } catch ( SecurityException e) { } catch ( NoSuchFieldException e) { } return null; }
Example 31
/** * Constructs a Field Attributes object from the {@code f}. * @param f the field to pull attributes from * @param declaringType The type in which the field is declared */ FieldAttributes(Class<?> declaringClazz,Field f,Type declaringType){ this.declaringClazz=$Gson$Preconditions.checkNotNull(declaringClazz); this.name=f.getName(); this.declaredType=f.getType(); this.isSynthetic=f.isSynthetic(); this.modifiers=f.getModifiers(); this.field=f; this.resolvedType=getTypeInfoForField(f,declaringType); }
Example 32
From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/picasa/.
Source file: EntrySchema.java

public ColumnInfo(String name,int type,boolean indexed,boolean fullText,Field field,int projectionIndex){ this.name=name.toLowerCase(); this.type=type; this.indexed=indexed; this.fullText=fullText; this.field=field; this.projectionIndex=projectionIndex; }
Example 33
From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/compat/.
Source file: CompatUtils.java

public static Field getField(Class<?> targetClass,String name){ if (targetClass == null || TextUtils.isEmpty(name)) return null; try { return targetClass.getField(name); } catch ( SecurityException e) { } catch ( NoSuchFieldException e) { } return null; }
Example 34
From project any23, under directory /api/src/main/java/org/apache/any23/vocab/.
Source file: Vocabulary.java

private void fillResourceToCommentMap(){ if (resourceToCommentMap != null) return; final Map<URI,String> newMap=new HashMap<URI,String>(); for ( Field field : this.getClass().getFields()) { try { final Object value=field.get(this); if (value instanceof URI) { final Comment comment=field.getAnnotation(Comment.class); if (comment != null) newMap.put((URI)value,comment.value()); } } catch ( IllegalAccessException iae) { throw new RuntimeException("Error while creating resource to comment map.",iae); } } resourceToCommentMap=newMap; }
Example 35
From project AnySoftKeyboard, under directory /src/com/anysoftkeyboard/utils/.
Source file: CompatUtils.java

public static Field getField(Class<?> targetClass,String name){ if (targetClass == null || TextUtils.isEmpty(name)) return null; try { return targetClass.getField(name); } catch ( SecurityException e) { } catch ( NoSuchFieldException e) { } return null; }
Example 36
From project api, under directory /weld-spi/src/main/java/org/jboss/weld/injection/spi/helpers/.
Source file: AbstractResourceServices.java

protected String getResourceName(InjectionPoint injectionPoint){ Resource resource=injectionPoint.getAnnotated().getAnnotation(Resource.class); String mappedName=resource.mappedName(); if (!mappedName.equals("")) { return mappedName; } String name=resource.name(); if (!name.equals("")) { return RESOURCE_LOOKUP_PREFIX + "/" + name; } String propertyName; if (injectionPoint.getMember() instanceof Field) { propertyName=injectionPoint.getMember().getName(); } else if (injectionPoint.getMember() instanceof Method) { propertyName=getPropertyName((Method)injectionPoint.getMember()); if (propertyName == null) { throw new IllegalArgumentException("Injection point represents a method which doesn't follow " + "JavaBean conventions (unable to determine property name) " + injectionPoint); } } else { throw new AssertionError("Unable to inject into " + injectionPoint); } String className=injectionPoint.getMember().getDeclaringClass().getName(); return RESOURCE_LOOKUP_PREFIX + "/" + className+ "/"+ propertyName; }
Example 37
From project arastreju, under directory /arastreju.ogm/src/main/java/org/arastreju/ogm/impl/enhance/.
Source file: AnalyzedClass.java

public Field obtainFieldForID(){ for ( Field field : clazz.getFields()) { final NodeID nodeID=field.getAnnotation(NodeID.class); if (nodeID != null) { return field; } } return null; }
Example 38
From project arquillian-container-osgi, under directory /container-common/src/main/java/org/jboss/arquillian/container/osgi/.
Source file: AbstractOSGiApplicationArchiveProcessor.java

private void addImportsForClass(OSGiManifestBuilder builder,Class<?> javaClass){ for ( Class<?> interf : javaClass.getInterfaces()) { addImportPackage(builder,interf); } for ( Annotation anno : javaClass.getDeclaredAnnotations()) { addImportPackage(builder,anno.annotationType()); } for ( Field field : javaClass.getDeclaredFields()) { Class<?> type=field.getType(); addImportPackage(builder,type); } for ( Method method : javaClass.getDeclaredMethods()) { Class<?> returnType=method.getReturnType(); if (returnType != Void.TYPE) addImportPackage(builder,returnType); for ( Class<?> paramType : method.getParameterTypes()) addImportPackage(builder,paramType); } for ( Class<?> declaredClass : javaClass.getDeclaredClasses()) { addImportsForClass(builder,declaredClass); } }
Example 39
From project arquillian-extension-android, under directory /android-configuration/src/main/java/org/jboss/arquillian/android/configuration/.
Source file: ConfigurationMapper.java

/** * Maps Android configuration using Arquillian Descriptor file * @param descriptor Arquillian Descriptor * @param configuration Configuration object * @param properties A map of name-value pairs * @return Configured configuration */ public static <T>T fromArquillianDescriptor(ArquillianDescriptor descriptor,T configuration,Map<String,String> properties){ Validate.notNull(descriptor,"Descriptor must not be null"); Validate.notNull(configuration,"Configuration must not be null"); List<Field> fields=SecurityActions.getAccessableFields(configuration.getClass()); for ( Field f : fields) { if (properties.containsKey(f.getName())) { try { f.set(configuration,convert(box(f.getType()),properties.get(f.getName()))); } catch ( Exception e) { throw new RuntimeException("Could not map Android configuration from Arquillian Descriptor",e); } } } return configuration; }