https://github.com/digipolitan/java-code-writer
https://github.com/digipolitan/java-code-writer
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/digipolitan/java-code-writer
- Owner: Digipolitan
- License: bsd-3-clause
- Created: 2017-08-18T08:43:37.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-13T20:49:57.000Z (over 7 years ago)
- Last Synced: 2025-01-17T00:20:13.541Z (4 months ago)
- Language: Swift
- Size: 47.9 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
JavaCodeWriter
=================================[](https://developer.apple.com/swift/)
[](https://swift.org/package-manager/)
[](http://twitter.com/Digipolitan)Library to write java source code
## Installation
### SPM
To install JavaCodeWriter with SwiftPackageManager, add the following lines to your `Package.swift`.
```swift
let package = Package(
name: "XXX",
products: [
.library(
name: "XXX",
targets: ["XXX"]),
],
dependencies: [
.package(url: "https://github.com/Digipolitan/ode-writer.git", from: "1.0.0")
],
targets: [
.target(
name: "XXX",
dependencies: ["JavaCodeWriter"])
]
)
```## The Basics
You must create a file description that represent the java output file with the given following type
- class `ClassDescription`
- enum `EnumDescription`
- protocol `InterfaceDescription````swift
// Create a User class with 2 fields
var cd = ClassDescription(name: "User", options: .init(visibility: .public))
cd.fields.append(.init(name: "lastName", type: "String"))
cd.fields.append(.init(name: "firstName", type: "String"))
let fileDescription = FileDescription(classDescription: cd, package: "com.digipolitan.user")
```After that use the FileWriter to transform the given FileDescription to string as follow
```swift
let res = FileWriter.default.write(description: fileDescription)
```## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details!
This project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report
unacceptable behavior to [[email protected]](mailto:[email protected]).## License
JavaCodeWriter is licensed under the [BSD 3-Clause license](LICENSE).