Skip to content

Commit 4bc4b6c

Browse files
committed
Improved readme
1 parent b59bced commit 4bc4b6c

File tree

1 file changed

+24
-69
lines changed

1 file changed

+24
-69
lines changed

README.md

Lines changed: 24 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,42 @@
11
# TypedRest for Java
22

3-
[![API documentation](https://img.shields.io/badge/api-docs-orange.svg)](https://dotnet.typedrest.net/)
43
[![Build status](https://img.shields.io/appveyor/ci/TypedRest/typedrest-java.svg)](https://ci.appveyor.com/project/TypedRest/typedrest-java)
5-
TypedRest helps you build type-safe fluent-style REST API clients.
4+
TypedRest helps you build type-safe, fluent-style REST API clients.
65

7-
Maven artifacts (group `com.oneandone`):
8-
[![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)
9-
[![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)
10-
[![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)
11-
[![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)
12-
13-
**Important:** [Lombok](https://projectlombok.org/), a build-time dependency, does not support Java 10 yet. However, the resulting artifact will work on Java 10.
14-
15-
16-
## Nomenclature
17-
18-
We use the following terms in the library and documentation:
19-
* An __entity__ is a data transfer object that can be serialized (usually as JSON).
20-
* An __endpoint__ is a REST resource at a specific URI.
21-
* An __entry endpoint__ is an _endpoint_ that is the top-level URI of a REST interface.
22-
* An __element endpoint__ is an _endpoint_ that represents a single _entity_.
23-
* A __collection endpoint__ is an _endpoint_ that represents a collection of _entities_ and provides an _element endpoint_ for each of them.
24-
* A __trigger endpoint__ is an _endpoint_ that represents an RPC call to trigger a single action (intentionally un-RESTful).
6+
Common REST patterns such as collections are represented as classes, allowing you to write more idiomatic code. For example, TypedRest lets you turn this:
257

8+
```java
9+
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("http://example.com/contacts/123")).build();
10+
HttpResponse<> response = HttpClient.newHttpClient().send(request, BodyHandlers.ofString());
11+
Contact contact = objectMapper.readValue(response.body(), Contact.class);
12+
```
2613

27-
## Usecase sample
14+
into this:
2815

29-
We'll use this simple POJO (Plain old Java object) class modeling software packages as a sample _entity_ type:
3016
```java
31-
class PackageEntity {
32-
private int id;
33-
@Id public int getId() { return id; }
34-
public void setId(int id) { this.id = id; }
35-
36-
private String name;
37-
public String getName() { return name; }
38-
public void setName(String name) { this.name = name; }
39-
}
17+
MyServiceClient myService = new MyServiceClient(URI.create("http://example.com/"));
18+
Contact contact = myService.getContacts().get("123").read();
4019
```
4120

21+
## Maven artifacts
4222

43-
## Getting started
23+
Artifact group: `com.oneandone`
4424

45-
Include this in your Maven ```pom.xml``` to use the library:
46-
```xml
47-
<dependency>
48-
<groupId>com.oneandone</groupId>
49-
<artifactId>typedrest-core</artifactId>
50-
<version>0.30</version>
51-
</dependency>
52-
```
25+
[![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)
26+
The main TypedRest library.
5327

54-
You can then use the classes `EntryEndpoint`, `CollectionEndpointImpl`, `ElementEndpointImpl`, `PollingEndpointImpl`, `ActionEndpointImpl`, `PaginationEndpointImpl`, `StreamEndpointImpl` and `BlobEndpointImpl` to build a local representation of a remote REST service. Based on our usecase sample this could look like this:
55-
```java
56-
class SampleEntryEndpoint extends EntryEndpoint {
57-
public SampleEntryEndpoint(URI uri) {
58-
super(uri);
59-
}
28+
[![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)
29+
Annotations for data models to be used with TypedRest.
6030

61-
public CollectionEndpoint<PackageEntity> getPackages() {
62-
return new CollectionEndpointImpl<>(this, "packages", PackageEntity.class);
63-
}
64-
}
65-
```
31+
[![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)
32+
Build [Vaadin](https://vaadin.com/) GUIs for TypedRest clients.
6633

67-
You can then perform CRUD operations like this:
68-
```java
69-
SampleEntryEndpoint server = new SampleEntryEndpoint(URI.create("http://myservice/api/"));
70-
List<PackageEntity> packages = server.packages.readAll();
71-
ElementEndpoint<PackageEntity> element = server.packages.create(new PackageEntity(...));
72-
PackageEntity pack = server.packages.get(1).read();
73-
server.Packages.get(1).update(pack);
74-
server.Packages.get(1).delete();
75-
```
34+
[![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)
35+
[Maven archetype](https://maven.apache.org/guides/introduction/introduction-to-archetypes.html) (template) for creating TypedRest projects.
7636

7737

78-
## Build GUI clients
38+
## Documentation
7939

80-
Include this in your Maven ```pom.xml``` to build GUIs with [Vaadin](https://vaadin.com/):
81-
```xml
82-
<dependency>
83-
<groupId>com.oneandone</groupId>
84-
<artifactId>typedrest-vaadin</artifactId>
85-
<version>0.27</version>
86-
</dependency>
87-
```
40+
Read an **[Introduction](https://typedrest.net/introduction/)** to TypedRest or jump right in with the **[Getting started](https://typedrest.net/getting-started/java/)** guide.
41+
42+
For information about specific classes or interfaces you can read the **[API Documentation](https://java.typedrest.net/)**.

0 commit comments

Comments
 (0)