GTLRRuntimeCommon.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (c) 2011 Google Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #import <Foundation/Foundation.h>
  16. #import "GTLRObject.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. // This protocol and support class are an internal implementation detail so
  19. // GTLRObject and GTLRQuery can share some code.
  20. /**
  21. * An internal protocol for the GTLR library.
  22. *
  23. * None of these methods should be used by client apps.
  24. */
  25. @protocol GTLRRuntimeCommon <NSObject>
  26. @required
  27. // Get/Set properties
  28. - (void)setJSONValue:(nullable id)obj forKey:(NSString *)key;
  29. - (id)JSONValueForKey:(NSString *)key;
  30. // Child cache
  31. - (void)setCacheChild:(nullable id)obj forKey:(NSString *)key;
  32. - (nullable id)cacheChildForKey:(NSString *)key;
  33. // Object mapper.
  34. - (nullable id<GTLRObjectClassResolver>)objectClassResolver;
  35. // Key map
  36. + (nullable NSDictionary<NSString *, NSString *> *)propertyToJSONKeyMapForClass:(Class<GTLRRuntimeCommon>)aClass;
  37. // Array item types
  38. + (nullable NSDictionary<NSString *, Class> *)arrayPropertyToClassMapForClass:(Class<GTLRRuntimeCommon>)aClass;
  39. // The parent class for dynamic support
  40. + (nullable Class<GTLRRuntimeCommon>)ancestorClass;
  41. @end
  42. /**
  43. * An internal class for the GTLR library.
  44. *
  45. * None of these methods should be used by client apps.
  46. */
  47. @interface GTLRRuntimeCommon : NSObject
  48. // Wire things up.
  49. + (BOOL)resolveInstanceMethod:(SEL)sel onClass:(Class)onClass;
  50. // Helpers
  51. + (nullable id)objectFromJSON:(id)json
  52. defaultClass:(nullable Class)defaultClass
  53. objectClassResolver:(id<GTLRObjectClassResolver>)objectClassResolver
  54. isCacheable:(nullable BOOL *)isCacheable;
  55. + (nullable id)jsonFromAPIObject:(id)obj
  56. expectedClass:(nullable Class)expectedClass
  57. isCacheable:(nullable BOOL *)isCacheable;
  58. // Walk up the class tree merging dictionaries and return the result.
  59. + (NSDictionary *)mergedClassDictionaryForSelector:(SEL)selector
  60. startClass:(Class)startClass
  61. ancestorClass:(Class)ancestorClass
  62. cache:(NSMutableDictionary *)cache;
  63. @end
  64. NS_ASSUME_NONNULL_END