0

I have a new branch in my code, where a lot of jdoc-comments. were added. However, the code was also automatically reformatted and imports were rearranged.

I'd like to have the documentation in a seperate branch / pull request.

Is there a way to export the jdoc from the solution and then re-apply the exported jdocs to the original code? Or is there another way to achieve this?

original:

    protected static Random r = new Random();
    private static final String WACHTWOORD_PATTERN = PropertiesFileLoader.getInstance().getProperty("pwd.pattern", "aaaaaann");
    private static final boolean ENKEL_HOOFDLETTERS_TOEGESTAAN = Boolean.parseBoolean(PropertiesFileLoader.getInstance().getProperty("pwd.allUppercaseAllowed", "false"));
    private static final boolean ENKEL_KLEINELETTERS_TOEGESTAAN = Boolean.parseBoolean(PropertiesFileLoader.getInstance().getProperty("pwd.allLowercaseAllowed", "false"));
    private static Integer[] LETTERS_INDICES = null;
    private static final Map<String, String[]> TEKENS_MAP = new HashMap<String, String[]>();

    public static String volgendWachtwoord() {
        String wachtwoord = "";
        for (int i = 0; i < WACHTWOORD_PATTERN.length(); ++i) {
            wachtwoord = wachtwoord + TEKENS_MAP.get(WACHTWOORD_PATTERN.substring(i, i + 1))[r.nextInt(TEKENS_MAP.get(WACHTWOORD_PATTERN.substring(i, i + 1)).length)];
        }
        if (null != LETTERS_INDICES && LETTERS_INDICES.length > 0) {
            if (!ENKEL_HOOFDLETTERS_TOEGESTAAN && wachtwoord.toUpperCase().equals(wachtwoord)) {
                int kleineLetterIndex = r.nextInt(LETTERS_INDICES.length);
                wachtwoord = wachtwoord.substring(0, kleineLetterIndex) + wachtwoord.substring(kleineLetterIndex, kleineLetterIndex + 1).toLowerCase() + (kleineLetterIndex == LETTERS_INDICES.length - 1 ? "" : wachtwoord.substring(kleineLetterIndex + 1));
            }
            if (!ENKEL_KLEINELETTERS_TOEGESTAAN && wachtwoord.toLowerCase().equals(wachtwoord)) {
                int groteLetterIndex = r.nextInt(LETTERS_INDICES.length);
                wachtwoord = wachtwoord.substring(0, groteLetterIndex) + wachtwoord.substring(groteLetterIndex, groteLetterIndex + 1).toUpperCase() + (groteLetterIndex == LETTERS_INDICES.length - 1 ? "" : wachtwoord.substring(groteLetterIndex + 1));
        ...

changed:

    protected static     Random                r                              = new Random();
    private static final String                WACHTWOORD_PATTERN             = PropertiesFileLoader.getInstance().getProperty("pwd.pattern", "aaaaaann");
    private static final boolean               ENKEL_HOOFDLETTERS_TOEGESTAAN  = Boolean.parseBoolean(
            PropertiesFileLoader.getInstance().getProperty("pwd.allUppercaseAllowed", "false"));
    private static final boolean               ENKEL_KLEINELETTERS_TOEGESTAAN = Boolean.parseBoolean(
            PropertiesFileLoader.getInstance().getProperty("pwd.allLowercaseAllowed", "false"));
    private static       Integer[]             LETTERS_INDICES                = null;
    private static final Map<String, String[]> TEKENS_MAP                     = new HashMap<String, String[]>();
    /**
     * It generates a random password based on the pattern and the tokens map
     *
     * @return A random password
     */
    public static String volgendWachtwoord() {
        String wachtwoord = "";
        for (int i = 0; i < WACHTWOORD_PATTERN.length(); ++i) {
            wachtwoord = wachtwoord + TEKENS_MAP.get(WACHTWOORD_PATTERN.substring(i, i + 1))[r.nextInt(TEKENS_MAP.get(WACHTWOORD_PATTERN.substring(i, i + 1)).length)];
        }
        if (null != LETTERS_INDICES && LETTERS_INDICES.length > 0) {
            if (!ENKEL_HOOFDLETTERS_TOEGESTAAN && wachtwoord.toUpperCase().equals(wachtwoord)) {
                int kleineLetterIndex = r.nextInt(LETTERS_INDICES.length);
                wachtwoord = wachtwoord.substring(0, kleineLetterIndex) + wachtwoord.substring(kleineLetterIndex, kleineLetterIndex + 1).toLowerCase() + (
                        kleineLetterIndex == LETTERS_INDICES.length - 1 ? "" : wachtwoord.substring(kleineLetterIndex + 1));
            }
            if (!ENKEL_KLEINELETTERS_TOEGESTAAN && wachtwoord.toLowerCase().equals(wachtwoord)) {
                int groteLetterIndex = r.nextInt(LETTERS_INDICES.length);
                wachtwoord = wachtwoord.substring(0, groteLetterIndex) + wachtwoord.substring(groteLetterIndex, groteLetterIndex + 1).toUpperCase() + (
                        groteLetterIndex == LETTERS_INDICES.length - 1 ? "" : wachtwoord.substring(groteLetterIndex + 1));
        ...
realbart
  • 3,497
  • 1
  • 25
  • 37
  • You could try staging hunks, and maybe automate it based on your comment patterns, [like this](https://stackoverflow.com/q/36932309/184546). – TTT Jan 03 '23 at 17:07
  • So your approach would be to take the diffs and grep the files starting with + /* or with + *? – realbart Jan 05 '23 at 23:01

0 Answers0