implementations for desctiption and debugDescription complete for all CoreStore types

This commit is contained in:
John Rommel Estropia
2016-05-08 20:30:28 +09:00
parent 9dae291f62
commit 57b66cff34
25 changed files with 373 additions and 35 deletions

View File

@@ -7,8 +7,6 @@
//
import UIKit
import CoreData
import CoreStore
// MARK: - AppDelegate
@@ -24,9 +22,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
application.statusBarStyle = .LightContent
print(CoreStore.beginUnsafe().commitAndWait())
print(From<Palette>("Config1", "Config2"))
return true
}
}

View File

@@ -339,6 +339,46 @@ extension LegacySQLiteStore: CustomDebugStringConvertible, CoreStoreDebugStringC
}
// MARK: - ListMonitor
private struct CoreStoreFetchedSectionInfoWrapper: CoreStoreDebugStringConvertible {
let sectionInfo: NSFetchedResultsSectionInfo
var coreStoreDumpString: String {
return createFormattedString(
"\"\(self.sectionInfo.name)\" (", ")",
("numberOfObjects", self.sectionInfo.numberOfObjects),
("indexTitle", self.sectionInfo.indexTitle)
)
}
}
extension ListMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
// MARK: CustomDebugStringConvertible
public var debugDescription: String {
return formattedDebugDescription(self)
}
// MARK: CoreStoreDebugStringConvertible
public var coreStoreDumpString: String {
return createFormattedString(
"(", ")",
("isPendingRefetch", self.isPendingRefetch),
("numberOfObjects", self.numberOfObjects()),
("sections", self.sections().map(CoreStoreFetchedSectionInfoWrapper.init))
)
}
}
// MARK: - LocalStorageOptions
extension LocalStorageOptions: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
@@ -441,6 +481,96 @@ extension MigrationChain: CustomDebugStringConvertible, CoreStoreDebugStringConv
}
// MARK: - MigrationType
extension MigrationResult: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
// MARK: CustomDebugStringConvertible
public var debugDescription: String {
return formattedDebugDescription(self)
}
// MARK: CoreStoreDebugStringConvertible
public var coreStoreDumpString: String {
switch self {
case .Success(let migrationTypes):
return createFormattedString(
".Success (", ")",
("migrationTypes", migrationTypes)
)
case .Failure(let error):
return createFormattedString(
".Failure (", ")",
("error", error)
)
}
}
}
// MARK: - MigrationType
extension MigrationType: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
// MARK: CustomDebugStringConvertible
public var debugDescription: String {
return formattedDebugDescription(self)
}
// MARK: CoreStoreDebugStringConvertible
public var coreStoreDumpString: String {
switch self {
case .None(let version):
return ".None (\"\(version)\")"
case .Lightweight(let sourceVersion, let destinationVersion):
return ".Lightweight (\"\(sourceVersion)\"\"\(destinationVersion)\")"
case .Heavyweight(let sourceVersion, let destinationVersion):
return ".Heavyweight (\"\(sourceVersion)\"\"\(destinationVersion)\")"
}
}
}
// MARK: - ObjectMonitor
extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
// MARK: CustomDebugStringConvertible
public var debugDescription: String {
return formattedDebugDescription(self)
}
// MARK: CoreStoreDebugStringConvertible
public var coreStoreDumpString: String {
return createFormattedString(
"(", ")",
("isObjectDeleted", self.isObjectDeleted),
("object", self.object)
)
}
}
// MARK: - OrderBy
extension OrderBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
@@ -499,6 +629,30 @@ extension SaveResult: CustomDebugStringConvertible, CoreStoreDebugStringConverti
}
// MARK: - SectionBy
extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
// MARK: CustomDebugStringConvertible
public var debugDescription: String {
return formattedDebugDescription(self)
}
// MARK: CoreStoreDebugStringConvertible
public var coreStoreDumpString: String {
return createFormattedString(
"(", ")",
("sectionKeyPath", self.sectionKeyPath)
)
}
}
// MARK: - Select
extension Select: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
@@ -567,6 +721,40 @@ extension SelectTerm: CustomDebugStringConvertible, CoreStoreDebugStringConverti
}
// MARK: - SetupResult
extension SetupResult: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
// MARK: CustomDebugStringConvertible
public var debugDescription: String {
return formattedDebugDescription(self)
}
// MARK: CoreStoreDebugStringConvertible
public var coreStoreDumpString: String {
switch self {
case .Success(let storage):
return createFormattedString(
".Success (", ")",
("storage", storage)
)
case .Failure(let error):
return createFormattedString(
".Failure (", ")",
("error", error)
)
}
}
}
// MARK: - SQLiteStore
extension SQLiteStore: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
@@ -828,7 +1016,7 @@ extension NSAttributeDescription: CoreStoreDebugStringConvertible {
("defaultValue", self.defaultValue),
("valueTransformerName", self.valueTransformerName),
("allowsExternalBinaryDataStorage", self.allowsExternalBinaryDataStorage),
("entity", self.entity.name),
("entity.name", self.entity.name),
("name", self.name),
("optional", self.optional),
("transient", self.transient),
@@ -896,7 +1084,7 @@ extension NSEntityDescription: CoreStoreDebugStringConvertible {
("managedObjectClassName", self.managedObjectClassName!),
("name", self.name),
("abstract", self.abstract),
("superentity", self.superentity?.name),
("superentity?.name", self.superentity?.name),
("subentities", self.subentities.map({ $0.name })),
("properties", self.properties),
("userInfo", self.userInfo),
@@ -929,19 +1117,6 @@ extension NSError: CoreStoreDebugStringConvertible {
}
}
extension NSManagedObject: CoreStoreDebugStringConvertible {
public var coreStoreDumpString: String {
// TODO:
var string = "("
// string.appendDumpInfo("self", self)
string.indent(1)
string.appendContentsOf("\n)")
return string
}
}
extension NSManagedObjectModel: CoreStoreDebugStringConvertible {
public var coreStoreDumpString: String {
@@ -954,6 +1129,19 @@ extension NSManagedObjectModel: CoreStoreDebugStringConvertible {
}
}
extension NSManagedObjectID: CoreStoreDebugStringConvertible {
public var coreStoreDumpString: String {
return createFormattedString(
"\(self.URIRepresentation().coreStoreDumpString) (", ")",
("entity.name", self.entity.name),
("temporaryID", self.temporaryID),
("persistentStore?.URL", self.persistentStore?.URL)
)
}
}
extension NSMappingModel: CoreStoreDebugStringConvertible {
public var coreStoreDumpString: String {
@@ -976,14 +1164,14 @@ extension NSRelationshipDescription: CoreStoreDebugStringConvertible {
return createFormattedString(
"(", ")",
("destinationEntity", self.destinationEntity?.name),
("inverseRelationship", self.inverseRelationship?.name),
("destinationEntity?.name", self.destinationEntity?.name),
("inverseRelationship?.name", self.inverseRelationship?.name),
("minCount", self.minCount),
("maxCount", self.maxCount),
("deleteRule", self.deleteRule),
("toMany", self.toMany),
("ordered", self.ordered),
("entity", self.entity.name),
("entity.name", self.entity.name),
("name", self.name),
("optional", self.optional),
("transient", self.transient),

View File

@@ -70,6 +70,14 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
}
// MARK: NSObject
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: BaseDataTransaction
/**

View File

@@ -253,6 +253,11 @@ public final class CSDataStack: NSObject, CoreStoreObjectiveCType {
return self.bridgeToSwift === object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -62,6 +62,11 @@ public final class CSError: NSError, CoreStoreObjectiveCType {
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -111,6 +111,14 @@ public final class CSFrom: NSObject, CoreStoreObjectiveCType {
}
// MARK: NSObject
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType
public let bridgeToSwift: From<NSManagedObject>

View File

@@ -66,6 +66,11 @@ public final class CSGroupBy: NSObject, CSQueryClause, CoreStoreObjectiveCType {
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CSQueryClause

View File

@@ -101,6 +101,11 @@ public final class CSInMemoryStore: NSObject, CSStorageInterface, CoreStoreObjec
return self.bridgeToSwift === object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -85,6 +85,11 @@ public final class CSInto: NSObject, CoreStoreObjectiveCType {
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -537,6 +537,11 @@ public final class CSListMonitor: NSObject, CoreStoreObjectiveCType {
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -153,6 +153,11 @@ public final class CSMigrationResult: NSObject, CoreStoreObjectiveCType {
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -99,6 +99,11 @@ public final class CSMigrationType: NSObject, CoreStoreObjectiveCType {
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -115,6 +115,11 @@ public final class CSObjectMonitor: NSObject, CoreStoreObjectiveCType {
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -104,6 +104,11 @@ public final class CSOrderBy: NSObject, CSFetchClause, CSQueryClause, CSDeleteCl
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CSFetchClause, CSQueryClause, CSDeleteClause

View File

@@ -179,6 +179,11 @@ public final class CSSQLiteStore: NSObject, CSLocalStorage, CoreStoreObjectiveCT
return self.bridgeToSwift === object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -153,6 +153,11 @@ public final class CSSaveResult: NSObject, CoreStoreObjectiveCType {
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType

View File

@@ -64,6 +64,14 @@ public final class CSSectionBy: NSObject, CoreStoreObjectiveCType {
}
// MARK: NSObject
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType
public let bridgeToSwift: SectionBy

View File

@@ -364,6 +364,11 @@ public final class CSSelect: NSObject {
&& self.selectTerms == object.selectTerms
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType
@@ -371,6 +376,7 @@ public final class CSSelect: NSObject {
self.attributeType = T.attributeType
self.selectTerms = swiftValue.selectTerms
self.bridgeToSwift = swiftValue
super.init()
}
@@ -378,6 +384,7 @@ public final class CSSelect: NSObject {
self.attributeType = .UndefinedAttributeType
self.selectTerms = swiftValue.selectTerms
self.bridgeToSwift = swiftValue
super.init()
}
@@ -386,6 +393,11 @@ public final class CSSelect: NSObject {
internal let attributeType: NSAttributeType
internal let selectTerms: [SelectTerm]
// MARK: Private
private let bridgeToSwift: CoreStoreDebugStringConvertible
}

View File

@@ -56,7 +56,7 @@ public final class CSSetupResult: NSObject {
}
/**
A `CSStorageInterface` instance if the `commit` operation for the transaction succeeded. Returns `NO` otherwise.
A `CSStorageInterface` instance if the `commit` operation for the transaction succeeded. Returns `nil` otherwise.
*/
@objc
public let storage: CSStorageInterface?
@@ -143,6 +143,11 @@ public final class CSSetupResult: NSObject {
return self.storage === object.storage
&& self.error == object.error
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType
@@ -159,8 +164,14 @@ public final class CSSetupResult: NSObject {
self.storage = nil
self.error = error.bridgeToObjectiveC
}
self.bridgeToSwift = swiftValue
super.init()
}
// MARK: Private
private let bridgeToSwift: CoreStoreDebugStringConvertible
}

View File

@@ -70,6 +70,14 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
}
// MARK: NSObject
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: BaseDataTransaction
/**

View File

@@ -50,6 +50,14 @@ public final class CSTweak: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
}
// MARK: NSObject
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CSFetchClause, CSQueryClause, CSDeleteClause
@objc

View File

@@ -138,6 +138,14 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
}
// MARK: NSObject
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CoreStoreObjectiveCType
internal typealias SwiftType = UnsafeDataTransaction

View File

@@ -117,6 +117,11 @@ public final class CSWhere: NSObject, CSFetchClause, CSQueryClause, CSDeleteClau
return self.bridgeToSwift == object.bridgeToSwift
}
public override var description: String {
return "(\(String(reflecting: self.dynamicType))) \(self.bridgeToSwift.coreStoreDumpString)"
}
// MARK: CSFetchClause, CSQueryClause, CSDeleteClause

View File

@@ -1192,11 +1192,33 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
// MARK: - ListMonitor: Equatable
@available(OSX, unavailable)
public func ==<T: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
@warn_unused_result
public func == <T: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
return lhs === rhs
}
@available(OSX, unavailable)
@warn_unused_result
public func == <T: NSManagedObject, U: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
return lhs.fetchedResultsController === rhs.fetchedResultsController
}
@available(OSX, unavailable)
@warn_unused_result
public func ~= <T: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<T>) -> Bool {
return lhs === rhs
}
@available(OSX, unavailable)
@warn_unused_result
public func ~= <T: NSManagedObject, U: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
return lhs.fetchedResultsController === rhs.fetchedResultsController
}
@available(OSX, unavailable)
extension ListMonitor: Equatable { }
@@ -1309,15 +1331,6 @@ extension ListMonitor: FetchedResultsControllerHandler {
}
// MARK: - ListMonitor: Equatable
@warn_unused_result
public func == <T: NSManagedObject, U: NSManagedObject>(lhs: ListMonitor<T>, rhs: ListMonitor<U>) -> Bool {
return lhs.fetchedResultsController === rhs.fetchedResultsController
}
// MARK: - Notification Keys
private let ListMonitorWillChangeListNotification = "ListMonitorWillChangeListNotification"

View File

@@ -301,7 +301,13 @@ public final class ObjectMonitor<T: NSManagedObject> {
// MARK: - ObjectMonitor: Equatable
@available(OSX, unavailable)
public func ==<T: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
public func == <T: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
return lhs === rhs
}
@available(OSX, unavailable)
public func ~= <T: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
return lhs === rhs
}