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

com.vmware.pscoe.iac.artifact.model.basic.BasicPackageDescriptor Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
/*
 * #%L
 * artifact-manager
 * %%
 * Copyright (C) 2023 VMware
 * %%
 * Build Tools for VMware Aria
 * Copyright 2023 VMware, Inc.
 * 
 * This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in compliance with the BSD-2 License.  
 * 
 * This product may include a number of subcomponents with separate copyright notices and license terms. Your use of these subcomponents is subject to the terms and conditions of the subcomponent's license, as noted in the LICENSE file.
 * #L%
 */
package com.vmware.pscoe.iac.artifact.model.basic;

import java.io.File;
import java.util.List;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.vmware.pscoe.iac.artifact.model.PackageDescriptor;

public class BasicPackageDescriptor extends PackageDescriptor {
	private List content;

	public List getContent() {
		return content;
	}

	public void setContent(List content) {
		this.content = content;
	}

	public List getMembersForType(BasicPackageMemberType type) {
		if (BasicPackageMemberType.CONTENT.equals(type)) {
			return getContent();
		} else {
			throw new RuntimeException(String.format("ContentType '%s' is not supported!", type));
		}
	}

	public static BasicPackageDescriptor getInstance(File filesystemPath) {
		ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
		mapper.setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
		try {
			return mapper.readValue(filesystemPath, BasicPackageDescriptor.class);
		} catch (Exception e) {
			throw new RuntimeException(
					"Unable to load Basic Package Descriptor [" + filesystemPath.getAbsolutePath() + "]", e);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy