Skip to content

Commit 6c6b927

Browse files
committed
Fixed some file naming
1 parent 471c712 commit 6c6b927

18 files changed

Lines changed: 449 additions & 736 deletions

File tree

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ repositories {
2020
mavenCentral()
2121
}
2222

23+
java {
24+
sourceCompatibility = JavaVersion.VERSION_1_8
25+
targetCompatibility = JavaVersion.VERSION_1_8
26+
}
27+
2328
dependencies {
2429
githubImplementation "intisy:simple-logger:2.1.5"
2530
implementation "org.apache.httpcomponents:httpclient:4.5.14"

gradle/wrapper/gradle-wrapper.jar

0 Bytes
Binary file not shown.

gradlew

0 Bytes
Binary file not shown.

src/main/java/io/github/intisy/utils/collections/DoubleHashMap.java

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,62 +17,61 @@
1717

1818
@SuppressWarnings("unused")
1919
public class DoubleHashMap<K, V1, V2> extends HashMap<K, Doublet<V1, V2>> {
20-
/**
21-
* Associates the specified key with the specified values in this map.
22-
* If the map previously contained a mapping for the key, the old value is replaced.
23-
*
24-
* @param key the key with which the specified values are to be associated
25-
* @param value1 the first value to be associated with the specified key
26-
* @param value2 the second value to be associated with the specified key
27-
*/
28-
public void put(K key, V1 value1, V2 value2) {
29-
super.put(key, new Doublet<>(value1, value2));
30-
}
20+
/**
21+
* Associates the specified key with the specified values in this map.
22+
* If the map previously contained a mapping for the key, the old value is replaced.
23+
*
24+
* @param key the key with which the specified values are to be associated
25+
* @param value1 the first value to be associated with the specified key
26+
* @param value2 the second value to be associated with the specified key
27+
*/
28+
public void put(K key, V1 value1, V2 value2) {
29+
super.put(key, new Doublet<>(value1, value2));
30+
}
3131

32-
/**
33-
* Returns the first value to which the specified key is mapped,
34-
* or null if this map contains no mapping for the key.
35-
*
36-
* @param key the key whose associated first value is to be returned
37-
* @return the first value to which the specified key is mapped, or
38-
* null if this map contains no mapping for the key
39-
* @throws NullPointerException if the mapping for the key is null
40-
*/
41-
public V1 getValue1(K key) {
42-
return get(key).getKey();
43-
}
32+
/**
33+
* Returns the first value to which the specified key is mapped,
34+
* or null if this map contains no mapping for the key.
35+
*
36+
* @param key the key whose associated first value is to be returned
37+
* @return the first value to which the specified key is mapped, or
38+
* null if this map contains no mapping for the key
39+
* @throws NullPointerException if the mapping for the key is null
40+
*/
41+
public V1 getValue1(K key) {
42+
return get(key).getKey();
43+
}
4444

45-
/**
46-
* Returns the second value to which the specified key is mapped,
47-
* or null if this map contains no mapping for the key.
48-
*
49-
* @param key the key whose associated second value is to be returned
50-
* @return the second value to which the specified key is mapped, or
51-
* null if this map contains no mapping for the key
52-
* @throws NullPointerException if the mapping for the key is null
53-
*/
54-
public V2 getValue2(K key) {
55-
return get(key).getValue();
56-
}
45+
/**
46+
* Returns the second value to which the specified key is mapped,
47+
* or null if this map contains no mapping for the key.
48+
*
49+
* @param key the key whose associated second value is to be returned
50+
* @return the second value to which the specified key is mapped, or
51+
* null if this map contains no mapping for the key
52+
* @throws NullPointerException if the mapping for the key is null
53+
*/
54+
public V2 getValue2(K key) {
55+
return get(key).getValue();
56+
}
5757

58-
/**
59-
* Returns a collection view of the first values contained in this map.
60-
* The collection is backed by the map, so changes to the map are reflected in the collection.
61-
*
62-
* @return a collection view of the first values contained in this map
63-
*/
64-
public Collection<V1> values1() {
65-
return values().stream().map(Doublet::getKey).collect(Collectors.toList());
66-
}
58+
/**
59+
* Returns a collection view of the first values contained in this map.
60+
* The collection is backed by the map, so changes to the map are reflected in the collection.
61+
*
62+
* @return a collection view of the first values contained in this map
63+
*/
64+
public Collection<V1> values1() {
65+
return values().stream().map(Doublet::getKey).collect(Collectors.toList());
66+
}
6767

68-
/**
69-
* Returns a collection view of the second values contained in this map.
70-
* The collection is backed by the map, so changes to the map are reflected in the collection.
71-
*
72-
* @return a collection view of the second values contained in this map
73-
*/
74-
public Collection<V2> values2() {
75-
return values().stream().map(Doublet::getValue).collect(Collectors.toList());
76-
}
68+
/**
69+
* Returns a collection view of the second values contained in this map.
70+
* The collection is backed by the map, so changes to the map are reflected in the collection.
71+
*
72+
* @return a collection view of the second values contained in this map
73+
*/
74+
public Collection<V2> values2() {
75+
return values().stream().map(Doublet::getValue).collect(Collectors.toList());
76+
}
7777
}
78-
Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
package io.github.intisy.utils.concurrency;
2-
3-
import java.util.concurrent.locks.Condition;
4-
import java.util.concurrent.locks.Lock;
5-
import java.util.concurrent.locks.ReentrantLock;
6-
7-
/**
8-
* A utility class for thread synchronization based on a boolean condition.
9-
* This class provides a mechanism for threads to wait until a boolean variable
10-
* reaches a specific value, using a lock and condition variable for thread safety.
11-
*
12-
* @author Finn Birich
13-
*/
14-
@SuppressWarnings("unused")
15-
public class Wait {
16-
private final Lock lock = new ReentrantLock();
17-
private final Condition condition = lock.newCondition();
18-
private boolean variable = false;
19-
20-
/**
21-
* Causes the current thread to wait until the internal boolean variable
22-
* equals the specified value. This method will block until the condition is met
23-
* or the thread is interrupted.
24-
*
25-
* @param variable the boolean value to wait for
26-
* @throws InterruptedException if the current thread is interrupted while waiting
27-
*/
28-
public void waitForVariable(boolean variable) throws InterruptedException {
29-
lock.lock();
30-
try {
31-
while (this.variable != variable) {
32-
condition.await();
33-
}
34-
} finally {
35-
lock.unlock();
36-
}
37-
}
38-
39-
/**
40-
* Sets the internal boolean variable to the specified value and
41-
* notifies all waiting threads that the variable has changed.
42-
*
43-
* @param value the new value to set
44-
*/
45-
public void setVariable(boolean value) {
46-
lock.lock();
47-
try {
48-
variable = value;
49-
condition.signalAll();
50-
} finally {
51-
lock.unlock();
52-
}
53-
}
54-
55-
/**
56-
* Returns the current value of the internal boolean variable.
57-
*
58-
* @return the current value of the variable
59-
*/
60-
public boolean getVariable() {
61-
return variable;
62-
}
1+
package io.github.intisy.utils.concurrency;
2+
3+
import java.util.concurrent.locks.Condition;
4+
import java.util.concurrent.locks.Lock;
5+
import java.util.concurrent.locks.ReentrantLock;
6+
7+
/**
8+
* A utility class for thread synchronization based on a boolean condition.
9+
* This class provides a mechanism for threads to wait until a boolean variable
10+
* reaches a specific value, using a lock and condition variable for thread safety.
11+
*
12+
* @author Finn Birich
13+
*/
14+
@SuppressWarnings("unused")
15+
public class Wait {
16+
private final Lock lock = new ReentrantLock();
17+
private final Condition condition = lock.newCondition();
18+
private boolean variable = false;
19+
20+
/**
21+
* Causes the current thread to wait until the internal boolean variable
22+
* equals the specified value. This method will block until the condition is met
23+
* or the thread is interrupted.
24+
*
25+
* @param variable the boolean value to wait for
26+
* @throws InterruptedException if the current thread is interrupted while waiting
27+
*/
28+
public void waitForVariable(boolean variable) throws InterruptedException {
29+
lock.lock();
30+
try {
31+
while (this.variable != variable) {
32+
condition.await();
33+
}
34+
} finally {
35+
lock.unlock();
36+
}
37+
}
38+
39+
/**
40+
* Sets the internal boolean variable to the specified value and
41+
* notifies all waiting threads that the variable has changed.
42+
*
43+
* @param value the new value to set
44+
*/
45+
public void setVariable(boolean value) {
46+
lock.lock();
47+
try {
48+
variable = value;
49+
condition.signalAll();
50+
} finally {
51+
lock.unlock();
52+
}
53+
}
54+
55+
/**
56+
* Returns the current value of the internal boolean variable.
57+
*
58+
* @return the current value of the variable
59+
*/
60+
public boolean getVariable() {
61+
return variable;
62+
}
6363
}

0 commit comments

Comments
 (0)