rythm-swift.unionGlobals.txt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of courier-swift-generator Show documentation
Show all versions of courier-swift-generator Show documentation
Swift data binding generator for multiple data formats including JSON and Avro.
@args com.linkedin.pegasus.generator.spec.UnionTemplateSpec union, String path, org.coursera.courier.swift.SwiftSyntax syntax, org.coursera.courier.swift.SwiftyJSON swifty
@import com.linkedin.pegasus.generator.spec.UnionTemplateSpec.Member
@{ String className = ((path == null || path.trim().length() == 0) ? "" : (path + ".")) + syntax.escapeKeyword(union.getClassName()) }
@if (syntax.isEquatable()) {
public func ==(lhs: @className, rhs: @className) -> Bool {
switch (lhs, rhs) {
@for(Member member: union.getMembers()) {
@{ String unionMemberName = syntax.toUnionMemberName(member.getClassTemplateSpec()) }
case (let .@(unionMemberName)(lhs), let .@(unionMemberName)(rhs)):
return lhs == rhs
}
case (let .UNKNOWN$(lhs), let .UNKNOWN$(rhs)):
return JSON(lhs) == JSON(rhs)
default:
return false
}
}
}