public SoyMsg build() { SoyMsg msg = new AutoValue_SoyMsg( localeString, id, altId, meaning, desc, isHidden, contentType, isPlrselMsg, parts); if (sourceLocation != null) { msg.addSourceLocation(sourceLocation); } return msg; } }
/** * Note: If there exist duplicate message ids in the {@code msgs} list, the first one wins. * However, the source paths from subsequent duplicates will be added to the source paths for the * message. * * @param localeString The language/locale string of this bundle of messages, or null if unknown. * Should only be null for bundles newly extracted from source files. Should always be set for * bundles parsed from message files/resources. * @param msgs The list of messages. List order will become the iteration order. */ public SoyMsgBundleImpl(@Nullable String localeString, List<SoyMsg> msgs) { this.localeString = localeString; this.locale = localeString == null ? null : new ULocale(localeString); this.isRtl = BidiGlobalDir.forStaticLocale(localeString) == BidiGlobalDir.RTL; // Preserve the ordering of the input. Map<Long, SoyMsg> tempMsgMap = new LinkedHashMap<>(); for (SoyMsg msg : msgs) { checkArgument(Objects.equals(msg.getLocaleString(), localeString)); long msgId = msg.getId(); SoyMsg existingMsg = tempMsgMap.get(msgId); if (existingMsg == null) { // new message id tempMsgMap.put(msgId, msg); } else { // duplicate message id for (SourceLocation source : msg.getSourceLocations()) { existingMsg.addSourceLocation(source); } } } msgMap = ImmutableMap.copyOf(tempMsgMap); }