Skip to content

Commit

Permalink
calculate javadoc links dynamically.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbien committed Mar 23, 2023
1 parent 150be19 commit 0ec0a98
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.time.LocalDate;
import java.time.Month;
import java.time.Period;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -57,19 +60,19 @@ public final class J2SEPlatformDefaultJavadocImpl implements J2SEPlatformDefault
OFFICIAL_JAVADOC.put("1.6", "https://docs.oracle.com/javase/6/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("1.7", "https://docs.oracle.com/javase/7/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("1.8", "https://docs.oracle.com/javase/8/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("9", "https://docs.oracle.com/javase/9/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("10", "https://docs.oracle.com/javase/10/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("11", "https://docs.oracle.com/en/java/javase/11/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("12", "https://docs.oracle.com/en/java/javase/12/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("13", "https://docs.oracle.com/en/java/javase/13/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("14", "https://docs.oracle.com/en/java/javase/14/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("15", "https://docs.oracle.com/en/java/javase/15/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("16", "https://docs.oracle.com/en/java/javase/16/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("17", "https://docs.oracle.com/en/java/javase/17/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("18", "https://docs.oracle.com/en/java/javase/18/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("19", "https://docs.oracle.com/en/java/javase/19/docs/api/"); // NOI18N
OFFICIAL_JAVADOC.put("20", "https://download.java.net/java/early_access/jdk20/docs/api/"); // NOI18N Early access
OFFICIAL_JAVADOC.put("21", "https://download.java.net/java/early_access/jdk21/docs/api/"); // NOI18N Early access

// timezone shouldn't matter since the accuracy is worse than a day
LocalDate jdk9 = LocalDate.of(2017, Month.SEPTEMBER, 21); // start of 6 month schedule
LocalDate now = LocalDate.now();

if (now.isAfter(jdk9)) { // time traveler -> only java 8 doc for you
int[] jdk = new int[] {9};
jdk9.datesUntil(now, Period.ofMonths(6)).forEach((t) -> {
OFFICIAL_JAVADOC.put(String.valueOf(jdk[0]), "https://docs.oracle.com/javase/"+jdk[0]+"/docs/api/"); // NOI18N
jdk[0]++;
});
OFFICIAL_JAVADOC.put(String.valueOf(jdk[0]), "https://download.java.net/java/early_access/jdk"+jdk[0]+"/docs/api/"); // NOI18N Early access
}
}

@Override
Expand Down

0 comments on commit 0ec0a98

Please sign in to comment.