Last active
August 29, 2015 14:02
-
-
Save plumhead/07ec4be10c5c968304c4 to your computer and use it in GitHub Desktop.
Pipe and Chains!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getOrElse<S>(f : @auto_closure () -> S)(a : S?) -> S { | |
if let r = a { | |
return r | |
} | |
else { | |
return f() | |
} | |
} | |
class func allRootElementsOfType(document : UmlDocument, type : String) -> Array<ModelElementNode> { | |
return | |
document.project?.profile?.modelNode?.childNodes | |
|> getOrElse (Array()) | |
|> filter {$0.elementType == type} | |
} | |
class func allStereotypes(document : UmlDocument) -> Array<ModelElementNode> { | |
return allRootElementsOfType(document, type: "sterotype") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment