All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.auties.protobuf.builtin.ProtobufMapMixin Maven / Gradle / Ivy

The newest version!
package it.auties.protobuf.builtin;

import it.auties.protobuf.annotation.ProtobufDefaultValue;
import it.auties.protobuf.annotation.ProtobufMixin;
import it.auties.protobuf.annotation.ProtobufUnknownFields;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

@ProtobufMixin
public class ProtobufMapMixin {
    @ProtobufDefaultValue
    public static  Map newMap() {
        return new HashMap<>();
    }

    @ProtobufDefaultValue
    public static  ConcurrentMap newConcurrentMap() {
        return new ConcurrentHashMap<>();
    }

    @ProtobufDefaultValue
    public static  SequencedMap newSequencedMap() {
        return new LinkedHashMap<>();
    }

    @SuppressWarnings("SortedCollectionWithNonComparableKeys")
    @ProtobufDefaultValue
    public static  NavigableMap newNavigableMap() {
        return new TreeMap<>();
    }

    @SuppressWarnings("SortedCollectionWithNonComparableKeys")
    @ProtobufDefaultValue
    public static  SortedMap newSortedMap() {
        return new TreeMap<>();
    }

    @ProtobufUnknownFields.Setter
    public static void addUnknownField(Map map, Integer name, Object value) {
        map.put(name, value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy