@Test public void testEnsureParentAndKey() { ParseRelation relation = new ParseRelation("Test"); ParseObject parent = mock(ParseObject.class); relation.ensureParentAndKey(parent, "key"); assertEquals(parent, relation.getParent()); assertEquals("key", relation.getKey()); }
void ensureParentAndKey(ParseObject someParent, String someKey) { synchronized (mutex) { if (parent == null) { parent = new WeakReference<>(someParent); parentObjectId = someParent.getObjectId(); parentClassName = someParent.getClassName(); } if (key == null) { key = someKey; } if (parent.get() != someParent) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different ParseObjects."); } if (!key.equals(someKey)) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different keys."); } } }
ParseRelation implements Parcelable { void ensureParentAndKey(ParseObject someParent, String someKey) { synchronized (mutex) { if (parent == null) { parent = new WeakReference<>(someParent); parentObjectId = someParent.getObjectId(); parentClassName = someParent.getClassName(); } if (key == null) { key = someKey; } if (parent.get() != someParent) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different ParseObjects."); } if (!key.equals(someKey)) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different keys."); } } } }
ParseRelation implements Parcelable { void ensureParentAndKey(ParseObject someParent, String someKey) { synchronized (mutex) { if (parent == null) { parent = new WeakReference<>(someParent); parentObjectId = someParent.getObjectId(); parentClassName = someParent.getClassName(); } if (key == null) { key = someKey; } if (parent.get() != someParent) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different ParseObjects."); } if (!key.equals(someKey)) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different keys."); } } } ParseRelation(ParseObject parent, String key);   ParseRelation(String targetClass);   ParseRelation(JSONObject jsonObject, ParseDecoder decoder);   ParseRelation(Parcel source, ParseParcelDecoder decoder); }
ParseRelation implements Parcelable { void ensureParentAndKey(ParseObject someParent, String someKey) { synchronized (mutex) { if (parent == null) { parent = new WeakReference<>(someParent); parentObjectId = someParent.getObjectId(); parentClassName = someParent.getClassName(); } if (key == null) { key = someKey; } if (parent.get() != someParent) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different ParseObjects."); } if (!key.equals(someKey)) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different keys."); } } } ParseRelation(ParseObject parent, String key);   ParseRelation(String targetClass);   ParseRelation(JSONObject jsonObject, ParseDecoder decoder);   ParseRelation(Parcel source, ParseParcelDecoder decoder); void add(T object); void remove(T object); ParseQuery<T> getQuery(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); }
ParseRelation implements Parcelable { void ensureParentAndKey(ParseObject someParent, String someKey) { synchronized (mutex) { if (parent == null) { parent = new WeakReference<>(someParent); parentObjectId = someParent.getObjectId(); parentClassName = someParent.getClassName(); } if (key == null) { key = someKey; } if (parent.get() != someParent) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different ParseObjects."); } if (!key.equals(someKey)) { throw new IllegalStateException( "Internal error. One ParseRelation retrieved from two different keys."); } } } ParseRelation(ParseObject parent, String key);   ParseRelation(String targetClass);   ParseRelation(JSONObject jsonObject, ParseDecoder decoder);   ParseRelation(Parcel source, ParseParcelDecoder decoder); void add(T object); void remove(T object); ParseQuery<T> getQuery(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); final static Creator<ParseRelation> CREATOR; }