public static Traits parseTraits(String[] traits) {
        if (traits == null || traits.length == 0) {
            return new Traits();
        }

        Map<String, Map<String, Object>> traitConfigMap = new HashMap<>();

        for (String traitExpression : traits) {
            //traitName.key=value
            final String[] trait = traitExpression.split("\\.", 2);
            final String[] traitConfig = trait[1].split("=", 2);

            // the CRD api is in CamelCase, then we have to
            // convert the kebab-case to CamelCase
            final String traitKey = StringHelper.dashToCamelCase(traitConfig[0]);
            final Object traitValue = resolveTraitValue(traitKey, traitConfig[1].trim());
            if (traitConfigMap.containsKey(trait[0])) {
                Map<String, Object> config = traitConfigMap.get(trait[0]);

                if (config.containsKey(traitKey)) {
                    Object existingValue = config.get(traitKey);

                    if (existingValue instanceof List) {
                        List<String> values = (List<String>) existingValue;
                        if (traitValue instanceof List) {
                            List<String> traitValueList = (List<String>) traitValue;
                            values.addAll(traitValueList);
                        } else {
                            values.add(traitValue.toString());
                        }
                    } else if (existingValue instanceof Map) {
                        Map<String, String> values = (Map<String, String>) existingValue;
                        if (traitValue instanceof Map) {
                            Map<String, String> traitValueList = (Map<String, String>) traitValue;
                            values.putAll(traitValueList);
                        } else {
                            final String[] traitValueConfig = traitValue.toString().split("=", 2);
                            values.put(traitValueConfig[0], traitValueConfig[1]);
                        }
                    } else if (traitValue instanceof List) {
                        List<String> traitValueList = (List<String>) traitValue;
                        traitValueList.add(0, existingValue.toString());
                        config.put(traitKey, traitValueList);
                    } else if (traitValue instanceof Map) {
                        Map<String, String> traitValueMap = (Map<String, String>) traitValue;
                        final String[] existingValueConfig = existingValue.toString().split("=", 2);
                        traitValueMap.put(existingValueConfig[0], existingValueConfig[1]);
                        config.put(traitKey, traitValueMap);
                    } else {
                        if (traitKey.endsWith("annotations")) {
                            Map<String, String> map = new LinkedHashMap<>();
                            final String[] traitValueConfig = traitValue.toString().split("=", 2);
                            final String[] existingValueConfig = existingValue.toString().split("=", 2);
                            map.put(traitValueConfig[0], traitValueConfig[1]);
                            map.put(existingValueConfig[0], existingValueConfig[1]);
                            config.put(traitKey, map);
                        } else {
                            config.put(traitKey, Arrays.asList(existingValue.toString(), traitValue));
                        }
                    }
                } else {
                    config.put(traitKey, traitValue);
                }
            } else {
                Map<String, Object> config = new HashMap<>();
                config.put(traitKey, traitValue);
                traitConfigMap.put(trait[0], config);
            }
        }

        Traits traitModel = KubernetesHelper.json().convertValue(traitConfigMap, Traits.class);

        // Handle leftover traits as addons
        Set<?> knownTraits = KubernetesHelper.json().convertValue(traitModel, Map.class).keySet();
        if (knownTraits.size() < traitConfigMap.size()) {
            traitModel.setAddons(new HashMap<>());
            for (Map.Entry<String, Map<String, Object>> traitConfig : traitConfigMap.entrySet()) {
                if (!knownTraits.contains(traitConfig.getKey())) {
                    traitModel.getAddons().put(traitConfig.getKey(),
                            new AddonsBuilder().addToAdditionalProperties(traitConfig.getValue()).build());
                }
            }
        }

        return traitModel;
    }
@Test
    public void parseTraitsTest() {
        String[] traits = new String[] {
                "custom.property=custom",
                "container.port=8080",
                "container.port-name=custom" };
        Traits traitsSpec = TraitHelper.parseTraits(traits);
        Assertions.assertNotNull(traitsSpec);
        Assertions.assertEquals(8080L, traitsSpec.getContainer().getPort());
        Assertions.assertNotNull(traitsSpec.getAddons().get("custom"));

        Traits traitsSpecEmpty = TraitHelper.parseTraits(new String[0]);
        Assertions.assertNotNull(traitsSpecEmpty);

        Traits traitsSpecNull = TraitHelper.parseTraits(null);
        Assertions.assertNotNull(traitsSpecNull);
    }