1 // © 2022 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 4 package com.ibm.icu.dev.test.message2; 5 6 import java.util.Collections; 7 import java.util.HashMap; 8 import java.util.Map; 9 10 import com.ibm.icu.message2.MessageFormatter; 11 12 /** 13 * Convenience class that provides the same functionality as 14 * <code>Map.of</code> introduced in JDK 11, which can't be used yet for ICU4J. 15 * 16 * <p>The returned Map is immutable, to prove that the {@link MessageFormatter} 17 * does not change it</p> 18 */ 19 @SuppressWarnings("javadoc") 20 public class Args { 21 22 public static final Map<String, Object> NONE = new HashMap<>(); 23 of( String argName0, Object argValue0)24 public static Map<String, Object> of( 25 String argName0, Object argValue0) { 26 Map<String, Object> result = new HashMap<>(); 27 result.put(argName0, argValue0); 28 return Collections.unmodifiableMap(result); 29 } 30 of( String argName0, Object argValue0, String argName1, Object argValue1)31 public static Map<String, Object> of( 32 String argName0, Object argValue0, 33 String argName1, Object argValue1) { 34 Map<String, Object> result = new HashMap<>(); 35 result.put(argName0, argValue0); 36 result.put(argName1, argValue1); 37 return Collections.unmodifiableMap(result); 38 } 39 of( String argName0, Object argValue0, String argName1, Object argValue1, String argName2, Object argValue2)40 public static Map<String, Object> of( 41 String argName0, Object argValue0, 42 String argName1, Object argValue1, 43 String argName2, Object argValue2) { 44 Map<String, Object> result = new HashMap<>(); 45 result.put(argName0, argValue0); 46 result.put(argName1, argValue1); 47 result.put(argName2, argValue2); 48 return Collections.unmodifiableMap(result); 49 } 50 of( String argName0, Object argValue0, String argName1, Object argValue1, String argName2, Object argValue2, String argName3, Object argValue3)51 public static Map<String, Object> of( 52 String argName0, Object argValue0, 53 String argName1, Object argValue1, 54 String argName2, Object argValue2, 55 String argName3, Object argValue3) { 56 Map<String, Object> result = new HashMap<>(); 57 result.put(argName0, argValue0); 58 result.put(argName1, argValue1); 59 result.put(argName2, argValue2); 60 result.put(argName3, argValue3); 61 return Collections.unmodifiableMap(result); 62 } 63 of( String argName0, Object argValue0, String argName1, Object argValue1, String argName2, Object argValue2, String argName3, Object argValue3, String argName4, Object argValue4)64 public static Map<String, Object> of( 65 String argName0, Object argValue0, 66 String argName1, Object argValue1, 67 String argName2, Object argValue2, 68 String argName3, Object argValue3, 69 String argName4, Object argValue4) { 70 Map<String, Object> result = new HashMap<>(); 71 result.put(argName0, argValue0); 72 result.put(argName1, argValue1); 73 result.put(argName2, argValue2); 74 result.put(argName3, argValue3); 75 result.put(argName4, argValue4); 76 return Collections.unmodifiableMap(result); 77 } 78 of( String argName0, Object argValue0, String argName1, Object argValue1, String argName2, Object argValue2, String argName3, Object argValue3, String argName4, Object argValue4, String argName5, Object argValue5)79 public static Map<String, Object> of( 80 String argName0, Object argValue0, 81 String argName1, Object argValue1, 82 String argName2, Object argValue2, 83 String argName3, Object argValue3, 84 String argName4, Object argValue4, 85 String argName5, Object argValue5) { 86 Map<String, Object> result = new HashMap<>(); 87 result.put(argName0, argValue0); 88 result.put(argName1, argValue1); 89 result.put(argName2, argValue2); 90 result.put(argName3, argValue3); 91 result.put(argName4, argValue4); 92 result.put(argName5, argValue5); 93 return Collections.unmodifiableMap(result); 94 } 95 of( String argName0, Object argValue0, String argName1, Object argValue1, String argName2, Object argValue2, String argName3, Object argValue3, String argName4, Object argValue4, String argName5, Object argValue5, String argName6, Object argValue6)96 public static Map<String, Object> of( 97 String argName0, Object argValue0, 98 String argName1, Object argValue1, 99 String argName2, Object argValue2, 100 String argName3, Object argValue3, 101 String argName4, Object argValue4, 102 String argName5, Object argValue5, 103 String argName6, Object argValue6) { 104 Map<String, Object> result = new HashMap<>(); 105 result.put(argName0, argValue0); 106 result.put(argName1, argValue1); 107 result.put(argName2, argValue2); 108 result.put(argName3, argValue3); 109 result.put(argName4, argValue4); 110 result.put(argName5, argValue5); 111 result.put(argName6, argValue6); 112 return Collections.unmodifiableMap(result); 113 } 114 of( String argName0, Object argValue0, String argName1, Object argValue1, String argName2, Object argValue2, String argName3, Object argValue3, String argName4, Object argValue4, String argName5, Object argValue5, String argName6, Object argValue6, String argName7, Object argValue7)115 public static Map<String, Object> of( 116 String argName0, Object argValue0, 117 String argName1, Object argValue1, 118 String argName2, Object argValue2, 119 String argName3, Object argValue3, 120 String argName4, Object argValue4, 121 String argName5, Object argValue5, 122 String argName6, Object argValue6, 123 String argName7, Object argValue7) { 124 Map<String, Object> result = new HashMap<>(); 125 result.put(argName0, argValue0); 126 result.put(argName1, argValue1); 127 result.put(argName2, argValue2); 128 result.put(argName3, argValue3); 129 result.put(argName4, argValue4); 130 result.put(argName5, argValue5); 131 result.put(argName6, argValue6); 132 result.put(argName7, argValue7); 133 return Collections.unmodifiableMap(result); 134 } 135 of( String argName0, Object argValue0, String argName1, Object argValue1, String argName2, Object argValue2, String argName3, Object argValue3, String argName4, Object argValue4, String argName5, Object argValue5, String argName6, Object argValue6, String argName7, Object argValue7, String argName8, Object argValue8)136 public static Map<String, Object> of( 137 String argName0, Object argValue0, 138 String argName1, Object argValue1, 139 String argName2, Object argValue2, 140 String argName3, Object argValue3, 141 String argName4, Object argValue4, 142 String argName5, Object argValue5, 143 String argName6, Object argValue6, 144 String argName7, Object argValue7, 145 String argName8, Object argValue8) { 146 Map<String, Object> result = new HashMap<>(); 147 result.put(argName0, argValue0); 148 result.put(argName1, argValue1); 149 result.put(argName2, argValue2); 150 result.put(argName3, argValue3); 151 result.put(argName4, argValue4); 152 result.put(argName5, argValue5); 153 result.put(argName6, argValue6); 154 result.put(argName7, argValue7); 155 result.put(argName8, argValue8); 156 return Collections.unmodifiableMap(result); 157 } 158 of( String argName0, Object argValue0, String argName1, Object argValue1, String argName2, Object argValue2, String argName3, Object argValue3, String argName4, Object argValue4, String argName5, Object argValue5, String argName6, Object argValue6, String argName7, Object argValue7, String argName8, Object argValue8, String argName9, Object argValue9)159 public static Map<String, Object> of( 160 String argName0, Object argValue0, 161 String argName1, Object argValue1, 162 String argName2, Object argValue2, 163 String argName3, Object argValue3, 164 String argName4, Object argValue4, 165 String argName5, Object argValue5, 166 String argName6, Object argValue6, 167 String argName7, Object argValue7, 168 String argName8, Object argValue8, 169 String argName9, Object argValue9) { 170 Map<String, Object> result = new HashMap<>(); 171 result.put(argName0, argValue0); 172 result.put(argName1, argValue1); 173 result.put(argName2, argValue2); 174 result.put(argName3, argValue3); 175 result.put(argName4, argValue4); 176 result.put(argName5, argValue5); 177 result.put(argName6, argValue6); 178 result.put(argName7, argValue7); 179 result.put(argName8, argValue8); 180 result.put(argName9, argValue9); 181 return Collections.unmodifiableMap(result); 182 } 183 } 184