FMaxNode.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FirebaseDatabase/Sources/FMaxNode.h"
  17. #import "FirebaseDatabase/Sources/Snapshot/FEmptyNode.h"
  18. #import "FirebaseDatabase/Sources/Utilities/FUtilities.h"
  19. @implementation FMaxNode {
  20. }
  21. - (id)init {
  22. self = [super init];
  23. if (self) {
  24. }
  25. return self;
  26. }
  27. + (id<FNode>)maxNode {
  28. static FMaxNode *maxNode = nil;
  29. static dispatch_once_t once;
  30. dispatch_once(&once, ^{
  31. maxNode = [[FMaxNode alloc] init];
  32. });
  33. return maxNode;
  34. }
  35. - (NSComparisonResult)compare:(id<FNode>)other {
  36. if (other == self) {
  37. return NSOrderedSame;
  38. } else {
  39. return NSOrderedDescending;
  40. }
  41. }
  42. - (BOOL)isEqual:(id)other {
  43. return other == self;
  44. }
  45. - (id<FNode>)getImmediateChild:(NSString *)childName {
  46. return [FEmptyNode emptyNode];
  47. }
  48. - (BOOL)isEmpty {
  49. return NO;
  50. }
  51. @end