View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.classic.spi;
11  
12  import java.io.Serializable;
13  
14  public class ClassPackagingData implements Serializable {
15  
16    private static final long serialVersionUID = 637783570208674312L;
17  
18    final String codeLocation;
19    final String version;
20    private final boolean exact;
21    
22    public ClassPackagingData(String codeLocation, String version) {
23      this.codeLocation = codeLocation;
24      this.version = version;
25      this.exact = true;
26    }
27  
28    public ClassPackagingData(String classLocation, String version, boolean exact) {
29      this.codeLocation = classLocation;
30      this.version = version;
31      this.exact = exact;
32    }
33    
34    public String getCodeLocation() {
35      return codeLocation;
36    }
37  
38    public String getVersion() {
39      return version;
40    }
41  
42    public boolean isExact() {
43      return exact;
44    }
45  
46    @Override
47    public int hashCode() {
48      final int PRIME = 31;
49      int result = 1;
50      result = PRIME * result + ((codeLocation == null) ? 0 : codeLocation.hashCode());
51      return result;
52    }
53  
54    @Override
55    public boolean equals(Object obj) {
56      if (this == obj)
57        return true;
58      if (obj == null)
59        return false;
60      if (getClass() != obj.getClass())
61        return false;
62      final ClassPackagingData other = (ClassPackagingData) obj;
63      if (codeLocation == null) {
64        if (other.codeLocation != null)
65          return false;
66      } else if (!codeLocation.equals(other.codeLocation))
67        return false;
68      if (exact != other.exact)
69        return false;
70      if (version == null) {
71        if (other.version != null)
72          return false;
73      } else if (!version.equals(other.version))
74        return false;
75      return true;
76    }
77    
78  }