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

de.schlichtherle.truezip.zip.ZipParametersUtils Maven / Gradle / Ivy

/*
 * Copyright (C) 2005-2015 Schlichtherle IT Services.
 * All rights reserved. Use is subject to license terms.
 */
package de.schlichtherle.truezip.zip;

import javax.annotation.CheckForNull;
import javax.annotation.concurrent.ThreadSafe;

/**
 * Provides static utility methods for ZIP parameters.
 * 
 * @author Christian Schlichtherle
 */
@ThreadSafe
final class ZipParametersUtils {

    private ZipParametersUtils() {
    }

    /**
     * Searches for {@code ZipParameters} of the given type starting from
     * the given parameters.
     * 
     * @param  

the type of the ZIP parameters to search for. * @param type the type of the ZIP parameters to search for. * @param param the parameters for starting the search. * @return The parameters of the given type. * @throws ZipParametersException if {@code param} is {@code null} or * no suitable parameters can get found. */ static

P parameters( final Class

type, @CheckForNull ZipParameters param) throws ZipParametersException { while (null != param) { // Order is important here to support multiple interface implementations! if (type.isInstance(param)) { return type.cast(param); } else if (param instanceof ZipParametersProvider) { param = ((ZipParametersProvider) param).get(type); } else { break; } } throw new ZipParametersException("No suitable ZIP parameters available!"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy