View Javadoc
1   /*
2    * Copyright 2018 SPF4J.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.spf4j.test.log;
17  
18  import java.util.Objects;
19  import org.spf4j.log.Level;
20  
21  /**
22   * @author Zoltan Farkas
23   */
24  public final class PrintConfig {
25  
26    /**
27     * the log category to print. ("" is the root category).
28     */
29    private final String category;
30    /**
31     *  true if we don't want downstream log handlers to receive any logs from this category.
32     */
33    private final boolean greedy;
34    /**
35     *  minimum log level to print.
36     */
37    private final Level minLevel;
38  
39    public PrintConfig(final String category, final Level minLevel, final boolean greedy) {
40      this.category = category;
41      this.greedy = greedy;
42      this.minLevel = minLevel;
43    }
44  
45    public String getCategory() {
46      return category;
47    }
48  
49    public boolean isGreedy() {
50      return greedy;
51    }
52  
53    public Level getMinLevel() {
54      return minLevel;
55    }
56  
57    @Override
58    public int hashCode() {
59      int hash = 11 + Objects.hashCode(this.category);
60      hash = 11 * hash + (this.greedy ? 1 : 0);
61      return 11 * hash + Objects.hashCode(this.minLevel);
62    }
63  
64    @Override
65    public boolean equals(final Object obj) {
66      if (this == obj) {
67        return true;
68      }
69      if (obj == null) {
70        return false;
71      }
72      if (getClass() != obj.getClass()) {
73        return false;
74      }
75      final PrintConfig other = (PrintConfig) obj;
76      if (this.greedy != other.greedy) {
77        return false;
78      }
79      if (!Objects.equals(this.category, other.category)) {
80        return false;
81      }
82      return this.minLevel == other.minLevel;
83    }
84  
85  
86  
87    @Override
88    public String toString() {
89      return "PrintConfig{" + "category=" + category + ", greedy=" + greedy + ", minLevel=" + minLevel + '}';
90    }
91  
92  
93  
94  }