FSTDatabaseInfo.m 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "Firestore/Source/Core/FSTDatabaseInfo.h"
  17. #import "Firestore/Source/Model/FSTDatabaseID.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. #pragma mark - FSTDatabaseInfo
  20. @implementation FSTDatabaseInfo
  21. #pragma mark - Constructors
  22. + (instancetype)databaseInfoWithDatabaseID:(FSTDatabaseID *)databaseID
  23. persistenceKey:(NSString *)persistenceKey
  24. host:(NSString *)host
  25. sslEnabled:(BOOL)sslEnabled {
  26. return [[FSTDatabaseInfo alloc] initWithDatabaseID:databaseID
  27. persistenceKey:persistenceKey
  28. host:host
  29. sslEnabled:sslEnabled];
  30. }
  31. /**
  32. * Designated initializer.
  33. *
  34. * @param databaseID The database in the datastore.
  35. * @param persistenceKey A unique identifier for this Firestore's local storage. Usually derived
  36. * from -[FIRApp appName].
  37. * @param host The Firestore server hostname.
  38. * @param sslEnabled Whether to use SSL when connecting.
  39. */
  40. - (instancetype)initWithDatabaseID:(FSTDatabaseID *)databaseID
  41. persistenceKey:(NSString *)persistenceKey
  42. host:(NSString *)host
  43. sslEnabled:(BOOL)sslEnabled {
  44. if (self = [super init]) {
  45. _databaseID = databaseID;
  46. _persistenceKey = [persistenceKey copy];
  47. _host = [host copy];
  48. _sslEnabled = sslEnabled;
  49. }
  50. return self;
  51. }
  52. #pragma mark - NSObject methods
  53. - (NSString *)description {
  54. return [NSString
  55. stringWithFormat:@"<FSTDatabaseInfo: databaseID:%@ host:%@>", self.databaseID, self.host];
  56. }
  57. @end
  58. NS_ASSUME_NONNULL_END