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

dk.grinn.keycloak.migration.entities.RealmHistoryPK Maven / Gradle / Ivy

package dk.grinn.keycloak.migration.entities;

/*-
 * #%L
 * Keycloak : Migrate : Spi
 * %%
 * Copyright (C) 2019 Jonas Grann & Kim Jersin
 * %%
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 * #L%
 */

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;

/**
 *
 * @author @author Kim Jersin <[email protected]>
 */
@Embeddable
public class RealmHistoryPK implements Serializable {

    @Basic(optional = false)
    @NotNull
    @Column(name = "id", updatable = false)
    private int id;

    @Basic(optional = false)
    @NotNull
    @Column(name = "installed_rank")
    private int installedRank;

    public RealmHistoryPK() {
    }

    public RealmHistoryPK(ScriptHistoryKey key) {
        this(key.getId(), key.getRank());
    }
    
    public RealmHistoryPK(int id, int installedRank) {
        this.id = id;
        this.installedRank = installedRank;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getInstalledRank() {
        return installedRank;
    }
    
    public ScriptHistoryKey asScriptHistoryKey() {
        return new ScriptHistoryKey(id, installedRank);
    }

    /**
     *
     * @param installedRank
     */
    public void setInstalledRank(int installedRank) {
        this.installedRank = installedRank;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) id;
        hash += (int) installedRank;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RealmHistoryPK)) {
            return false;
        }
        RealmHistoryPK other = (RealmHistoryPK) object;
        if (this.id != other.id) {
            return false;
        }
        if (this.installedRank != other.installedRank) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dk.grinn.keycloak.migration.entities.GkcadmRealmHistoryPK[ id=" + id + ", installedRank=" + installedRank + " ]";
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy