    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.imaging.formats.webp;
    018
    019import java.util.ArrayList;
    020import java.util.Collections;
    021import java.util.List;
    022
    023import org.apache.commons.imaging.common.GenericImageMetadata;
    024import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
    025
    026/**
    027 * WebP image metadata.
    028 *
    029 * @since 1.0.0-alpha4
    030 */
    031public final class WebPImageMetadata extends GenericImageMetadata {
    032
    033    /**
    034     * TIFF Exif metadata.
    035     */
    036    private final TiffImageMetadata exif;
    037
    038    /**
    039     * Create a new WebP image metadata object.
    040     *
    041     * @param exif the Exif metadata.
    042     */
    043    public WebPImageMetadata(final TiffImageMetadata exif) {
    044        this.exif = exif;
    045    }
    046
    047    /**
    048     * Returns the Exif metadata.
    049     *
    050     * @return {@code null} if no Exif metadata is available; otherwise, returns the Exif metadata.
    051     */
    052    public TiffImageMetadata getExif() {
    053        return exif;
    054    }
    055
    056    @Override
    057    public List<? extends ImageMetadataItem> getItems() {
    058        final ArrayList<ImageMetadataItem> items = new ArrayList<>(super.getItems());
    059        if (exif != null) {
    060            items.addAll(exif.getItems());
    061        }
    062        return Collections.unmodifiableList(items);
    063    }
    064}