|
15 | 15 | import java.util.Map; |
16 | 16 | import java.util.Set; |
17 | 17 | import java.util.TreeSet; |
18 | | -import java.util.function.Function; |
19 | 18 |
|
20 | 19 | import org.bouncycastle.bcpg.ArmoredOutputStream; |
21 | 20 | import org.bouncycastle.bcpg.BCPGInputStream; |
@@ -3034,41 +3033,56 @@ public boolean isHardRevocation() |
3034 | 3033 | */ |
3035 | 3034 | public Date getSince() |
3036 | 3035 | { |
3037 | | - // Find most recent chain link |
3038 | | -// return chainLinks.stream() |
3039 | | -// .map(it -> it.signature) |
3040 | | -// .max(Comparator.comparing(OpenPGPComponentSignature::getCreationTime)) |
3041 | | -// .map(OpenPGPComponentSignature::getCreationTime) |
3042 | | -// .orElse(null); |
3043 | | - return chainLinks.stream() |
3044 | | - .map(new Function<Link, Object>() |
3045 | | - { |
3046 | | - @Override |
3047 | | - public OpenPGPComponentSignature apply(Link it) |
3048 | | - { |
3049 | | - return it.signature; // Replace lambda: `it -> it.signature` |
3050 | | - } |
3051 | | - |
3052 | | - }) |
3053 | | - .max(new Comparator<Object>() |
3054 | | - { |
3055 | | - @Override |
3056 | | - public int compare(Object o1, Object o2) |
3057 | | - { |
3058 | | - // Replace method reference: `Comparator.comparing(OpenPGPComponentSignature::getCreationTime)` |
3059 | | - return ((OpenPGPComponentSignature)o1).getCreationTime().compareTo(((OpenPGPComponentSignature)o2).getCreationTime()); |
3060 | | - } |
3061 | | - }) |
3062 | | - .map(new Function<Object, Date>() |
| 3036 | + Date latestDate = null; |
| 3037 | + for (Iterator it = chainLinks.iterator(); it.hasNext(); ) |
| 3038 | + { |
| 3039 | + Link link = (Link)it.next(); |
| 3040 | + OpenPGPComponentSignature signature = link.getSignature(); |
| 3041 | + Date currentDate = signature.getCreationTime(); |
| 3042 | + if (latestDate == null || currentDate.after(latestDate)) |
3063 | 3043 | { |
3064 | | - @Override |
3065 | | - public Date apply(Object sig) |
3066 | | - { |
3067 | | - return ((OpenPGPComponentSignature)sig).getCreationTime(); // Replace method reference: `OpenPGPComponentSignature::getCreationTime` |
3068 | | - } |
3069 | | - }) |
3070 | | - .orElse(null); |
| 3044 | + latestDate = currentDate; |
| 3045 | + } |
| 3046 | + } |
| 3047 | + return latestDate; |
3071 | 3048 | } |
| 3049 | +// public Date getSince() |
| 3050 | +// { |
| 3051 | +// // Find most recent chain link |
| 3052 | +//// return chainLinks.stream() |
| 3053 | +//// .map(it -> it.signature) |
| 3054 | +//// .max(Comparator.comparing(OpenPGPComponentSignature::getCreationTime)) |
| 3055 | +//// .map(OpenPGPComponentSignature::getCreationTime) |
| 3056 | +//// .orElse(null); |
| 3057 | +// return chainLinks.stream() |
| 3058 | +// .map(new Function<Link, Object>() |
| 3059 | +// { |
| 3060 | +// @Override |
| 3061 | +// public OpenPGPComponentSignature apply(Link it) |
| 3062 | +// { |
| 3063 | +// return it.signature; // Replace lambda: `it -> it.signature` |
| 3064 | +// } |
| 3065 | +// |
| 3066 | +// }) |
| 3067 | +// .max(new Comparator<Object>() |
| 3068 | +// { |
| 3069 | +// @Override |
| 3070 | +// public int compare(Object o1, Object o2) |
| 3071 | +// { |
| 3072 | +// // Replace method reference: `Comparator.comparing(OpenPGPComponentSignature::getCreationTime)` |
| 3073 | +// return ((OpenPGPComponentSignature)o1).getCreationTime().compareTo(((OpenPGPComponentSignature)o2).getCreationTime()); |
| 3074 | +// } |
| 3075 | +// }) |
| 3076 | +// .map(new Function<Object, Date>() |
| 3077 | +// { |
| 3078 | +// @Override |
| 3079 | +// public Date apply(Object sig) |
| 3080 | +// { |
| 3081 | +// return ((OpenPGPComponentSignature)sig).getCreationTime(); // Replace method reference: `OpenPGPComponentSignature::getCreationTime` |
| 3082 | +// } |
| 3083 | +// }) |
| 3084 | +// .orElse(null); |
| 3085 | +// } |
3072 | 3086 |
|
3073 | 3087 | /** |
3074 | 3088 | * Return the date until which the chain link is valid. |
|
0 commit comments