FTupleEventTypeString.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/Tests/Helpers/FTupleEventTypeString.h"
  17. @implementation FTupleEventTypeString
  18. @synthesize firebase;
  19. @synthesize eventType;
  20. @synthesize string;
  21. @synthesize vvcallback;
  22. @synthesize initialized;
  23. - (id)initWithFirebase:(FIRDatabaseReference *)f
  24. withEvent:(FIRDataEventType)evt
  25. withString:(NSString *)str;
  26. {
  27. self = [super init];
  28. if (self) {
  29. self.firebase = f;
  30. self.eventType = evt;
  31. self.string = str;
  32. self.initialized = NO;
  33. }
  34. return self;
  35. }
  36. - (NSString *)description {
  37. return [NSString stringWithFormat:@"%@ %@ (%zd)", self.firebase, self.string, self.eventType];
  38. }
  39. - (BOOL)isEqualTo:(FTupleEventTypeString *)other {
  40. BOOL stringsEqual = NO;
  41. if (self.string == nil && other.string == nil) {
  42. stringsEqual = YES;
  43. } else if (self.string != nil && other.string != nil) {
  44. stringsEqual = [self.string isEqualToString:other.string];
  45. }
  46. return self.eventType == other.eventType && stringsEqual &&
  47. [[self.firebase description] isEqualToString:[other.firebase description]];
  48. }
  49. @end