[Git][java-team/guava-mini][upstream] New upstream version 0.1.4
Mechtilde Stehmann (@mechtilde)
gitlab at salsa.debian.org
Sun Dec 11 19:46:36 GMT 2022
Mechtilde Stehmann pushed to branch upstream at Debian Java Maintainers / guava-mini
Commits:
3c95659c by Mechtilde at 2022-10-14T16:42:33+02:00
New upstream version 0.1.4
- - - - -
8 changed files:
- + .github/dependabot.yml
- + .github/workflows/ci.yml
- − .travis.yml
- README.md
- pom.xml
- src/main/java/com/github/davidmoten/guavamini/Lists.java
- + src/main/java/com/github/davidmoten/guavamini/Maps.java
- + src/test/java/com/github/davidmoten/guavamini/MapsTest.java
Changes:
=====================================
.github/dependabot.yml
=====================================
@@ -0,0 +1,11 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for all configuration options:
+# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+
+version: 2
+updates:
+ - package-ecosystem: "maven" # See documentation for possible values
+ directory: "/" # Location of package manifests
+ schedule:
+ interval: "daily"
=====================================
.github/workflows/ci.yml
=====================================
@@ -0,0 +1,23 @@
+name: Java CI
+
+on: [push]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ java: ['8', '11']
+ steps:
+ - uses: actions/checkout at v2
+ - name: Set up JDK ${{ matrix.java }}
+ uses: actions/setup-java at v2
+ with:
+ java-version: ${{ matrix.java }}
+ distribution: 'adopt'
+ - name: Build with Maven
+ run: mvn --batch-mode --update-snapshots verify
+ - uses: codecov/codecov-action at v1
+ with:
+ file: ./**/target/site/jacoco/jacoco.xml
+ name: codecov
=====================================
.travis.yml deleted
=====================================
@@ -1,3 +0,0 @@
-language: java
-jdk:
- - openjdk8
=====================================
README.md
=====================================
@@ -1,10 +1,10 @@
# guava-mini
-[](https://travis-ci.org/davidmoten/guava-mini)<br/>
+<a href="https://github.com/davidmoten/guava-mini/actions/workflows/ci.yml"><img src="https://github.com/davidmoten/guava-mini/actions/workflows/ci.yml/badge.svg"/></a><br/>
[](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/guava-mini)<br/>
+[](https://codecov.io/gh/davidmoten/guava-mini)<br/>
+Some popular utilities from Guava repackaged (with different package names but same class names and method names) into a little jar (15K) available on Maven Central.
-Some popular utilities from Guava repackaged (with different package names but same class names and method names) into a little jar (11K) available on Maven Central.
-
-Compatible with java 6 and later.
+Compatible with java 8 and later.
Status: *on Maven Central*
@@ -21,6 +21,13 @@ Taken from Guava:
* `Lists`: `newArrayList`
* `Sets`: `newHashSet`
+Non-guava:
+
+* `Maps`: `hashMap`, `treeMap`, `linkedHashMap`
+```java
+Map<Integer, String> map = Maps.put(1, "hi").put(2, "there").build();
+```
+
Getting started
------------------
Add this dependency to your pom.xml:
@@ -28,6 +35,6 @@ Add this dependency to your pom.xml:
<dependency>
<groupId>com.github.davidmoten</groupId>
<artifactId>guava-mini</artifactId>
- <version>0.1.1</version>
+ <version>VERSION_HERE</version>
</dependency>
```
=====================================
pom.xml
=====================================
@@ -10,7 +10,7 @@
</parent>
<artifactId>guava-mini</artifactId>
- <version>0.1.3</version>
+ <version>0.1.4</version>
<name>${project.artifactId}</name>
<description>Classes taken from Guava</description>
@@ -21,22 +21,18 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <maven.compiler.target>1.6</maven.compiler.target>
+ <maven.compiler.target>1.8</maven.compiler.target>
<scm.url>scm:git:https://github.com/davidmoten/guava-mini.git</scm.url>
- <cobertura.version>2.7</cobertura.version>
- <checkstyle.version>2.13</checkstyle.version>
- <findbugs.version>3.0.1</findbugs.version>
- <javadoc.version>2.10.3</javadoc.version>
- <pmd.version>3.4</pmd.version>
- <jdepend.version>2.0-beta-2</jdepend.version>
- <javancss.version>2.1</javancss.version>
- <project.info.version>2.7</project.info.version>
- <jxr.version>2.5</jxr.version>
+ <checkstyle.version>3.1.2</checkstyle.version>
+ <javadoc.version>3.2.0</javadoc.version>
+ <pmd.version>3.15.0</pmd.version>
+ <project.info.version>3.1.1</project.info.version>
+ <jxr.version>3.0.0</jxr.version>
<taglist.version>2.4</taglist.version>
- <m3.site.version>3.4</m3.site.version>
+ <m3.site.version>3.9.1</m3.site.version>
<changelog.version>2.2</changelog.version>
- <bundle.plugin.version>4.2.1</bundle.plugin.version>
+ <bundle.plugin.version>5.1.1</bundle.plugin.version>
<coverage.reports.dir>${project.build.directory}/target/coverage-reports</coverage.reports.dir>
</properties>
@@ -78,7 +74,7 @@
<connection>${scm.url}</connection>
<developerConnection>${scm.url}</developerConnection>
<url>${scm.url}</url>
- <tag>0.1.3</tag>
+ <tag>0.1.4</tag>
</scm>
<dependencies>
@@ -87,21 +83,21 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.12</version>
+ <version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
- <version>1.10.8</version>
+ <version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.davidmoten</groupId>
<artifactId>junit-extras</artifactId>
- <version>0.3</version>
+ <version>0.4</version>
<scope>test</scope>
</dependency>
@@ -112,7 +108,7 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.5.1</version>
+ <version>3.8.1</version>
<configuration>
<source>${maven.compiler.target}</source>
<target>${maven.compiler.target}</target>
@@ -130,19 +126,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>${cobertura.version}</version>
- <configuration>
- <aggregate>false</aggregate>
- <instrumentation>
- <excludes>
- <exclude>com/github/davidmoten/guava-mini/ImageSaver.class</exclude>
- </excludes>
- </instrumentation>
- </configuration>
- </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
@@ -152,6 +135,31 @@
<obrRepository>NONE</obrRepository>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.8.7</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>report</id>
+ <phase>test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <excludes>
+ <exclude>**/FileBasedSPSCQueueMemoryMapped*</exclude>
+ </excludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
<reporting>
@@ -167,11 +175,6 @@
<aggregate>true</aggregate>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>${cobertura.version}</version>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
@@ -189,26 +192,6 @@
<aggregate>true</aggregate>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>${findbugs.version}</version>
- <configuration>
- <xmlOutput>true</xmlOutput>
- <effort>Max</effort>
- <!--<excludeFilterFile>findbugs-exclude-filter-amsa.xml</excludeFilterFile> -->
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jdepend-maven-plugin</artifactId>
- <version>${jdepend.version}</version>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>javancss-maven-plugin</artifactId>
- <version>${javancss.version}</version>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
@@ -231,10 +214,6 @@
<aggregate>true</aggregate>
</configuration>
</plugin>
- <!-- commented this plugin out because cannot run offline (e.g. at home) -->
- <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-changelog-plugin</artifactId>
- <version>${changelog.version}</version> <configuration> <username>${svn.username}</username> <password>${svn.password}</password>
- </configuration> </plugin> -->
</plugins>
</reporting>
=====================================
src/main/java/com/github/davidmoten/guavamini/Lists.java
=====================================
@@ -13,7 +13,7 @@ public final class Lists {
// cannot instantiate
}
- public static <E> ArrayList<E> newArrayList(E... elements) {
+ public static <E> ArrayList<E> newArrayList(@SuppressWarnings("unchecked") E... elements) {
Preconditions.checkNotNull(elements);
// Avoid integer overflow when a large array is passed in
int capacity = computeArrayListCapacity(elements.length);
=====================================
src/main/java/com/github/davidmoten/guavamini/Maps.java
=====================================
@@ -0,0 +1,92 @@
+package com.github.davidmoten.guavamini;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.function.Function;
+
+public final class Maps {
+
+ private Maps() {
+ // prevent instantiation
+ }
+
+ private static final int DEFAULT_INITIAL_SIZE = 16;
+ private static final Function<Integer, Map<Object, Object>> FACTORY_HASHMAP = //
+ size -> new HashMap<Object, Object>(size);
+ private static final Function<Integer, Map<Object, Object>> FACTORY_TREEMAP = //
+ size -> new TreeMap<Object, Object>();
+ private static final Function<Integer, Map<Object, Object>> FACTORY_LINKEDHASHMAP = //
+ size -> new LinkedHashMap<Object, Object>(size);
+
+ public static <K, V> Map<K, V> empty() {
+ return Collections.emptyMap();
+ }
+
+ public static <K, V> MapBuilder<K, V> put(K key, V value) {
+ return hashMap().put(key, value);
+ }
+
+ public static Builder treeMap() {
+ return new Builder(FACTORY_TREEMAP);
+ }
+
+ public static Builder hashMap() {
+ return new Builder(FACTORY_HASHMAP);
+ }
+
+ public static Builder linkedHashMap() {
+ return new Builder(FACTORY_LINKEDHASHMAP);
+ }
+
+ public static Builder factory(
+ Function<? super Integer, ? extends Map<Object, Object>> factory) {
+ Preconditions.checkNotNull(factory, "factory cannot be null");
+ return new Builder(factory);
+ }
+
+ public static final class Builder {
+
+ private final Function<? super Integer, ? extends Map<Object, Object>> factory;
+ private int initialSize = DEFAULT_INITIAL_SIZE;
+
+ Builder(Function<? super Integer, ? extends Map<Object, Object>> factory) {
+ this.factory = factory;
+ }
+
+ public Builder initialSize(int initialSize) {
+ Preconditions.checkArgument(initialSize > 0, "initialSize must be greater than 0");
+ this.initialSize = initialSize;
+ return this;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <K, V> MapBuilder<K, V> put(K key, V value) {
+ return new MapBuilder<K, V>((Map<K, V>) factory.apply(initialSize)).put(key, value);
+ }
+ }
+
+ public static final class MapBuilder<K, V> {
+ private final Map<K, V> map;
+
+ MapBuilder(Map<K, V> map) {
+ this.map = map;
+ }
+
+ public MapBuilder<K, V> put(K key, V value) {
+ map.put(key, value);
+ return this;
+ }
+
+ public Map<K, V> build() {
+ return map;
+ }
+
+ public Map<K, V> buildImmutable() {
+ return Collections.unmodifiableMap(map);
+ }
+ }
+
+}
=====================================
src/test/java/com/github/davidmoten/guavamini/MapsTest.java
=====================================
@@ -0,0 +1,90 @@
+package com.github.davidmoten.guavamini;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.junit.Test;
+
+import com.github.davidmoten.junit.Asserts;
+
+public class MapsTest {
+
+ @Test
+ public void isUtilityClass() {
+ Asserts.assertIsUtilityClass(Maps.class);
+ }
+
+ @Test
+ public void testHashMapSize1() {
+ Map<Integer, String> map = Maps.put(1, "hi").build();
+ assertEquals("hi", map.get(1));
+ assertEquals(1, map.size());
+ assertTrue(map instanceof HashMap);
+ }
+
+ @Test
+ public void testHashMapSize2() {
+ Map<Integer, String> map = Maps.put(1, "hi").put(2, "there").build();
+ assertEquals("hi", map.get(1));
+ assertEquals("there", map.get(2));
+ assertEquals(2, map.size());
+ }
+
+ @Test
+ public void testHashMapEmpty() {
+ Map<Integer, String> map = Maps.empty();
+ assertTrue(map.isEmpty());
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testHashMapImmutable() {
+ Map<Integer, String> map = Maps.put(1, "hi").buildImmutable();
+ assertEquals("hi", map.get(1));
+ assertEquals(1, map.size());
+ map.put(2, "there");
+ }
+
+ @Test
+ public void testHashMapWithInitialSize() {
+ Map<Integer, String> map = Maps.hashMap().initialSize(4).put(1, "hi").build();
+ assertEquals("hi", map.get(1));
+ assertEquals(1, map.size());
+ assertTrue(map instanceof HashMap);
+ }
+
+ @Test
+ public void testCustomMapWithInitialSize() {
+ Map<Integer, String> map = Maps.factory(size -> new HashMap<Object, Object>(size))
+ .initialSize(4).put(1, "hi").build();
+ assertEquals("hi", map.get(1));
+ assertEquals(1, map.size());
+ assertTrue(map instanceof HashMap);
+ }
+
+ @Test
+ public void testTreeMapSize1() {
+ Map<Integer, String> map = Maps.treeMap().put(1, "hi").build();
+ assertEquals("hi", map.get(1));
+ assertEquals(1, map.size());
+ assertTrue(map instanceof TreeMap);
+ }
+
+ @Test
+ public void testLinkedHashMapMapSize1() {
+ Map<Integer, String> map = Maps.linkedHashMap().put(1, "hi").build();
+ assertEquals("hi", map.get(1));
+ assertEquals(1, map.size());
+ assertTrue(map instanceof LinkedHashMap);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMapWithInitialSizeInvalid() {
+ Maps.hashMap().initialSize(0);
+ }
+
+}
View it on GitLab: https://salsa.debian.org/java-team/guava-mini/-/commit/3c95659c3da4d89409a0990ee6909ecb75704bd7
--
View it on GitLab: https://salsa.debian.org/java-team/guava-mini/-/commit/3c95659c3da4d89409a0990ee6909ecb75704bd7
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20221211/0d4a5afe/attachment.htm>
More information about the pkg-java-commits
mailing list