Skip to content

Commit 18a0b5d

Browse files
committed
Rewrite in Kotlin (wip)
1 parent f98d178 commit 18a0b5d

File tree

206 files changed

+3159
-8270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+3159
-8270
lines changed

.editorconfig

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 4
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
keep_existing_linebreaks = true
11+
max_line_length = off
12+
13+
[*.{json,xml,yml,yaml,htm,html,js,ts,css,scss,less}]
14+
indent_size = 2
15+
16+
[*.{*proj,resx,config,ruleset,cd,props,targets,nuspec}]
17+
end_of_line = crlf
18+
indent_size = 2
19+
20+
[*.{txt,cs,ps1,psd1,manifest}]
21+
end_of_line = crlf
22+
23+
[*.{bat,cmd}]
24+
charset = latin1
25+
end_of_line = crlf
26+
27+
[*.sln]
28+
end_of_line = crlf
29+
indent_style = tab
30+
31+
[*.{md,resx,Designer.*}]
32+
trim_trailing_whitespace = false
33+
34+
[*.cs]
35+
# Indentation
36+
csharp_indent_block_contents = true
37+
csharp_indent_braces = false
38+
csharp_indent_case_contents = true
39+
csharp_indent_switch_labels = true
40+
csharp_outdent_binary_ops = true
41+
csharp_outdent_dots = true
42+
csharp_align_linq_query = true
43+
csharp_align_multiline_parameter = true
44+
csharp_align_multiline_calls_chain = true
45+
csharp_align_multiline_binary_expressions_chain = true
46+
csharp_align_multiline_array_and_object_initializer = false
47+
48+
# Line breaks
49+
csharp_new_line_before_catch = true
50+
csharp_new_line_before_else = true
51+
csharp_new_line_before_finally = true
52+
csharp_new_line_before_members_in_object_initializers = false
53+
csharp_new_line_before_open_brace = all
54+
csharp_blank_lines_around_single_line_field = 0
55+
csharp_blank_lines_inside_region = 0
56+
csharp_blank_lines_around_region = 0
57+
csharp_blank_lines_after_block_statements = 0
58+
csharp_empty_block_style = together
59+
csharp_place_simple_blocks_on_single_line = true
60+
csharp_place_simple_initializer_on_single_line = true
61+
csharp_place_attribute_on_same_line = if_owner_is_single_line
62+
csharp_place_expr_method_on_single_line = true
63+
csharp_place_constructor_initializer_on_same_line = false
64+
csharp_wrap_object_and_collection_initializer_style = chop_if_long
65+
csharp_wrap_array_initializer_style = chop_if_long
66+
csharp_wrap_parameters_style = chop_if_long
67+
csharp_preserve_single_line_blocks = true
68+
csharp_keep_existing_arrangement = true
69+
70+
# Spacing
71+
csharp_space_after_cast = false
72+
csharp_space_after_colon_in_inheritance_clause = true
73+
csharp_space_after_comma = true
74+
csharp_space_after_dot = false
75+
csharp_space_after_keywords_in_control_flow_statements = true
76+
csharp_space_after_semicolon_in_for_statement = true
77+
csharp_space_around_binary_operators = before_and_after
78+
csharp_space_before_colon_in_inheritance_clause = true
79+
csharp_space_before_comma = false
80+
csharp_space_before_dot = false
81+
csharp_space_before_semicolon_in_for_statement = false
82+
csharp_space_before_open_square_brackets = false
83+
csharp_space_between_empty_square_brackets = false
84+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
85+
csharp_space_between_method_declaration_parameter_list_parentheses = false
86+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
87+
csharp_space_between_method_call_name_and_opening_parenthesis = false
88+
csharp_space_between_method_call_parameter_list_parentheses = false
89+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
90+
csharp_space_between_square_brackets = false
91+
csharp_space_within_empty_braces = false
92+
93+
# Style
94+
csharp_parentheses_redundancy_style = remove_if_not_clarifies_precedence
95+
csharp_allow_comment_after_lbrace = true
96+
csharp_braces_for_ifelse = required_for_multiline
97+
csharp_braces_for_for = required_for_multiline
98+
csharp_braces_for_foreach = required_for_multiline
99+
csharp_braces_for_while = required_for_multiline
100+
csharp_braces_for_using = required_for_multiline
101+
csharp_braces_for_lock = required_for_multiline
102+
csharp_braces_for_fixed = required_for_multiline
103+
csharp_style_var_for_built_in_types = false
104+
csharp_style_var_when_type_is_apparent = true
105+
csharp_style_expression_bodied_constructors = false
106+
csharp_style_expression_bodied_accessors = true
107+
csharp_style_expression_bodied_methods = true
108+
csharp_style_expression_bodied_properties = true
109+
csharp_local_function_body = expression_body
110+
csharp_style_qualification_for_event = false
111+
csharp_style_qualification_for_field = false
112+
csharp_style_qualification_for_method = false
113+
csharp_style_qualification_for_property = false
114+
csharp_style_pattern_matching_over_as_with_null_check = true
115+
csharp_style_pattern_matching_over_is_with_cast_check = true
116+
csharp_style_object_initializer = true
117+
csharp_style_collection_initializer = true
118+
csharp_style_explicit_tuple_names = true
119+
csharp_style_null_propagation = true
120+
csharp_style_coalesce_expression = true
121+
csharp_style_conditional_delegate_call = true
122+
csharp_style_throw_expression = true
123+
csharp_style_predefined_type_for_locals_parameters_members = true
124+
csharp_style_predefined_type_for_member_access = true

.gitattributes

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Normalize linebreaks
2-
* text=auto
1+
# Disable linebreak normalization
2+
* -text

.github/workflows/build.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
# Prepare
9+
- uses: actions/checkout@v2
10+
with:
11+
fetch-depth: 0
12+
- uses: gittools/actions/gitversion/setup@v0.10.2
13+
with:
14+
versionSpec: '5.12.x'
15+
- uses: gittools/actions/gitversion/execute@v0.10.2
16+
id: gitversion
17+
- name: Set version (release)
18+
if: github.ref_type == 'tag'
19+
run: echo "VERSION=${{steps.gitversion.outputs.semVer}}" >> $GITHUB_ENV
20+
- name: Set version (pre-release)
21+
if: github.ref_type != 'tag'
22+
run: echo "VERSION=${{steps.gitversion.outputs.semVer}}-${{steps.gitversion.outputs.shortSha}}" >> $GITHUB_ENV
23+
24+
# Build
25+
- run: gradle build
26+
- run: gradle dokkaHtml
27+
- run: gradle test
28+
- name: Report test results
29+
if: always()
30+
uses: dorny/test-reporter@v1
31+
with:
32+
name: Test Report
33+
reporter: java-junit
34+
path: build/test-results/test/TEST-*.xml
35+
36+
# Release
37+
- name: Create GitHub Release
38+
if: github.ref_type == 'tag'
39+
uses: softprops/action-gh-release@v1
40+
41+
# Publish
42+
# - name: Publish packages (GitHub)
43+
# if: github.event_name == 'push' && !startsWith(github.ref_name, 'renovate/')
44+
# run: gradle publishMavenPublicationToGitHubRepository
45+
# env:
46+
# GITHUB_TOKEN: ${{github.token}}
47+
# - name: Publish packages (Maven Central)
48+
# if: github.ref_type == 'tag'
49+
# run: gradle publishToSonatype closeAndReleaseSonatypeStagingRepository
50+
# env:
51+
# SIGNING_KEY: ${{secrets.SIGNING_KEY}}
52+
# SIGNING_PASSWORD: ${{secrets.SIGNING_PASSWORD}}
53+
# SONATYPE_USERNAME: ${{secrets.SONATYPE_USERNAME}}
54+
# SONATYPE_PASSWORD: ${{secrets.SONATYPE_PASSWORD}}
55+
- name: Publish documentation
56+
if: github.ref_type == 'tag'
57+
uses: peaceiris/actions-gh-pages@v3
58+
with:
59+
github_token: ${{github.token}}
60+
force_orphan: true
61+
publish_dir: build/dokka/html
62+
cname: java.typedrest.net

.github/workflows/doc.yml

-27
This file was deleted.

.gitignore

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
#Maven
2-
target/
3-
pom.xml.tag
4-
pom.xml.releaseBackup
5-
pom.xml.versionsBackup
6-
pom.xml.next
7-
release.properties
8-
dependency-reduced-pom.xml
9-
buildNumber.properties
10-
11-
#JetBrains IntelliJ IDEA
1+
build/
2+
.gradle/
123
.idea/
13-
*.iml

GitVersion.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
mode: ContinuousDeployment
2+
3+
branches:
4+
# Mainline branches
5+
develop:
6+
tag: alpha
7+
increment: patch
8+
master:
9+
tag: beta
10+
11+
# Stabilization branches
12+
release:
13+
tag: rc
14+
hotfix:
15+
tag: rc

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2016 1&1 Internet SE
3+
Copyright (c) 2021 Bastian Eicher
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
21+
THE SOFTWARE.

README.md

+32-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# ![TypedRest](logo.svg) for Java
1+
# ![TypedRest](logo.svg) for Java/Kotlin
22

3-
TypedRest for Java helps you build type-safe, fluent-style REST API clients. Common REST patterns such as collections are represented as classes, allowing you to write more idiomatic code.
3+
TypedRest for Java/Kotlin helps you build type-safe, fluent-style REST API clients. Common REST patterns such as collections are represented as classes, allowing you to write more idiomatic code.
4+
5+
**Java**
46

57
```java
68
MyClient client = new MyClient(URI.create("http://example.com/"));
@@ -25,22 +27,41 @@ Note note = smith.getNote().read();
2527
smith.delete();
2628
```
2729

30+
**Kotlin**
31+
32+
```kotlin
33+
val client = MyClient(URI("http://example.com/"))
34+
35+
// GET /contacts
36+
val contactList: List<Contact> = client.contacts.readAll()
37+
38+
// POST /contacts -> Location: /contacts/1337
39+
val smith: ContactEndpoint = client.contacts.create(Contact("Smith"))
40+
//val smith: ContactEndpoint = client.contacts["1337"]
41+
42+
// GET /contacts/1337
43+
val contact: Contact = smith.read()
44+
45+
// PUT /contacts/1337/note
46+
smith.note.set(Note("some note"))
47+
48+
// GET /contacts/1337/note
49+
val note: Note = smith.note.read()
50+
51+
// DELETE /contacts/1337
52+
smith.delete()
53+
```
54+
2855
Read an **[Introduction](https://typedrest.net/introduction/)** to TypedRest or jump right in with the **[Getting started](https://typedrest.net/getting-started/java/)** guide.
2956

3057
For information about specific Java classes or interfaces you can read the **[API Documentation](https://java.typedrest.net/)**.
3158

3259
## Maven artifacts
3360

34-
Artifact group: `com.oneandone`
61+
Artifact group: `net.typedrest`
3562

36-
[![typedrest-core](https://img.shields.io/maven-central/v/com.oneandone/typedrest-core.svg?label=typedrest-core)](https://mvnrepository.com/artifact/com.oneandone/typedrest-core)
63+
[![typedrest-core](https://img.shields.io/maven-central/v/net.typedrest/typedrest.svg?label=typedrest)](https://mvnrepository.com/artifact/net.typedrest/typedrest)
3764
The main TypedRest library.
3865

39-
[![typedrest-annotations](https://img.shields.io/maven-central/v/com.oneandone/typedrest-annotations.svg?label=typedrest-annotations)](https://mvnrepository.com/artifact/com.oneandone/typedrest-annotations)
66+
[![typedrest-annotations](https://img.shields.io/maven-central/v/net.typedrest/typedrest-annotations.svg?label=typedrest-annotations)](https://mvnrepository.com/artifact/net.typedrest/typedrest-annotations)
4067
Annotations for data models to be used with TypedRest.
41-
42-
[![typedrest-vaadin](https://img.shields.io/maven-central/v/com.oneandone/typedrest-vaadin.svg?label=typedrest-vaadin)](https://mvnrepository.com/artifact/com.oneandone/typedrest-vaadin)
43-
Build [Vaadin](https://vaadin.com/) GUIs for TypedRest clients.
44-
45-
[![typedrest-archetype](https://img.shields.io/maven-central/v/com.oneandone/typedrest-archetype.svg?label=typedrest-archetype)](https://mvnrepository.com/artifact/com.oneandone/typedrest-archetype)
46-
[Maven archetype](https://maven.apache.org/guides/introduction/introduction-to-archetypes.html) (template) for creating TypedRest projects.

annotations/pom.xml

-24
This file was deleted.

annotations/src/main/java/net/typedrest/Description.java

-14
This file was deleted.

annotations/src/main/java/net/typedrest/EditorHidden.java

-12
This file was deleted.

annotations/src/main/java/net/typedrest/Id.java

-12
This file was deleted.

0 commit comments

Comments
 (0)