[Git][java-team/guava-mini][upstream] New upstream version 0.1.7

Mechtilde Stehmann (@mechtilde) gitlab at salsa.debian.org
Sun Apr 6 14:18:06 BST 2025



Mechtilde Stehmann pushed to branch upstream at Debian Java Maintainers / guava-mini


Commits:
a52bc60c by Mechtilde at 2025-04-06T14:47:41+02:00
New upstream version 0.1.7
- - - - -


11 changed files:

- + .github/workflows/automerge.yml
- .github/workflows/ci.yml
- README.md
- pom.xml
- src/main/java/com/github/davidmoten/guavamini/Lists.java
- src/main/java/com/github/davidmoten/guavamini/Optional.java
- src/main/java/com/github/davidmoten/guavamini/Preconditions.java
- src/main/java/com/github/davidmoten/guavamini/Sets.java
- src/test/java/com/github/davidmoten/guavamini/ListsTest.java
- src/test/java/com/github/davidmoten/guavamini/PreconditionsTest.java
- src/test/java/com/github/davidmoten/guavamini/SetsTest.java


Changes:

=====================================
.github/workflows/automerge.yml
=====================================
@@ -0,0 +1,23 @@
+name: Dependabot auto-merge
+on: pull_request
+
+permissions:
+  pull-requests: write
+  contents: write
+
+jobs:
+  dependabot:
+    runs-on: ubuntu-latest
+    if: ${{ github.actor == 'dependabot[bot]' }}
+    steps:
+      - name: Dependabot metadata
+        id: metadata
+        uses: dependabot/fetch-metadata at v1.1.1
+        with:
+          github-token: "${{ secrets.GITHUB_TOKEN }}"
+      - name: Enable auto-merge for Dependabot PRs
+        if: ${{!contains(steps.metadata.outputs.dependency-names, 'maven-plugin-api') && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch')}}
+        run: gh pr merge --auto --rebase "$PR_URL"
+        env:
+          PR_URL: ${{github.event.pull_request.html_url}}
+          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}


=====================================
.github/workflows/ci.yml
=====================================
@@ -1,13 +1,23 @@
-name: Java CI
+name: ci 
 
-on: [push]
+## Does continuous integration build with Java 8 and 11 and 
+## if succeeds and due to a dependabot pull request (minor or
+## patch verson change) it will automatically merge the PR. 
+
+## Unlike many sample automerge workflows this does not rely 
+## on third-party libraries apart from the official dependabot
+## repository ones. This reduces the security risk significantly
+## (we don't want to unknowingly merge malicious code or expose 
+## secrets to a malicious third party).
+
+on: [push, pull_request]
 
 jobs:
   build:
     runs-on: ubuntu-latest
     strategy: 
      matrix:
-      java: ['8', '11'] 
+      java: ['8', '11', '17'] 
     steps:
       - uses: actions/checkout at v2
       - name: Set up JDK ${{ matrix.java }} 
@@ -21,3 +31,22 @@ jobs:
         with:
           file: ./**/target/site/jacoco/jacoco.xml
           name: codecov
+  dependabot:
+    runs-on: ubuntu-latest
+    needs: build
+    permissions:
+      pull-requests: write
+      contents: write
+    if: ${{ github.actor == 'dependabot[bot]' }}
+    steps:
+      - name: Dependabot metadata
+        id: metadata
+        uses: dependabot/fetch-metadata at v1.1.1
+        with:
+          github-token: "${{ secrets.GITHUB_TOKEN }}"
+      - name: Enable auto-merge for Dependabot PRs
+        if: ${{!contains(steps.metadata.outputs.dependency-names, 'maven-plugin-api') && (steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch')}}
+        run: gh pr merge --auto --rebase "$PR_URL"
+        env:
+          PR_URL: ${{github.event.pull_request.html_url}}
+          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}


=====================================
README.md
=====================================
@@ -26,6 +26,9 @@ Non-guava:
 * `Maps`: `hashMap`, `treeMap`, `linkedHashMap`
 ```java
 Map<Integer, String> map = Maps.put(1, "hi").put(2, "there").build();
+Map<Integer, String> sorted = Maps.treeMap().put(1, "hi").put(2, "there").build();
+Map<Integer, String> linked = Maps.linkedHashMap().put(1, "hi").put(2, "there").build();
+Map<Integer, String> presized = Maps.hashMap().initialSize(1000).put(1, "hi").put(2, "there").build();
 ```
 
 Getting started


=====================================
pom.xml
=====================================
@@ -10,7 +10,7 @@
     </parent>
 
     <artifactId>guava-mini</artifactId>
-    <version>0.1.4</version>
+    <version>0.1.7</version>
 
     <name>${project.artifactId}</name>
     <description>Classes taken from Guava</description>
@@ -24,15 +24,15 @@
         <maven.compiler.target>1.8</maven.compiler.target>
         <scm.url>scm:git:https://github.com/davidmoten/guava-mini.git</scm.url>
 
-        <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.9.1</m3.site.version>
+        <checkstyle.version>3.3.0</checkstyle.version>
+        <javadoc.version>3.6.0</javadoc.version>
+        <pmd.version>3.21.0</pmd.version>
+        <project.info.version>3.4.5</project.info.version>
+        <jxr.version>3.3.0</jxr.version>
+        <taglist.version>3.0.0</taglist.version>
+        <m3.site.version>3.12.1</m3.site.version>
         <changelog.version>2.2</changelog.version>
-        <bundle.plugin.version>5.1.1</bundle.plugin.version>
+        <bundle.plugin.version>5.1.9</bundle.plugin.version>
         <coverage.reports.dir>${project.build.directory}/target/coverage-reports</coverage.reports.dir>
 
     </properties>
@@ -74,7 +74,7 @@
         <connection>${scm.url}</connection>
         <developerConnection>${scm.url}</developerConnection>
         <url>${scm.url}</url>
-        <tag>0.1.4</tag>
+        <tag>0.1.7</tag>
     </scm>
 
     <dependencies>
@@ -90,7 +90,7 @@
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
-            <version>4.0.0</version>
+            <version>4.11.0</version>
             <scope>test</scope>
         </dependency>
 
@@ -108,7 +108,7 @@
         <plugins>
             <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.8.1</version>
+                <version>3.11.0</version>
                 <configuration>
                     <source>${maven.compiler.target}</source>
                     <target>${maven.compiler.target}</target>
@@ -138,7 +138,7 @@
             <plugin>
                 <groupId>org.jacoco</groupId>
                 <artifactId>jacoco-maven-plugin</artifactId>
-                <version>0.8.7</version>
+                <version>0.8.10</version>
                 <executions>
                     <execution>
                         <goals>


=====================================
src/main/java/com/github/davidmoten/guavamini/Lists.java
=====================================
@@ -4,13 +4,14 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.List;
 
 import com.github.davidmoten.guavamini.annotations.VisibleForTesting;
 
 public final class Lists {
 
     private Lists() {
-        // cannot instantiate
+        // prevent instantiation
     }
 
     public static <E> ArrayList<E> newArrayList(@SuppressWarnings("unchecked") E... elements) {
@@ -21,6 +22,10 @@ public final class Lists {
         Collections.addAll(list, elements);
         return list;
     }
+    
+    public static <E> List<E> of(@SuppressWarnings("unchecked") E... elements) {
+        return newArrayList(elements);
+    }
 
     @VisibleForTesting
     static int computeArrayListCapacity(int arraySize) {


=====================================
src/main/java/com/github/davidmoten/guavamini/Optional.java
=====================================
@@ -47,7 +47,7 @@ public final class Optional<T> {
     public static <T> Optional<T> absent() {
         return new Optional<T>();
     }
-
+    
     public static class NotPresentException extends RuntimeException {
 
         private static final long serialVersionUID = -4444814681271790328L;


=====================================
src/main/java/com/github/davidmoten/guavamini/Preconditions.java
=====================================
@@ -15,6 +15,17 @@ public final class Preconditions {
             throw new NullPointerException(message);
         return t;
     }
+    
+    public static <T> T checkArgumentNotNull(T t) {
+        return checkArgumentNotNull(t, "argument");
+    }
+    
+    public static <T> T checkArgumentNotNull(T t, String parameterName) {
+        if (t == null) {
+            throw new IllegalArgumentException(parameterName + " cannot be null");
+        } 
+        return t;
+    }
 
     public static void checkArgument(boolean b, String message) {
         if (!b)


=====================================
src/main/java/com/github/davidmoten/guavamini/Sets.java
=====================================
@@ -4,6 +4,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Set;
 
 import com.github.davidmoten.guavamini.annotations.VisibleForTesting;
 
@@ -15,13 +16,17 @@ public final class Sets {
 
     static final int MAX_POWER_OF_TWO = 1 << (Integer.SIZE - 2);
 
-    public static <E> HashSet<E> newHashSet(E... elements) {
+    public static <E> HashSet<E> newHashSet(@SuppressWarnings("unchecked") E... elements) {
         Preconditions.checkNotNull(elements);
         HashSet<E> set = newHashSetWithExpectedSize(elements.length);
         Collections.addAll(set, elements);
         return set;
     }
-
+    
+    public static <E> Set<E> of(@SuppressWarnings("unchecked") E... elements) {
+        return newHashSet(elements);
+    }
+    
     public static <E> HashSet<E> newHashSetWithExpectedSize(int expectedSize) {
         return new HashSet<E>(capacity(expectedSize));
     }


=====================================
src/test/java/com/github/davidmoten/guavamini/ListsTest.java
=====================================
@@ -19,6 +19,11 @@ public class ListsTest {
         list.add(2);
         assertEquals(list, Lists.newArrayList(1, 2));
     }
+    
+    @Test
+    public void testOf() {
+        assertEquals(Lists.newArrayList(1, 2), Lists.of(1, 2));
+    }
 
     @Test
     public void createListFromIterable() {


=====================================
src/test/java/com/github/davidmoten/guavamini/PreconditionsTest.java
=====================================
@@ -2,6 +2,7 @@ package com.github.davidmoten.guavamini;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -19,7 +20,7 @@ public class PreconditionsTest {
     public void testNotNullDoesNotThrowException() {
         Preconditions.checkNotNull(new Object());
     }
-    
+
     @Test
     public void testNotNullReturnsTypedObject() {
         Integer n = 1;
@@ -62,4 +63,20 @@ public class PreconditionsTest {
         Asserts.assertIsUtilityClass(Preconditions.class);
     }
 
+    @Test
+    public void testCheckArgumentNotNullThrowsIAE() {
+        try {
+            Preconditions.checkArgumentNotNull(null);
+            Assert.fail();
+        } catch (IllegalArgumentException e) {
+            assertEquals("argument cannot be null", e.getMessage());
+        }
+    }
+
+    @Test
+    public void testCheckArgumentNotNullReturnsWhenNotNull() {
+        Object o = new Object();
+        assertTrue(o == Preconditions.checkArgumentNotNull(o));
+    }
+
 }


=====================================
src/test/java/com/github/davidmoten/guavamini/SetsTest.java
=====================================
@@ -15,6 +15,11 @@ public class SetsTest {
     public void testCreate() {
         assertTrue(Sets.newHashSet(1, 2, 3).contains(2));
     }
+    
+    @Test
+    public void testCreateUsingOf() {
+        assertTrue(Sets.of(1, 2, 3).contains(2));
+    }
 
     @Test
     public void testCreateFromIterator() {



View it on GitLab: https://salsa.debian.org/java-team/guava-mini/-/commit/a52bc60c98c56588cff3d88db31f636946382478

-- 
View it on GitLab: https://salsa.debian.org/java-team/guava-mini/-/commit/a52bc60c98c56588cff3d88db31f636946382478
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/20250406/46b09d1d/attachment.htm>


More information about the pkg-java-commits mailing list