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

client.PackageProvider Maven / Gradle / Ivy

/**
 * Copyright 2015 Groupon.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package client;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.common.collect.Maps;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletionStage;

/**
 * A provider that can be used to get a list of packages.
 *
 * @author Brandon Arp (barp at groupon dot com)
 */
@JsonTypeInfo(
        use = JsonTypeInfo.Id.CLASS,
        include = JsonTypeInfo.As.PROPERTY,
        property = "type")
public interface PackageProvider {
    /**
     * Provide a list of all packages.
     *
     * @return A {@link CompletionStage} of a list of packages.
     */
    CompletionStage getAllPackages();

    /**
     * A response for a list of packages.
     */
    class PackageListResponse {
        /**
         * Public constructor.
         *
         * @param packages the list of packages
         */
        public PackageListResponse(final Map> packages) {
            _packages = Maps.newLinkedHashMap(packages);
        }

        public Map> getPackages() {
            return Collections.unmodifiableMap(_packages);
        }

        private final Map> _packages;
    }

    /**
     * Metadata for a package version.
     */
    class PackageVersionMetadata {
        /**
         * Public constructor.
         *
         * @param name package name
         * @param version package version
         * @param bad whether the package is bad
         */
        public PackageVersionMetadata(final String name, final String version, final boolean bad) {
            _name = name;
            _version = version;
            _bad = bad;
        }

        public boolean isBad() {
            return _bad;
        }

        public String getName() {
            return _name;
        }

        public String getVersion() {
            return _version;
        }

        private final String _name;
        private final String _version;
        private final boolean _bad;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy