FIRRegexValue.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2025 Google LLC
  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. #include "Firestore/Source/Public/FirebaseFirestore/FIRRegexValue.h"
  17. @implementation FIRRegexValue
  18. - (instancetype)initWithPattern:(NSString *)pattern options:(NSString *)options {
  19. self = [super init];
  20. if (self) {
  21. _pattern = [pattern copy];
  22. _options = [options copy];
  23. }
  24. return self;
  25. }
  26. - (BOOL)isEqual:(nullable id)object {
  27. if (self == object) {
  28. return YES;
  29. }
  30. if (![object isKindOfClass:[FIRRegexValue class]]) {
  31. return NO;
  32. }
  33. FIRRegexValue *other = (FIRRegexValue *)object;
  34. return
  35. [self.pattern isEqualToString:other.pattern] && [self.options isEqualToString:other.options];
  36. }
  37. - (id)copyWithZone:(__unused NSZone *_Nullable)zone {
  38. return [[FIRRegexValue alloc] initWithPattern:self.pattern options:self.options];
  39. }
  40. - (NSString *)description {
  41. return [NSString
  42. stringWithFormat:@"<FIRRegexValue: (pattern:%@, options:%@)>", self.pattern, self.options];
  43. }
  44. @end