{"id":13768453,"url":"https://github.com/havardh/javaflow","last_synced_at":"2025-04-09T19:11:20.985Z","repository":{"id":57719884,"uuid":"71034081","full_name":"havardh/javaflow","owner":"havardh","description":"Java model to flowtype converter","archived":false,"fork":false,"pushed_at":"2019-02-05T17:46:53.000Z","size":379,"stargazers_count":22,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T19:11:15.757Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/havardh.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-16T06:27:09.000Z","updated_at":"2021-06-22T23:01:29.000Z","dependencies_parsed_at":"2022-09-26T21:41:08.989Z","dependency_job_id":null,"html_url":"https://github.com/havardh/javaflow","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/havardh%2Fjavaflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/havardh%2Fjavaflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/havardh%2Fjavaflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/havardh%2Fjavaflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/havardh","download_url":"https://codeload.github.com/havardh/javaflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094990,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:01:21.588Z","updated_at":"2025-04-09T19:11:20.947Z","avatar_url":"https://github.com/havardh.png","language":"Java","funding_links":[],"categories":["Tools"],"sub_categories":[],"readme":"# Javaflow #\n\n`javaflow` converts a set of Java models to Flow types.\n[![CircleCI](https://circleci.com/gh/havardh/javaflow.svg?style=svg)](https://circleci.com/gh/havardh/javaflow)\n\n## Example ##\n\n`javaflow` takes a list of Java class files, and writes the flow types\nfor the models to the standard output.\n\nA simple example is the following conversion of `Post.java` to `post.js`.\n\n```\npublic class Post {\n  private String title;\n  private String text;\n  \n  public String getTitle() { return this.title; }\n  public String getText() { return this.text; }\n}\n```\n\n```\njavaflow Post.java \u003epost.js\n```\n\n```\n/* @flow */\nexport type Post {\n  title: string,\n  text: string,\n};\n```\n\n## Installation ##\n\n### Embedding in maven build\n\nSee the [readme](https://github.com/havardh/javaflow-maven-plugin/blob/master/Readme.md) of the javaflow-maven-plugin repository.\n\n### Standalone cli tool\n\nDownload the most recent zip file under releases.\nUnzip the downloaded file to the desired location like `~/apps/javaflow`.\nAdd `~/app/javaflow/bin` to your `PATH` variable.\n\n## Advanced usage ##\n\n### Custom type substitution ###\n\nInternally `javaflow` contains a mapping from standard Java types like String, int and boolean\nto corresponding flow types. This mapping can be overridden, or additional mappings can be provided.\n\nAn use case for providing custom type substitutions is when the Java model contains a type with\na custom serialized form.\n\nConsider the model `Person` with the `Ssn` wrapper type below.\n\n```\ncom.github.havardh.examples;\n\npublic class Ssn {\n  private String ssn;\n  \n  public String getSsn() { return this.ssn; }\n}\n```\n\n```\ncom.github.havardh.examples;\n\npublic class Person {\n  private Ssn ssn;\n  \n  public Ssn getSsn() { return this.ssn; }\n}\n```\n\nLets say we the Java api layer contains a custom json serializer which removes the wrapper\ntype and outputs the ssn directly like so:\n\n```\n{\"ssn\": \"12120032701\"}\n```\n\nWithout any further configuration, `javaflow Person.java Ssn.java` would convert the types as follows\n\n```\n/* @flow */\nexport type Ssn = {\n  ssn: string,\n};\n\nexport type Person = {\n  ssn: Ssn,\n};\n```\n\nHere we want the string to be included in the Person type directly.\nThis can be achieved by supplying a `types.yml`. The `types.yml` file is\nread from the folder the `javaflow` command is executed from.\n\n```\ncom.github.havardh.examples.Ssn: string\n```\n\nThe format of the yaml file is `\u003ccanonical java type\u003e: \u003cflow type\u003e`.\n\nNow `javaflow Person.java` will output:\n\n```\n/* @flow */\nexport type Person = {\n  ssn: string,\n};\n``` \n\nNote: executing the command `javaflow Person.java` without the `types.yml` file would lead \nto the program failing due to the `Ssn.java` file not being found. `javaflow` does not look\nfor additional files which where not supplied as input.\n\n### Verifiers ###\n\nIn case you want to verify that you have specified mappings for all types,\nthat the DTOs have getters for all fields,\nor that the type of the fields are same as the return types of their getters,\n`javaflow` offers the possibility to add verifiers.\n\nAvailable verifiers:\n- `MemberFieldsPresentVerifier`, active by default, verifies that all types used in the types converted are either:\n    - built-in java types,\n    - overridden by custom type substitution, or\n    - included as a type being converted. \n- `ClassGetterNamingVerifier`, can be activated by passing the `--verifyGetters` flag in the CLI, verifies that the given types all have:\n    - the same number of fields and getters,\n    - the same type in the field definitions as the return type in the corresponding getter and\n    - their getters for the corresponding fields with the same name, prefixed with `get` or `is`.\n\n### Annotations ###\n\n - A field annotated with a `Nullable` annotation will translated to a Maybe type. \n\n## Development ##\n\n### Package ###\n\nRun the following command to package a zip file with all dependencies and the `javaflow` binary.\n\n`gradle assemble`\n\nThis create a zip file in the target folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavardh%2Fjavaflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhavardh%2Fjavaflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhavardh%2Fjavaflow/lists"}