在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:greenrobot/essentials开源软件地址:https://github.com/greenrobot/essentials开源编程语言:Java 95.1%开源软件介绍:EssentialsEssentials are a collection of general-purpose classes we found useful in many occasions.
This project is bare bones compared to a rich menu offered by Guava or Apache Commons. Essentials is not a framework, it's rather a small set of utilities to make Java standard approaches more convenient or more efficient. Features
Read more on our website. PerformanceSome classes where motivated by less than optimal performance offered by standard Java. For long keys (also works for int), Essentials provides a specialized implementation, that can be twice as fast. Here are some (completely non-scientific) benchmarking results running on Ubuntu 20.04 LTS using OpenJDK 11.0.9:
The benchmarking sources are available in the java-essentials-performance directory. Add the dependency to your projectFor Gradle, you add this dependency (from repository
And for Maven:
Code samplesExample code for some of the utility classes: // Get all bytes from stream and close the stream safely
byte[] bytes = IoUtils.readAllBytesAndClose(inputStream);
// Read the contents of an file as a string (use readBytes to get byte[])
String contents = FileUtils.readUtf8(file);
// How many days until new year's eve?
long time2 = DateUtils.getTimeForDay(2015, 12, 31);
int daysToNewYear = DateUtils.getDayDifference(time, time2); Multimaps: ListMap<String,String> multimap = new ListMap<>();
multimap.putElement("a", "1");
multimap.putElement("a", "2");
multimap.putElement("a", "3");
List<String> strings = multimap.get("a"); // Contains "1", "2", and "3" Our hash functions implement java.util.zip.Checksum, so this code might look familiar to you: Murmur3A murmur = new Murmur3A();
murmur.update(bytes);
long hash = murmur.getValue(); All hashes can be calculated progressively by calling update(...) multiple times. Our Murmur3A implementation goes a step further by offering updates with primitive data in a very efficient way: // reuse the previous instance and start over to calculate a new hash
murmur.reset();
murmur.updateLong(42L);
// Varargs and arrays are supported natively, too
murmur.updateInt(2014, 2015, 2016);
// Hash for the previous update calls. No conversion to byte[] necessary.
hash = murmur.getValue(); The utility classes are straight forward and don't have dependencies, so you should be fine to grasp them by having a look at their source code. Most of the method names should be self-explaining, and often you'll find JavaDocs where needed. Build setupWe use Gradle as a primary build system. Previously, Maven is used to build greenrobot-common. Inside of build-common, there are two parent POMs defined that might be useful: parent-pom and parent-pom-with-checks. The latter integrates FindBugs and Checkstyle in your build. Use it like this:
LicenseCopyright (C) 2012-2020 Markus Junginger, greenrobot (https://greenrobot.org) EventBus binaries and source code can be used according to the Apache License, Version 2.0. More by greenrobotEventBus is a central publish/subscribe bus for Android with optional delivery threads, priorities, and sticky events. A great tool to decouple components (e.g. Activities, Fragments, logic components) from each other. ObjectBox super-fast object database. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论