Skip to content

Commit 611e0d3

Browse files
committed
Updated to 1.5.0 PRE-RELEASE
Updated JDK to Java 10 Login Dialogs now don't require the use of Platform.runLater() Message Boxes now don't require the use of Platform.runLater() Message Box Default button is now in the right order. Massive changes to authentication and permissions system Renamed jbdc to jdbc Removed all deprecated methods from 1.4.0 Updated javadoc Replaced some loops with streams Added trim to all string isEmpty checks Added UTF_8 protection Added ExceptionUtils class for use in junit tests All password hashing now uses BCrypt replacing SHA-512 Other minor fixes Signed-off-by: Joshua Gager <[email protected]>
1 parent d6a5cb0 commit 611e0d3

File tree

249 files changed

+26436
-11301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+26436
-11301
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# JavaUltimateTools v1.4.2 [![Build Status](https://travis-ci.org/JGCompTech/JavaUltimateTools.svg?branch=master)](https://travis-ci.org/JGCompTech/JavaUltimateTools) [![Dependency Status](https://www.versioneye.com/user/projects/58e2fbb124ef3e003b526de5/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/58e2fbb124ef3e003b526de5) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.jgcomptech.tools/java-ultimate-tools/badge.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/com.jgcomptech.tools/java-ultimate-tools/) [![Javadocs](http://www.javadoc.io/badge/com.jgcomptech.tools/java-ultimate-tools.svg?style=flat-square)](http://www.javadoc.io/doc/com.jgcomptech.tools/java-ultimate-tools)
1+
# JavaUltimateTools v1.4.2 [![Build Status](https://travis-ci.org/JGCompTech/JavaUltimateTools.svg?branch=master)](https://travis-ci.org/JGCompTech/JavaUltimateTools) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.jgcomptech.tools/java-ultimate-tools/badge.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/com.jgcomptech.tools/java-ultimate-tools/) [![Javadocs](http://www.javadoc.io/badge/com.jgcomptech.tools/java-ultimate-tools.svg?style=flat-square)](http://www.javadoc.io/doc/com.jgcomptech.tools/java-ultimate-tools)
22

33
Java Ultimate Tools is a large repository of scripts for use in any Java program. It contains the following:
44
- OSInfo - Contains many classes that return information about the current Windows installation. This includes Architecture, Edition, Name, Product Key, Service Pack, User Info and Version.

docs/overview.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<body>
2-
<h3>JavaUltimateTools v1.4.2</h3><hr/>
2+
<h3>JavaUltimateTools v1.4.2</h3><hr>
33
<a href="https://travis-ci.org/JGCompTech/JavaUltimateTools">
44
<img src="https://travis-ci.org/JGCompTech/JavaUltimateTools.svg?branch=master" alt="Build Status" style="max-width:100%;">
55
</a>
@@ -31,27 +31,27 @@ <h3>JavaUltimateTools v1.4.2</h3><hr/>
3131
<p>If you would like a more details, check out the <a href="https://github.com/JGCompTech/JavaUltimateTools/blob/master/CLASSDESCRIPTION.md">CLASSDESCRIPTION.md</a> file.</p>
3232
<p>If you would like to view the JavaDoc info, it is hosted at <a href="https://jgcomptech.github.io/JavaUltimateTools/">github.io(Current GitHub Branch)</a> and at <a href="http://www.javadoc.io/doc/com.jgcomptech.tools/java-ultimate-tools">javadoc.io(Current Maven Release)</a>. The github.io version is what is stored in the doc folder in the project.</p>
3333

34-
<h3>Development</h3><hr/>
34+
<h3>Development</h3><hr>
3535
<p>Want to contribute? Great!
3636
Any help with development is greatly appreciated. If you want to add something or fix any issues please submit a pull request and if it is helpful it may be merged. Please check out our <a href="https://github.com/JGCompTech/JavaUltimateTools/blob/master/code-of-conduct.md">Code of Conduct for Contributors</a>.</p>
3737

38-
<h3>Download</h3><hr/>
38+
<h3>Download</h3><hr>
3939
<p><strong><a href="https://github.com/JGCompTech/JavaUltimateTools/releases/tag/v1.4.2">Download v1.4.2</a></strong></p>
4040
<p>The changelog can be found <a href="https://github.com/JGCompTech/JavaUltimateTools/blob/master/Changelog.txt">here</a></p>
4141

42-
<h3>Using with Maven</h3><hr/>
42+
<h3>Using with Maven</h3><hr>
4343
<p>If you are familiar with <a href="http://maven.apache.org">Maven</a>, add the following XML
4444
fragments into your pom.xml file. With those settings, your Maven will automatically download our library into your local Maven repository, since our libraries are synchronized with the <a href="http://repo1.maven.org/maven2/com/jgcomptech/tools/java-ultimate-tools/">Maven central repository</a>.</p>
45-
<pre><code>&lt;dependencies&gt;&#x000D;
46-
&emsp;&lt;dependency&gt;&#x000D;
47-
&emsp;&emsp;&lt;groupId&gt;com.jgcomptech.tools&lt;/groupId&gt;&#x000D;
48-
&emsp;&emsp;&lt;artifactId&gt;java-ultimate-tools&lt;/artifactId&gt;&#x000D;
49-
&emsp;&emsp;&lt;version&gt;1.4.2&lt;/version&gt;&#x000D;
50-
&emsp;&lt;/dependency&gt;&#x000D;
51-
&lt;/dependencies&gt;&#x000D;
45+
<pre><code>&lt;dependencies&gt;
46+
&emsp;&lt;dependency&gt;
47+
&emsp;&emsp;&lt;groupId&gt;com.jgcomptech.tools&lt;/groupId&gt;
48+
&emsp;&emsp;&lt;artifactId&gt;java-ultimate-tools&lt;/artifactId&gt;
49+
&emsp;&emsp;&lt;version&gt;1.4.2&lt;/version&gt;
50+
&emsp;&lt;/dependency&gt;
51+
&lt;/dependencies&gt;
5252
</code></pre>
5353

54-
<h3>License</h3><hr/>
54+
<h3>License</h3><hr>
5555
<p><a href="http://creativecommons.org/licenses/by/4.0/"><img src="https://i.creativecommons.org/l/by/4.0/88x31.png" alt="Creative Commons License" style="max-width:100%;"></a></p>
5656
<p>JavaUltimateTools by J&amp;G CompTech is licensed under a <a href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</p>
5757
</body>

pom.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.jgcomptech.tools</groupId>
88
<artifactId>java-ultimate-tools</artifactId>
9-
<version>1.4.2</version>
9+
<version>1.5.0</version>
1010
<packaging>jar</packaging>
1111

1212
<properties>
@@ -164,6 +164,7 @@
164164
<useStandardDocletOptions>true</useStandardDocletOptions>
165165
<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
166166
<overview>${basedir}//src/main/javadoc/overview.html</overview>
167+
<additionalOptions>-html5</additionalOptions>
167168
</configuration>
168169
</plugin>
169170
<plugin>
@@ -292,8 +293,8 @@
292293
<artifactId>maven-compiler-plugin</artifactId>
293294
<version>3.7.0</version>
294295
<configuration>
295-
<source>1.8</source>
296-
<target>1.8</target>
296+
<source>10</source>
297+
<target>10</target>
297298
</configuration>
298299
</plugin>
299300
</plugins>
@@ -369,5 +370,11 @@
369370
<artifactId>annotations</artifactId>
370371
<version>RELEASE</version>
371372
</dependency>
373+
<!-- https://mvnrepository.com/artifact/org.mindrot/jbcrypt -->
374+
<dependency>
375+
<groupId>org.mindrot</groupId>
376+
<artifactId>jbcrypt</artifactId>
377+
<version>0.4</version>
378+
</dependency>
372379
</dependencies>
373380
</project>

src/main/java/com/jgcomptech/tools/CollectionUtils.java

Lines changed: 81 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.jgcomptech.tools;
22

3-
import java.util.HashMap;
4-
import java.util.HashSet;
3+
import org.jetbrains.annotations.NotNull;
4+
5+
import java.util.Collection;
56
import java.util.Map;
67
import java.util.Optional;
8+
import java.util.Set;
79
import java.util.function.Predicate;
10+
import java.util.stream.Collectors;
11+
import java.util.stream.Stream;
812

913
/**
1014
* Contains methods for dealing with collections.
@@ -16,18 +20,19 @@ public final class CollectionUtils {
1620
* A "{@literal =}" separates the keys and values and a "{@literal &}" separates the key pairs.
1721
* @param stringMap map to convert
1822
* @return string representation of map
23+
* @throws IllegalArgumentException if StringMap is null
1924
*/
2025
public static String convertMapToString(final Map<String, String> stringMap) {
21-
final StringBuilder sb = new StringBuilder();
22-
final char keySeparator = '=';
23-
final char pairSeparator = '&';
24-
for(final Map.Entry<String, String> pair:stringMap.entrySet())
25-
{
26-
sb.append(pair.getKey());
26+
if(stringMap == null) throw new IllegalArgumentException("String Map cannot be null!");
27+
final var sb = new StringBuilder();
28+
final var keySeparator = '=';
29+
final var pairSeparator = '&';
30+
stringMap.forEach((key, value) -> {
31+
sb.append(key);
2732
sb.append(keySeparator);
28-
sb.append(pair.getValue());
33+
sb.append(value);
2934
sb.append(pairSeparator);
30-
}
35+
});
3136
return sb.toString().substring(0, sb.length() - 1);
3237
}
3338

@@ -36,108 +41,113 @@ public static String convertMapToString(final Map<String, String> stringMap) {
3641
* <p>Expects that "{@literal =}" separates the keys and values and a "{@literal &}" separates the key pairs.</p>
3742
* @param value map to convert
3843
* @return string representation of map
44+
* @throws IllegalArgumentException if Value is null
45+
* @since 1.5.0 now uses a stream to process the pairs
3946
*/
4047
public static Map<String, String> convertStringToMap(final String value) {
41-
final Map<String, String> myMap = new HashMap<>();
42-
final String keySeparator = "=";
43-
final String pairSeparator = "&";
44-
final String[] pairs = value.split(pairSeparator);
45-
for(final String pair : pairs) {
46-
final String[] keyValue = pair.split(keySeparator);
47-
myMap.put(keyValue[0], keyValue[1]);
48-
}
48+
if(value == null) throw new IllegalArgumentException("Value cannot be null!");
49+
final Map<String, String> myMap;
50+
final var keySeparator = "=";
51+
final var pairSeparator = "&";
52+
final var pairs = value.split(pairSeparator);
53+
myMap = Stream.of(pairs)
54+
.map(p -> p.split(keySeparator))
55+
.collect(Collectors.toMap(keyValue -> keyValue[0], keyValue -> keyValue[1], (a, b) -> b));
4956
return myMap;
5057
}
5158

5259
/**
53-
* Checks if an item userExists in a HashSet that matches the specified Predicate.
54-
* @param set the HashSet to check against
60+
* Checks if an item exists in a Collection that matches the specified Predicate.
61+
* @param collection the Collection to check against
5562
* @param condition the Predicate to check
5663
* @param <T> the type of objects in the HashSet
5764
* @return true if condition is true
58-
* @throws IllegalArgumentException if HashSet or Predicate is null
65+
* @throws IllegalArgumentException if Collection or Predicate is null
66+
* @since 1.5.0 now uses a java Parallel Stream to allow for a large list of values
5967
*/
60-
public static <T> boolean doesItemExistInHashSet(final HashSet<T> set, final Predicate<T> condition) {
61-
if(set == null) throw new IllegalArgumentException("HashSet cannot be null!");
68+
public static <T> boolean doesItemExistInCollection(final Collection<T> collection, final Predicate<T> condition) {
69+
if(collection == null) throw new IllegalArgumentException("Collection cannot be null!");
6270
if(condition == null) throw new IllegalArgumentException("Predicate cannot be null!");
63-
for(final T object : set) if (condition.test(object)) return true;
64-
return false;
71+
return collection.parallelStream().anyMatch(condition);
6572
}
6673

6774
/**
68-
* Checks if a value userExists in a HashMap that matches the specified Predicate.
69-
* @param map the HashMap to check against
75+
* Checks if a value exists in a HashMap that matches the specified Predicate.
76+
* @param map the Map to check against
7077
* @param condition the Predicate to check
71-
* @param <K> the type of the Key in the HashMap
72-
* @param <V> the type of the Value in the HashMap
78+
* @param <K> the type of the Key in the Map
79+
* @param <V> the type of the Value in the Map
7380
* @return true if condition is true
7481
* @throws IllegalArgumentException if HashMap or Predicate is null
82+
* @since 1.5.0 now uses a java Parallel Stream to allow for a large list of values
7583
*/
76-
public static <K, V> boolean doesItemExistInHashMap(final HashMap<K, V> map, final Predicate<V> condition) {
77-
if(map == null) throw new IllegalArgumentException("HashMap cannot be null!");
84+
public static <K, V> boolean doesItemExistInMap(final Map<K, V> map, final Predicate<V> condition) {
85+
if(map == null) throw new IllegalArgumentException("Map cannot be null!");
7886
if(condition == null) throw new IllegalArgumentException("Predicate cannot be null!");
79-
for(final Map.Entry<K, V> entry : map.entrySet()) if (condition.test(entry.getValue())) return true;
80-
return false;
87+
return map.values().parallelStream().anyMatch(condition);
8188
}
8289

8390
/**
84-
* Returns item in HashSet that matches the specified Predicate.
85-
* @param set the HashSet to check against
91+
* Returns the first item in a HashSet that matches the specified Predicate.
92+
* @param collection the Collection to check against
8693
* @param condition the Predicate to check
87-
* @param <T> the type of objects in the HashSet
94+
* @param <T> the type of objects in the Collection
8895
* @return an Optional containing the matching object, Empty if not found
89-
* @throws IllegalArgumentException if HashSet or Predicate is null
96+
* @throws IllegalArgumentException if Collection or Predicate is null
97+
* @since 1.5.0 now uses a java Parallel Stream to allow for a large list of values
9098
*/
91-
public static <T> Optional<T> getItemInHashSet(final HashSet<T> set, final Predicate<T> condition) {
92-
if(set == null) throw new IllegalArgumentException("HashSet cannot be null!");
99+
public static <T> Optional<T> getItemInCollection(final Collection<T> collection, final Predicate<T> condition) {
100+
if(collection == null) throw new IllegalArgumentException("Collection cannot be null!");
93101
if(condition == null) throw new IllegalArgumentException("Predicate cannot be null!");
94-
for(final T object : set) if (condition.test(object)) return Optional.of(object);
95-
return Optional.empty();
102+
return collection.parallelStream().filter(condition).findFirst();
96103
}
97104

98105
/**
99-
* Returns a HashSet of values in a HashMap that match the specified Predicate.
100-
* @param map the HashMap to check against
101-
* @param condition the Predicate to check
102-
* @param <K> the type of the Key in the HashMap
103-
* @param <V> the type of the Value in the HashMap
104-
* @return a HashSet of values matching the predicate, empty HashSet if no results found
105-
* @throws IllegalArgumentException if HashMap or Predicate is null
106+
* Returns the items in a Collection that matches the specified Predicate.
107+
* @param collection the Collection to check against
108+
* @param condition the Predicate to evaluate
109+
* @param <T> the Object type that is stored in the Collection
110+
* @return a HashSet of items that match match the Predicate
111+
* @since 1.5.0 now uses a java Parallel Stream to allow for a large list of values
106112
*/
107-
public static <K, V> HashSet<V> getValuesInHashMap(final HashMap<K, V> map, final Predicate<V> condition) {
108-
final HashSet<V> matchingValues = new HashSet<>();
113+
@NotNull
114+
public static <T> Set<T> getItemsInCollection(final Collection<T> collection,
115+
final Predicate<T> condition) {
116+
if(collection == null) throw new IllegalArgumentException("Collection cannot be null!");
117+
if(condition == null) throw new IllegalArgumentException("Predicate cannot be null!");
118+
return collection.parallelStream().filter(condition).collect(Collectors.toSet());
119+
}
109120

121+
/**
122+
* Returns a Set of values in a Map that match the specified Predicate.
123+
* @param map the Map to check against
124+
* @param condition the Predicate to check
125+
* @param <K> the type of the Key in the Map
126+
* @param <V> the type of the Value in the Map
127+
* @return a Set of values matching the predicate, an empty Set if no results found
128+
* @throws IllegalArgumentException if Map or Predicate is null
129+
* @since 1.5.0 now uses a java Parallel Stream to allow for a large list of values
130+
*/
131+
public static <K, V> Set<V> getValuesInMap(final Map<K, V> map, final Predicate<V> condition) {
110132
if(map == null) throw new IllegalArgumentException("HashMap cannot be null!");
111133
if(condition == null) throw new IllegalArgumentException("Predicate cannot be null!");
112-
113-
map.forEach((key, value) -> { if(condition.test(value)) matchingValues.add(value); });
114-
115-
return matchingValues;
134+
return map.values().parallelStream().filter(condition).collect(Collectors.toSet());
116135
}
117136

118137
/**
119-
* Returns the first item found in a HashMap that matches the specified Predicate.
120-
* @param map the HashMap to check against
138+
* Returns the first item found in a Map that matches the specified Predicate.
139+
* @param map the Map to check against
121140
* @param condition the Predicate to check
122-
* @param <K> the type of the Key in the HashMap
123-
* @param <V> the type of the Value in the HashMap
141+
* @param <K> the type of the Key in the Map
142+
* @param <V> the type of the Value in the Map
124143
* @return an Optional containing the matching value, Empty if no results found
125-
* @throws IllegalArgumentException if HashMap or Predicate is null
144+
* @throws IllegalArgumentException if Map or Predicate is null
145+
* @since 1.5.0 now uses a java Parallel Stream to allow for a large list of values
126146
*/
127-
public static <K, V> Optional<V> getValueInHashMap(final HashMap<K, V> map, final Predicate<V> condition) {
128-
V matchingValue = null;
129-
147+
public static <K, V> Optional<V> getValueInMap(final Map<K, V> map, final Predicate<V> condition) {
130148
if(map == null) throw new IllegalArgumentException("HashMap cannot be null!");
131149
if(condition == null) throw new IllegalArgumentException("Predicate cannot be null!");
132-
133-
for(final Map.Entry<K, V> entry : map.entrySet()) {
134-
if(condition.test(entry.getValue())) {
135-
matchingValue = entry.getValue();
136-
break;
137-
}
138-
}
139-
140-
return matchingValue == null ? Optional.empty() : Optional.of(matchingValue);
150+
return map.values().parallelStream().filter(condition).findFirst();
141151
}
142152

143153
/** Prevents instantiation of this utility class. */

0 commit comments

Comments
 (0)