@Override
    @SuppressWarnings("unchecked")
    public MaterialPattern read(Object value) {
        if (value == null) {
            logger.warning("Unknown material (null value)");
            return null;

        } else if (value instanceof Map) {
            Map<Object, Object> structure = (Map<Object, Object>) value;

            if (structure.size() != 1) {
                logger.warning("Material in format (mat:data) must have only one entry");
                return null;
            }

            Object material = structure.keySet().iterator().next();

            if (material == null) {
                logger.warning("Invalid material in material:data format (null provided for material)");
                return null;
            }

            MaterialPattern pattern = fromMaterial(material);

            if (pattern == null) {
                return null; // Already handled an error
            }

            if (pattern.hasDataFilter()) {
                logger.warning("Material '" + material + "' already has data attached in the material database; can't add more");
                return pattern;
            }

            Object data = structure.get(material);

            if (data == null) {
                return pattern;
            } else if (data instanceof List) {
                for (Object dataEntry : (List<Object>) data) {
                    appendData(pattern, dataEntry);
                }
            } else {
                appendData(pattern, data);
            }

            return pattern;

        } else {
            return fromMaterial(value);
        }
    }