MCPcopy Create free account
hub / github.com/androrm/androrm / getForeignKeyField

Method getForeignKeyField

src/src/com/orm/androrm/Model.java:281–312  ·  view source on GitHub ↗
(
			
			Class<T> 	target, 
			Class<O> 	originClass, 
			O 			origin
			
	)

Source from the content-addressed store, hash-verified

279 }
280
281 private static final <T extends Model, O extends Model> Field getForeignKeyField(
282
283 Class<T> target,
284 Class<O> originClass,
285 O origin
286
287 ) throws IllegalArgumentException, IllegalAccessException {
288
289 Field fk = null;
290
291 if(originClass != null && originClass.isInstance(origin)) {
292 for(Field field: DatabaseBuilder.getFields(originClass, origin)) {
293 Object f = field.get(origin);
294
295 if(f instanceof ForeignKeyField) {
296 ForeignKeyField<?> tmp = (ForeignKeyField<?>) f;
297 Class<? extends Model> t = tmp.getTarget();
298
299 if(t.equals(target)) {
300 fk = field;
301 break;
302 }
303 }
304 }
305
306 if(fk == null) {
307 fk = getForeignKeyField(target, getSuperclass(originClass), origin);
308 }
309 }
310
311 return fk;
312 }
313
314 protected static final <T extends Model> T getInstace(Class<T> clazz) {
315 T instance = null;

Callers 2

getBackLinkFieldNameMethod · 0.95
getForeignKeyMethod · 0.95

Calls 5

getFieldsMethod · 0.95
getSuperclassMethod · 0.95
equalsMethod · 0.80
getMethod · 0.65
getTargetMethod · 0.65

Tested by

no test coverage detected