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

Method setBackLink

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

Source from the content-addressed store, hash-verified

338 }
339
340 private static final <T extends Model, O extends Model> void setBackLink(
341
342 T target,
343 Class<T> targetClass,
344 O origin,
345 Class<O> originClass
346
347 ) throws NoSuchFieldException {
348
349 ForeignKeyField<T> fk = null;
350
351 try {
352 fk = getForeignKey(origin, originClass, targetClass);
353 } catch(IllegalAccessException e) {
354 Log.e(TAG, "an exception was thrown trying to gather a foreign key field pointing to "
355 + targetClass.getSimpleName()
356 + " on an instance of class "
357 + originClass.getSimpleName(), e);
358 }
359
360 if(fk != null) {
361 fk.set(target);
362 } else {
363 throw new NoSuchFieldException("No field pointing to "
364 + targetClass.getSimpleName()
365 + " was found in class "
366 + originClass.getSimpleName()
367 +"! Choices are: "
368 + getEligableFields(originClass, origin).toString());
369 }
370 }
371
372 public static <T extends Model> QuerySet<T> objects(
373

Callers 1

saveO2MToDatabaseMethod · 0.95

Calls 4

getForeignKeyMethod · 0.95
getEligableFieldsMethod · 0.95
setMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected