View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.hbtop.terminal;
19  
20  import java.util.Objects;
21  
22  import org.apache.hadoop.hbase.classification.InterfaceAudience;
23  
24  /**
25   * The attributes of text in the terminal.
26   */
27  @InterfaceAudience.Private
28  public class Attributes {
29    private boolean bold;
30    private boolean blink;
31    private boolean reverse;
32    private boolean underline;
33    private Color foregroundColor;
34    private Color backgroundColor;
35  
36    public Attributes() {
37      reset();
38    }
39  
40    public Attributes(Attributes attributes) {
41      set(attributes);
42    }
43  
44    public boolean isBold() {
45      return bold;
46    }
47  
48    public void setBold(boolean bold) {
49      this.bold = bold;
50    }
51  
52    public boolean isBlink() {
53      return blink;
54    }
55  
56    public void setBlink(boolean blink) {
57      this.blink = blink;
58    }
59  
60    public boolean isReverse() {
61      return reverse;
62    }
63  
64    public void setReverse(boolean reverse) {
65      this.reverse = reverse;
66    }
67  
68    public boolean isUnderline() {
69      return underline;
70    }
71  
72    public void setUnderline(boolean underline) {
73      this.underline = underline;
74    }
75  
76    public Color getForegroundColor() {
77      return foregroundColor;
78    }
79  
80    public void setForegroundColor(Color foregroundColor) {
81      this.foregroundColor = foregroundColor;
82    }
83  
84    public Color getBackgroundColor() {
85      return backgroundColor;
86    }
87  
88    public void setBackgroundColor(Color backgroundColor) {
89      this.backgroundColor = backgroundColor;
90    }
91  
92    public void reset() {
93      bold = false;
94      blink = false;
95      reverse = false;
96      underline = false;
97      foregroundColor = Color.WHITE;
98      backgroundColor = Color.BLACK;
99    }
100 
101   public void set(Attributes attributes) {
102     bold = attributes.bold;
103     blink = attributes.blink;
104     reverse = attributes.reverse;
105     underline = attributes.underline;
106     foregroundColor = attributes.foregroundColor;
107     backgroundColor = attributes.backgroundColor;
108   }
109 
110   @Override
111   public boolean equals(Object o) {
112     if (this == o) {
113       return true;
114     }
115     if (!(o instanceof Attributes)) {
116       return false;
117     }
118     Attributes that = (Attributes) o;
119     return bold == that.bold && blink == that.blink && reverse == that.reverse
120       && underline == that.underline && foregroundColor == that.foregroundColor
121       && backgroundColor == that.backgroundColor;
122   }
123 
124   @Override
125   public int hashCode() {
126     return Objects.hash(bold, blink, reverse, underline, foregroundColor, backgroundColor);
127   }
128 }