1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | package Torello.Java.Build; import static Torello.Java.C.BYELLOW; import static Torello.Java.C.RESET; import Torello.Java.StrIndent; import Torello.Java.ReadOnly.ReadOnlyList; import Torello.Java.ReadOnly.ReadOnlyMap; import static Torello.Java.C.BCYAN; import static Torello.Java.C.RESET; import java.util.Objects; class CollatedOptsRecord { /** The list of options that accept a Package-NickName List */ public final ReadOnlyList<String> optionsWhichAcceptPkgNickNames; /** * Map's a switch-string such as "-pb1" or "-cb2" (or "-pb3") to the actual * CloudSync instance that should be used for that switch. */ public final ReadOnlyMap<String, CloudSync> cloudSyncSwitchMapper; /** * Maintains a list of Options which require the "No Browser Cache" / "Set Max Age" * (Step/Stage 8) to be performed. * * NOTE: This just makes the code in class "CLI" a lot easier to write. I read recently * somewhere on the (extremely sparse) Java-Doc Documentation for the Apache-CLI class * "Option" (or "Options", I forget which), that "Multi-Stage" Processing for the * "String[] argv" parameter is the way to go. * * I haven't quite figured out what that wonderful piece of cryptic information actually * meant, but these ReadOnly Option-Lists & Map seem to work just fine for actually processing * the User's Request inside class "CLI" (Torello.Java.Build.CLI, of course, being the class * that processes the "main(String[] argv)" User-Input String-Array)... */ public final ReadOnlyList<String> smaRequested_optionsList; /** The list of "-pb" Options which include Stage-5. No More No Less. */ public final ReadOnlyList<String> partialWithSync_List; /** * The Composite-Step Build Menu-Option for running Steps #1 to #4. Since that option simply * does not have any Cloud-Synchronization Stages, it is only offered once on the menu, * rather than being offered once per Cloud-Sync instance. * * If the user has, indeed, provided CloudSync instances into his class 'Config', then this * String will be named "-pb1". If the user has not provided a CloudSync's to his class * 'Config', then this will simply be named "-cb1", and it will be the only * Composite-Stage, Complete-Build Option in his CLI-Menu. */ public final String compositeStep_RunStage2to4_OptionName; CollatedOptsRecord( final ReadOnlyList<String> optionsWhichAcceptPkgNickNames, final ReadOnlyMap<String, CloudSync> cloudSyncSwitchMapper, final ReadOnlyList<String> smaRequested_optionsList, final ReadOnlyList<String> partialWithSync_List, final String compositeStep_RunStage2to4_OptionName ) { this.optionsWhichAcceptPkgNickNames = optionsWhichAcceptPkgNickNames; this.cloudSyncSwitchMapper = cloudSyncSwitchMapper; this.smaRequested_optionsList = smaRequested_optionsList; this.partialWithSync_List = partialWithSync_List; this.compositeStep_RunStage2to4_OptionName = compositeStep_RunStage2to4_OptionName; } // ******************************************************************************************** // ******************************************************************************************** // java.lang.Object // ******************************************************************************************** // ******************************************************************************************** public String toString() { return BCYAN + "this.optionsWhichAcceptPkgNickNames.toString():\n\t" + RESET + this.optionsWhichAcceptPkgNickNames.toString() + "\n\n" + BCYAN + "this.cloudSyncSwitchMapper.toString():\n" + RESET + mapStr(this.cloudSyncSwitchMapper) + BCYAN + "this.smaRequested_optionsList.toString():\n\t" + RESET + this.smaRequested_optionsList.toString() + "\n\n" + BCYAN + "this.partialWithSync_List.toString():\n\t" + RESET + this.partialWithSync_List.toString() + "\n\n" + BCYAN + "this.compositeStep_RunStage2to4_OptionName:\n\t" + RESET + this.compositeStep_RunStage2to4_OptionName + "\n\n"; } private static String mapStr(ReadOnlyMap<String, CloudSync> map) { StringBuilder sb = new StringBuilder(); for (ReadOnlyMap.Entry<String, CloudSync> e : map.entrySet()) sb.append( BYELLOW + "Storage-Bucket Nick-Name: " + RESET + e.getKey() + '\n' + BYELLOW + "CloudSync Instance: " + RESET + e.getValue().nickName + "\n\n" ); return StrIndent.indent(sb.toString(), 2, false, true); } public boolean equals(Object o) { if (! (o instanceof CollatedOptsRecord)) return false; CollatedOptsRecord other = (CollatedOptsRecord) o; return Objects.equals (this.optionsWhichAcceptPkgNickNames, other.optionsWhichAcceptPkgNickNames) && Objects.equals (this.cloudSyncSwitchMapper, other.cloudSyncSwitchMapper) && Objects.equals (this.smaRequested_optionsList, other.smaRequested_optionsList) && Objects.equals (this.partialWithSync_List, other.partialWithSync_List) && Objects.equals ( this.compositeStep_RunStage2to4_OptionName, other.compositeStep_RunStage2to4_OptionName ); } public int hashCode() { return this.cloudSyncSwitchMapper.hashCode() + this.smaRequested_optionsList.hashCode() + this.partialWithSync_List.hashCode(); } } |