All Projects → zbra-solutions → Android Linq

zbra-solutions / Android Linq

Licence: mit
Manipulate collections easily using C# LINQ style queries and Java 8 closures.

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects

Projects that are alternatives of or similar to Android Linq

Fetch
The best file downloader library for Android
Stars: ✭ 1,124 (+1378.95%)
Mutual labels:  gradle
Android Container
Run E2E Android Testing with Docker Container
Stars: ✭ 68 (-10.53%)
Mutual labels:  gradle
Materialchipview
Material Chip view. Can be used as tags for categories, contacts or creating text clouds
Stars: ✭ 1,181 (+1453.95%)
Mutual labels:  gradle
Anomaly Detection
A machine learning plugin in Open Distro for Elasticsearch for real time anomaly detection on streaming data.
Stars: ✭ 65 (-14.47%)
Mutual labels:  gradle
Android Camera2 Library
Library to use Android Camera2 api easily.
Stars: ✭ 66 (-13.16%)
Mutual labels:  gradle
Cas Gradle Overlay Template
CAS Gradle Overlay: Generic CAS gradle war overlay to exercise the latest versions of CAS
Stars: ✭ 69 (-9.21%)
Mutual labels:  gradle
Spongeforge
A Forge mod that implements SpongeAPI
Stars: ✭ 1,106 (+1355.26%)
Mutual labels:  gradle
Greenbeanpods
A plugin that replaces external module dependencies with project dependencies.
Stars: ✭ 75 (-1.32%)
Mutual labels:  gradle
Version Checker Gradle Lint
Warning on new versions available even when using Kotlin-DSL plugin.
Stars: ✭ 68 (-10.53%)
Mutual labels:  gradle
Sample Boot Micro
Spring Cloud + Gradle Multi Project + Java8
Stars: ✭ 72 (-5.26%)
Mutual labels:  gradle
Habito
Simple habit tracker app for Android
Stars: ✭ 65 (-14.47%)
Mutual labels:  gradle
Microservices Example
Example of a microservices architecture on the modern stack of Java technologies
Stars: ✭ 66 (-13.16%)
Mutual labels:  gradle
Gradle Semantic Build Versioning
Gradle plugin to generate version-numbers and tags using semantic versioning
Stars: ✭ 69 (-9.21%)
Mutual labels:  gradle
Nodebb Webview
NodeBB WebView for Android
Stars: ✭ 64 (-15.79%)
Mutual labels:  gradle
Sorty
Fast Concurrent / Parallel Sorting in Go
Stars: ✭ 74 (-2.63%)
Mutual labels:  sort
Ros2 java
Java and Android bindings for ROS2
Stars: ✭ 60 (-21.05%)
Mutual labels:  gradle
Videosniffer
视频嗅探服务(VideoSniffer API Service On Android)
Stars: ✭ 68 (-10.53%)
Mutual labels:  gradle
Csnackbar
This is a wrapper for android Snackbar. Which giving support to change Snackbar color, duration, message or even it's content view with a custom view.
Stars: ✭ 76 (+0%)
Mutual labels:  gradle
Okta Blog Archive
Okta Developer Blog
Stars: ✭ 74 (-2.63%)
Mutual labels:  gradle
Weechat Autosort
Automatically keep your buffers sorted.
Stars: ✭ 69 (-9.21%)
Mutual labels:  sort

Android LINQ

Manipulate collections easily using C# LINQ style queries and Java 8 closures.

Description

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.

By using Retrolambda for Android, developers can leverage the power of closures and other new Java 8 features. Unfortunately, it doesn't allow the usage of the Stream API which is arguably its most awesome feature. However, by using it in conjunction with Android LINQ, its possible to perform powerful collection manipulation in just a few lines of code.

Android LINQ has little to no impact on performance because it does not make use of reflection or proxies. As its C# counterpart it's based on the monads concept, which is a fancy word to describe a sort of Decorator pattern implementation, and many sorting and ordering are just making calls to the default Java API.

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

Usage

Latest Version

Download

Android

To use Android LINQ, first, go and setup Retrolambda for Android so we can use those fancy closures from Java 8 (don't worry, its just some extra lines on your build.gradle file).

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).

Gradle

Android Studio >= 4.0

Android Studio 4.0 introduced a ne version of Gradle and with that, usage changed a little. See https://jitpack.io/#zbra-solutions/android-linq/1.1.0 for more details.

...
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
...
dependencies {
    implementation 'com.github.zbra-solutions:android-linq:1.1.0'
}

Legacy

...
repositories {
    jcenter()
}
...
compile 'br.com.zbra:android-linq:1.1.0'

Standard Java 8

Android LINQ uses standard Java and therefore can also be used outside Android.

Maven

<repositories>
    ...
    <repository>
      <id>jcenter</id>
      <url>http://jcenter.bintray.com </url>
      ...
    </repository>
    ...
</repositories>
<dependency>
  <groupId>br.com.zbra</groupId>
  <artifactId>android-linq</artifactId>
  <version>1.1.0</version>
</dependency>

Examples

Get names from contacts

List<String> contactNames = 
      stream(contacts)
          .select(c -> c.getName())
          .toList();

Get contacts who are 27 years or older

List<Contact> contacts = 
      stream(contacts)
          .where(c -> c.getAge() >= 27)
          .toList();

Sort contacts by name, then by age

List<Contact> contactNames = 
      stream(contacts)
          .orderBy(c -> c.getName())
          .thenBy(c -> c.Age())
          .toList();

Group products by category

Map<Category, Stream<Product>> productsByCategory
      stream(products)
          .groupBy(p -> p.getCategory())
          .toMap(g -> g.getKey() /* Category */, g.getElements() /* Stream<Product> */)

Calculate the total price of a purchase

double total = 
      stream(purchase.getItems())
          .sum((Purchase p) -> p.getPrice());

There are many more methods: first(), single(), distinct(), any(), aggregate(), count(), take(), skip() and reverse() are all available. Have fun!

Pull Requests Are Welcome!

Please, send feedback and pull requests a plenty! 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].