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

org.uberfire.ext.plugin.model.PluginSimpleContent Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2015 JBoss, by Red Hat, Inc
 *
 * 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 org.uberfire.ext.plugin.model;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.jboss.errai.common.client.api.annotations.Portable;
import org.uberfire.backend.vfs.Path;

@Portable
public class PluginSimpleContent extends Plugin {

    private String template;
    private String css;
    private Map codeMap;
    private Set frameworks = new HashSet();
    private Language language;

    public PluginSimpleContent() {
    }

    public PluginSimpleContent( final String name,
                                final PluginType type,
                                final Path path,
                                final String template,
                                final String css,
                                final Map codeMap,
                                final Set frameworks,
                                final Language language ) {
        super( name, type, path );
        this.template = template;
        this.css = css;
        this.codeMap = codeMap;
        this.frameworks = frameworks;
        this.language = language;
    }

    public PluginSimpleContent( final PluginSimpleContent pluginContent,
                                final String template,
                                final String css,
                                final Map codeMap,
                                final Collection frameworks,
                                final Language language ) {
        super( pluginContent.getName(), pluginContent.getType(), pluginContent.getPath() );
        this.codeMap = new HashMap( pluginContent.getCodeMap() != null ? pluginContent.getCodeMap() : Collections.emptyMap() );
        if ( codeMap != null && !codeMap.isEmpty() ) {
            for ( final Map.Entry codeTypeStringEntry : codeMap.entrySet() ) {
                this.codeMap.put( codeTypeStringEntry.getKey(), codeTypeStringEntry.getValue() );
            }
        }

        if (frameworks != null) {
            this.frameworks.clear();
            this.frameworks.addAll(frameworks);
        }

        this.language = pluginContent.getLanguage();
        if ( language != null ) {
            this.language = language;
        }

        this.template = pluginContent.getTemplate();
        if ( template != null ) {
            this.template = template;
        }

        this.css = pluginContent.getCss();
        if ( css != null ) {
            this.css = css;
        }
    }

    public PluginSimpleContent( final PluginSimpleContent pluginContent,
                                final String template,
                                final Map codeMap ) {
        super( pluginContent.getName(), pluginContent.getType(), pluginContent.getPath() );
        this.codeMap = new HashMap( pluginContent.getCodeMap() != null ? pluginContent.getCodeMap() : Collections.emptyMap() );
        if ( codeMap != null && !codeMap.isEmpty() ) {
            for ( final Map.Entry codeTypeStringEntry : codeMap.entrySet() ) {
                this.codeMap.put( codeTypeStringEntry.getKey(), codeTypeStringEntry.getValue() );
            }
        }
        this.template = pluginContent.getTemplate();
        if ( template != null ) {
            this.template = template;
        }
        this.css = pluginContent.getCss();
        this.frameworks = new HashSet( pluginContent.getFrameworks() != null ? pluginContent.getFrameworks() : Collections.emptyList() );
        this.language = pluginContent.getLanguage();
    }

    public String getTemplate() {
        return template;
    }

    public String getCss() {
        return css;
    }

    public Map getCodeMap() {
        return codeMap;
    }

    public Collection getFrameworks() {
        return frameworks;
    }

    public Language getLanguage() {
        return language;
    }

    @Override
    public boolean equals( Object o ) {
        if ( this == o ) {
            return true;
        }
        if ( !( o instanceof PluginSimpleContent ) ) {
            return false;
        }
        if ( !super.equals( o ) ) {
            return false;
        }

        PluginSimpleContent that = (PluginSimpleContent) o;

        if ( codeMap != null ? !codeMap.equals( that.codeMap ) : that.codeMap != null ) {
            return false;
        }
        if ( css != null ? !css.equals( that.css ) : that.css != null ) {
            return false;
        }
        if ( frameworks != null ? !frameworks.equals( that.frameworks ) : that.frameworks != null ) {
            return false;
        }
        if ( language != that.language ) {
            return false;
        }
        if ( template != null ? !template.equals( that.template ) : that.template != null ) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = ~~result;
        result = 31 * result + ( template != null ? template.hashCode() : 0 );
        result = ~~result;
        result = 31 * result + ( css != null ? css.hashCode() : 0 );
        result = ~~result;
        result = 31 * result + ( codeMap != null ? codeMap.hashCode() : 0 );
        result = ~~result;
        result = 31 * result + ( frameworks != null ? frameworks.hashCode() : 0 );
        result = ~~result;
        result = 31 * result + ( language != null ? language.hashCode() : 0 );
        result = ~~result;
        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy