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

com.redhat.red.build.koji.model.json.BuildComponent Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2015 Red Hat, Inc. ([email protected])
 *
 * 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 com.redhat.red.build.koji.model.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.redhat.red.build.koji.model.converter.KojiBuildComponentConverter;
import org.commonjava.rwx.anno.Converter;
import org.commonjava.rwx.anno.DataKey;

import java.util.HashSet;
import java.util.Set;

import static com.redhat.red.build.koji.model.json.KojiJsonConstants.TYPE;

/**
 *
 * @author Honza Brázdil <[email protected]>
 */
@JsonTypeInfo(use = Id.NAME, include = As.PROPERTY, property = TYPE)
@JsonSubTypes({
@JsonSubTypes.Type(value = FileBuildComponent.class, name = "file"),
@JsonSubTypes.Type(value = RPMBuildComponent.class, name = "rpm")
})
@Converter( KojiBuildComponentConverter.class )
public abstract class BuildComponent {

    @JsonProperty(TYPE)
    @DataKey( TYPE )
    private String type;

    public BuildComponent()
    {
    }

    public BuildComponent( String type)
    {
        this.type = type;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public static abstract class Builder implements SectionBuilder, VerifiableBuilder {

        private BuildRoot.Builder parent;

        public Builder() {
        }

        public Builder(BuildRoot.Builder parent) {
            this.parent = parent;
        }

        public BuildRoot.Builder parent() {
            return parent;
        }

        @Override
        public T build() throws VerificationException {
            Set missing = new HashSet<>();
            findMissingProperties("%s", missing);
            if (!missing.isEmpty()) {
                throw new VerificationException(missing);
            }

            return unsafeBuild();
        }

        public abstract String getIdentifier();

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy