-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Observability extension - devservices, devresources, LGTM
Grafana OTel LGTM additional Documentation Fix enforcer configuration and make names consistent Update descriptors with latest dependency state Abstract Testcontainers usage, own Container SPI.
- Loading branch information
Showing
61 changed files
with
2,622 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
core/runtime/src/main/java/io/quarkus/runtime/util/EnumerationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.quarkus.runtime.util; | ||
|
||
import java.util.Enumeration; | ||
import java.util.Iterator; | ||
import java.util.NoSuchElementException; | ||
import java.util.Objects; | ||
import java.util.Spliterator; | ||
import java.util.function.Consumer; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* Transform to "old school" Enumeration from Iterator/Spliterator/Stream | ||
*/ | ||
public class EnumerationUtil { | ||
public static <T> Enumeration<T> from(Iterator<T> iterator) { | ||
Objects.requireNonNull(iterator); | ||
|
||
return new Enumeration<T>() { | ||
@Override | ||
public boolean hasMoreElements() { | ||
return iterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public T nextElement() { | ||
return iterator.next(); | ||
} | ||
}; | ||
} | ||
|
||
public static <T> Enumeration<T> from(Spliterator<T> spliterator) { | ||
Objects.requireNonNull(spliterator); | ||
|
||
class Adapter implements Enumeration<T>, Consumer<T> { | ||
boolean valueReady; | ||
T nextElement; | ||
|
||
public void accept(T t) { | ||
this.valueReady = true; | ||
this.nextElement = t; | ||
} | ||
|
||
public boolean hasMoreElements() { | ||
if (!this.valueReady) { | ||
spliterator.tryAdvance(this); | ||
} | ||
|
||
return this.valueReady; | ||
} | ||
|
||
public T nextElement() { | ||
if (!this.valueReady && !this.hasMoreElements()) { | ||
throw new NoSuchElementException(); | ||
} else { | ||
this.valueReady = false; | ||
T t = this.nextElement; | ||
this.nextElement = null; | ||
return t; | ||
} | ||
} | ||
} | ||
|
||
return new Adapter(); | ||
} | ||
|
||
public static <T> Enumeration<T> from(Stream<T> stream) { | ||
return from(stream.spliterator()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.