To fix http://code.google.com/p/google-http-java-client/issues/detail?id=17 : When a subclass with a field annotated with @Key hides a superclass field annotated with @Key, prefer the definition from the subclass.
http://codereview.appspot.com/6312057/diff/4001/google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java File google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java (left): http://codereview.appspot.com/6312057/diff/4001/google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java#oldcode190 google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java:190: Preconditions.checkArgument(conflictingFieldInfo == null, no, we still want this check. ...
11 years, 9 months ago
(2012-07-30 21:35:36 UTC)
#2
11 years, 9 months ago
(2012-07-31 18:58:04 UTC)
#3
http://codereview.appspot.com/6312057/diff/4001/google-http-client/src/main/j...
File google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java
(left):
http://codereview.appspot.com/6312057/diff/4001/google-http-client/src/main/j...
google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java:190:
Preconditions.checkArgument(conflictingFieldInfo == null,
On 2012/07/30 21:35:36, yanivi wrote:
> no, we still want this check. It's just that we only want it for fields of
the
> same class. So for example this is still bad:
>
> class A {
> @Key String foo;
> @Key("foo") String foo2;
> }
Done and added a test case.
http://codereview.appspot.com/6312057/diff/4001/google-http-client/src/main/j...
File google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java
(right):
http://codereview.appspot.com/6312057/diff/4001/google-http-client/src/main/j...
google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java:190:
nameToFieldInfoMap.put(fieldName, fieldInfo);
On 2012/07/30 21:35:36, yanivi wrote:
> please add a comment mentioning that we are intentionally allowing a field in
a
> subclass to override a field from a superclass
Not sure if this is needed because of the two maps. Let me know what you think
about the two map design.
http://codereview.appspot.com/6312057/diff/7002/google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java File google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java (right): http://codereview.appspot.com/6312057/diff/7002/google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java#newcode179 google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java:179: if (superClass != null) { On 2012/08/01 11:42:33, yanivi ...
11 years, 9 months ago
(2012-08-01 12:49:25 UTC)
#5
http://codereview.appspot.com/6312057/diff/7002/google-http-client/src/main/j...
File google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java
(right):
http://codereview.appspot.com/6312057/diff/7002/google-http-client/src/main/j...
google-http-client/src/main/java/com/google/api/client/util/ClassInfo.java:179:
if (superClass != null) {
On 2012/08/01 11:42:33, yanivi wrote:
> Maybe a slightly better fix is to move lines 179-183 to after the for-loop (to
> right before 205)? then you won't need superNameToFieldInfoMap, though of
> course you'd need to iterate over the super fields to only put those that
aren't
> already in nameToFieldInfoMap.
Done.
Issue 6312057: Use the @Key definition from the subclass
(Closed)
Created 11 years, 10 months ago by rmistry
Modified 11 years, 9 months ago
Reviewers: yanivi
Base URL: https://google-http-java-client.googlecode.com/hg/
Comments: 8