@@ -0,0 +1,2878 @@
+/**%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.hedwig.protoextensions;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport com.google.protobuf.ByteString;%0Aimport org.apache.hedwig.protocol.PubSubProtocol;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Apublic class MapUtils %7B%0A%0A    static final Logger logger = LoggerFactory.getLogger(MapUtils.class);%0A%0A    public static String toString(PubSubProtocol.Map map) %7B%0A        StringBuilder sb = new StringBuilder();%0A        int numEntries = map.getEntriesCount();%0A        for (int i=0; i%3CnumEntries; i++) %7B%0A            PubSubProtocol.Map.Entry entry = map.getEntries(i);%0A            String key = entry.getKey();%0A            ByteString value = entry.getValue();%0A            sb.append(key).append('=').append(value.toStringUtf8());%0A            if (i != (numEntries - 1)) %7B%0A                sb.append(',');%0A            %7D%0A        %7D%0A        return sb.toString();%0A    %7D%0A%0A    public static Map%3CString, ByteString%3E buildMap(PubSubProtocol.Map protoMap) %7B%0A        Map%3CString, ByteString%3E javaMap = new HashMap%3CString, ByteString%3E();%0A%0A        int numEntries = protoMap.getEntriesCount();%0A        for (int i=0; i%3CnumEntries; i++) %7B%0A            PubSubProtocol.Map.Entry entry = protoMap.getEntries(i);%0A            String key = entry.getKey();%0A            if (javaMap.containsKey(key)) %7B%0A                ByteString preValue = javaMap.get(key);%0A                logger.warn(%22Key %22 + key + %22 has already been defined as value : %22 + preValue.toStringUtf8());%0A            %7D else %7B%0A                javaMap.put(key, entry.getValue());%0A            %7D%0A        %7D%0A        return javaMap;%0A    %7D%0A%0A    public static PubSubProtocol.Map.Builder buildMapBuilder(Map%3CString, ByteString%3E javaMap) %7B%0A        PubSubProtocol.Map.Builder mapBuilder = PubSubProtocol.Map.newBuilder();%0A%0A        for (Map.Entry%3CString, ByteString%3E entry : javaMap.entrySet()) %7B%0A            mapBuilder.addEntries(PubSubProtocol.Map.Entry.newBuilder().setKey(entry.getKey())%0A                                                .setValue(entry.getValue()));%0A        %7D%0A        return mapBuilder;%0A    %7D%0A%7D%0A

Add SubscriptionPreferences to record all preferences for a subscription (sijie via ivank) [missing files]