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

ai.djl.repository.Metadata Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
 * with the License. A copy of the License is located at
 *
 * http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file 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 ai.djl.repository;

import java.net.URI;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * A {@code Metadata} is a collection of {@link Artifact}s with unified metadata (including {@link
 * MRL}) that are stored in the same "metadata.json" file.
 *
 * 

All of the artifacts located within the metadata share the data defined at the metadata level * such as name, description, and website. The key difference between the artifacts within the same * metadata are the properties. * * @see Repository */ public class Metadata { private String metadataVersion; private String groupId; private String artifactId; private String name; private String description; private String website; private List artifacts; private String checksum; private Date lastUpdated; private transient URI repositoryUri; /** * Returns the artifacts matching the version and property requirements. * * @param versionRange the version range for the artifact * @param filter the property filter * @return the matching artifacts */ public List search(VersionRange versionRange, Map filter) { List results = versionRange.matches(artifacts); if (filter == null) { return results; } return results.stream().filter(a -> a.hasProperties(filter)).collect(Collectors.toList()); } /** * Returns the metadata format version. * * @return the metadata format version */ public String getMetadataVersion() { return metadataVersion; } /** * Sets the metadata format version. * * @param metadataVersion the new version */ public void setMetadataVersion(String metadataVersion) { this.metadataVersion = metadataVersion; } /** * Returns the groupId. * * @return the groupId */ public String getGroupId() { return groupId; } /** * Sets the groupId. * * @param groupId the new groupId */ public void setGroupId(String groupId) { this.groupId = groupId; } /** * Returns the artifactId. * * @return the artifactId */ public String getArtifactId() { return artifactId; } /** * Sets the artifactId. * * @param artifactId the new artifactId */ public void setArtifactId(String artifactId) { this.artifactId = artifactId; } /** * Returns the metadata-level name. * * @return the metadata-level name */ public String getName() { return name; } /** * Sets the metadata-level name. * * @param name the new metadata-level name */ public void setName(String name) { this.name = name; } /** * Returns the description. * * @return the description */ public String getDescription() { return description; } /** * Sets the description. * * @param description the description */ public void setDescription(String description) { this.description = description; } /** * Returns the website. * * @return the website */ public String getWebsite() { return website; } /** * Sets the website. * * @param website the website */ public void setWebsite(String website) { this.website = website; } /** * Returns all the artifacts in the metadata. * * @return the artifacts in the metadata */ public List getArtifacts() { return artifacts; } /** * Sets the artifacts for the metadata. * * @param artifacts the new artifacts */ public void setArtifacts(List artifacts) { this.artifacts = artifacts; } /** * Returns the metadata checksum. * * @return the checksum */ public String getChecksum() { return checksum; } /** * Sets the metadata checksum. * * @param checksum the new checksum */ public void setChecksum(String checksum) { this.checksum = checksum; } /** * Returns the last update date for the metadata. * * @return the last update date */ public Date getLastUpdated() { return lastUpdated; } /** * Sets the last update date for the metadata. * * @param lastUpdated the new last update date */ public void setLastUpdated(Date lastUpdated) { this.lastUpdated = lastUpdated; } /** * Returns the URI to the repository storing the metadata. * * @return the URI to the repository storing the metadata */ public URI getRepositoryUri() { return repositoryUri; } /** * Sets the repository URI. * * @param repositoryUri the new URI */ public void setRepositoryUri(URI repositoryUri) { this.repositoryUri = repositoryUri; if (artifacts != null) { for (Artifact artifact : artifacts) { artifact.setMetadata(this); } } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy