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

com.liberologico.cloudesire.cmw.model.dto.ApplicationFileDTO Maven / Gradle / Ivy

The newest version!
package com.liberologico.cloudesire.cmw.model.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

public class ApplicationFileDTO extends FileDTO implements INamedEntityDTO
{
    @NotEmpty
    private String version;
    @NotEmpty
    private String name;

    @Valid
    private Set endpointPatterns = new HashSet<>();
    @Valid
    private List applicationMetrics = new ArrayList<>();
    @Valid
    private List dependencies = new ArrayList<>();

    @NotNull
    private Boolean installable = false;

    @Valid
    private Set configurations;

    @Valid
    private Set environment = new HashSet<>();

    @JsonIgnore
    public Map getEnvironmentMap()
    {
        Map output = new HashMap<>();
        for ( ApplicationFileEnvironmentDTO dto : environment )
        {
            output.put( dto.getVariable(), dto.getValue() );
        }
        return output;
    }

    @JsonIgnore
    public void setEnvironmentMap( Map environment )
    {
        this.environment.clear();
        String url = this.getSelf();
        for ( Map.Entry entry : environment.entrySet() )
        {
            this.environment.add( new ApplicationFileEnvironmentDTO( url, entry.getKey(), entry.getValue()) );
        }
    }

    // region Auto-generated code
    public String getVersion()
    {
        return version;
    }

    public void setVersion( String version )
    {
        this.version = version;
    }

    public String getName()
    {
        return name;
    }

    public void setName( String name )
    {
        this.name = name;
    }

    public Boolean getInstallable()
    {
        return installable;
    }

    public void setInstallable( Boolean installable )
    {
        this.installable = installable;
    }

    public List getDependencies()
    {
        return dependencies;
    }

    public void setDependencies( List dependencies )
    {
        this.dependencies = dependencies;
    }

    public Set getEndpointPatterns()
    {
        return endpointPatterns;
    }

    public void setEndpointPatterns( Set endpointPatterns )
    {
        this.endpointPatterns = endpointPatterns;
    }

    public Set getEnvironment()
    {
        return environment;
    }

    public void setEnvironment( Set environment )
    {
        this.environment = environment;
    }

    public Set getConfigurations()
    {
        return configurations;
    }

    public void setConfigurations( Set configurations )
    {
        this.configurations = configurations;
    }

    public List getApplicationMetrics()
    {
        return applicationMetrics;
    }

    public void setApplicationMetrics( List applicationMetrics )
    {
        this.applicationMetrics = applicationMetrics;
    }

    @Override
    public boolean equals( Object o )
    {
        if ( this == o ) return true;
        if ( !( o instanceof ApplicationFileDTO ) ) return false;
        if ( !super.equals( o ) ) return false;
        ApplicationFileDTO that = (ApplicationFileDTO) o;
        return Objects.equals( version, that.version ) &&
                Objects.equals( name, that.name ) &&
                Objects.equals( endpointPatterns, that.endpointPatterns ) &&
                Objects.equals( dependencies, that.dependencies ) &&
                Objects.equals( installable, that.installable ) &&
                Objects.equals( environment, that.environment );
    }

    @Override
    public int hashCode()
    {
        return Objects.hash( super.hashCode(), version, name, endpointPatterns, dependencies, installable,
                environment );
    }
    // endregion
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy