001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.classic.spi;
015
016import java.io.Serializable;
017
018public class ClassPackagingData implements Serializable {
019
020    private static final long serialVersionUID = -804643281218337001L;
021    final String codeLocation;
022    final String version;
023    private final boolean exact;
024
025    public ClassPackagingData(String codeLocation, String version) {
026        this.codeLocation = codeLocation;
027        this.version = version;
028        this.exact = true;
029    }
030
031    public ClassPackagingData(String classLocation, String version, boolean exact) {
032        this.codeLocation = classLocation;
033        this.version = version;
034        this.exact = exact;
035    }
036
037    public String getCodeLocation() {
038        return codeLocation;
039    }
040
041    public String getVersion() {
042        return version;
043    }
044
045    public boolean isExact() {
046        return exact;
047    }
048
049    @Override
050    public int hashCode() {
051        final int PRIME = 31;
052        int result = 1;
053        result = PRIME * result + ((codeLocation == null) ? 0 : codeLocation.hashCode());
054        return result;
055    }
056
057    @Override
058    public boolean equals(Object obj) {
059        if (this == obj)
060            return true;
061        if (obj == null)
062            return false;
063        if (getClass() != obj.getClass())
064            return false;
065        final ClassPackagingData other = (ClassPackagingData) obj;
066        if (codeLocation == null) {
067            if (other.codeLocation != null)
068                return false;
069        } else if (!codeLocation.equals(other.codeLocation))
070            return false;
071        if (exact != other.exact)
072            return false;
073        if (version == null) {
074            if (other.version != null)
075                return false;
076        } else if (!version.equals(other.version))
077            return false;
078        return true;
079    }
080
081}