Skip to content

Commit aaf356c

Browse files
committed
Update README.md
1 parent 43b5aae commit aaf356c

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

README.md

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Android LINQ
2+
23
Manipulate collections easily using C# LINQ style queries and Java 8 closures.
34

4-
# Description
5+
## Description
56

67
Android LINQ is a small subset of collection manipulation utilities inspired by Microsoft C# LINQ library and targeted at Android developers looking to use new Java 8 Stream() API.
78

@@ -11,23 +12,15 @@ Android LINQ has little to no impact on performance because it does not make use
1112

1213
Anyway, you need not to worry. Just add this to your Gradle/Maven and suffer with manual collection iteration no more!
1314

14-
# Usage
15+
## Usage
16+
17+
### Android
1518

1619
To use Android LINQ, first, go and setup [Retrolambda for Android](https://github.com/evant/gradle-retrolambda) so we can use those fancy closures from Java 8 (don't worry, its just some extra lines on your build.gradle file).
1720

1821
Now, just add this line to your project build.gradle (files are hosted in Bintray jCenter, so don't forget to add it to the repositories list too).
1922

20-
### Maven
21-
22-
```
23-
<dependency>
24-
<groupId>br.com.zbra</groupId>
25-
<artifactId>android-linq</artifactId>
26-
<version>1.0.0</version>
27-
</dependency>
28-
```
29-
30-
### Gradle
23+
#### Gradle
3124

3225
```
3326
...
@@ -40,44 +33,63 @@ repositories {
4033
compile 'br.com.zbra:android-linq:1.0.0'
4134
```
4235

43-
# Examples
36+
### Standard Java 8
37+
38+
Android LINQ uses standard Java and therefore can also be used outside Android.
39+
40+
#### Maven
41+
42+
```
43+
<repositories>
44+
...
45+
<repository>
46+
<id>jcenter</id>
47+
<url>http://jcenter.bintray.com </url>
48+
...
49+
</repository>
50+
...
51+
</repositories>
52+
```
53+
```
54+
<dependency>
55+
<groupId>br.com.zbra</groupId>
56+
<artifactId>android-linq</artifactId>
57+
<version>1.0.0</version>
58+
</dependency>
59+
```
4460

45-
### Get names from contacts
61+
## Examples
4662

63+
#### Get names from contacts
4764
```
4865
List<String> contactNames =
4966
stream(contacts)
5067
.select(c -> c.getName())
5168
.toList();
5269
````
53-
54-
### Get contacts who are 27 years or older
70+
#### Get contacts who are 27 years or older
5571
```
5672
List<Contact> contacts =
5773
stream(contacts)
58-
.where(c - > c.getAge() >= 27)
74+
.where(c -> c.getAge() >= 27)
5975
.toList();
6076
```
61-
### Sort contacts by name, then by age
77+
#### Sort contacts by name, then by age
6278
```
6379
List<Contact> contactNames =
6480
stream(contacts)
65-
.orderBy(c - > c.getName())
66-
.thenBy(c - > c.Age())
81+
.orderBy(c -> c.getName())
82+
.thenBy(c -> c.Age())
6783
.toList();
6884
```
69-
70-
### Group products by category
71-
85+
#### Group products by category
7286
```
7387
Map<Category, Stream<Product>> productsByCategory
7488
stream(products)
7589
.groupBy(p -> p.getCategory())
7690
.toMap(g -> g.getKey() /* Category */, g.getElements() /* Stream<Product> */)
7791
```
78-
79-
### Calculate the total price of a purchase
80-
92+
#### Calculate the total price of a purchase
8193
```
8294
double total =
8395
stream(purchase.getItems())
@@ -86,7 +98,7 @@ double total =
8698
8799
There are many more methods: first(), single(), distinct(), any(), aggregate(), count(), take(), skip() and reverse() are all available. Have fun!
88100
89-
# Pull Requests Are Welcome!
101+
## Pull Requests Are Welcome!
90102
91103
Please, send feedback and pull requests a plenty!
92104
If you find a bug, a missing feature or have an improvement suggestion, don't be afraid to file an issue and we will do our best to attend it.

0 commit comments

Comments
 (0)