All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rythm-swift.union.txt Maven / Gradle / Ivy

@args com.linkedin.pegasus.generator.spec.UnionTemplateSpec union, org.coursera.courier.swift.SwiftSyntax syntax, org.coursera.courier.swift.SwiftyJSON swifty
@import com.linkedin.pegasus.generator.spec.UnionTemplateSpec.Member
@import org.coursera.courier.schema.TypedDefinitions

@maybePackageAndImports(union)

@{ String className = syntax.escapeKeyword(union.getClassName()) }

@if (union.getTyperefClass() != null) {
  @classAnnotations(union.getTyperefClass().getSchema())
}

public enum @className: Serializable@if (syntax.isEquatable()) {, Equatable} {
  @for(Member member: union.getMembers()) {
    @{ String unionMemberName = syntax.toUnionMemberName(member.getClassTemplateSpec()) }
    case @(unionMemberName)(@syntax.toType(member.getClassTemplateSpec(), false))
  }
  case UNKNOWN$([String : AnyObject])

  @if (TypedDefinitions.isTypedDefinition(union)) {
    @typedDefinitionSerializers(union, TypedDefinitions.getTypedDefinitionMapping(union, false), syntax, swifty)
  } else if (TypedDefinitions.isFlatTypedDefinition(union)) {
    @flatTypedDefinitionSerializers(union, TypedDefinitions.getTypedDefinitionMapping(union, true), syntax, swifty)
  } else {
    @unionSerializers(union, syntax, swifty)
  }

  @* TODO: implement
  public var hashValue: Int {
    switch self {
      @for(Member member: union.getMembers()) {
        @{ String unionMemberName = syntax.toUnionMemberName(member.getClassTemplateSpec()) }
        case .@(unionMemberName)(let member):
          return hashOf(member)
      }
      case .UNKNOWN$(let dictionary):
        return hashOf(dictionary)
    }
  }
  *@
}

@if (union.getEnclosingClass() == null) {
  @unionGlobals(union, null, syntax)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy