001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.hbtop.terminal;
019
020import java.util.Objects;
021import org.apache.yetus.audience.InterfaceAudience;
022
023/**
024 * The attributes of text in the terminal.
025 */
026@InterfaceAudience.Private
027public class Attributes {
028  private boolean bold;
029  private boolean blink;
030  private boolean reverse;
031  private boolean underline;
032  private Color foregroundColor;
033  private Color backgroundColor;
034
035  public Attributes() {
036    reset();
037  }
038
039  public Attributes(Attributes attributes) {
040    set(attributes);
041  }
042
043  public boolean isBold() {
044    return bold;
045  }
046
047  public void setBold(boolean bold) {
048    this.bold = bold;
049  }
050
051  public boolean isBlink() {
052    return blink;
053  }
054
055  public void setBlink(boolean blink) {
056    this.blink = blink;
057  }
058
059  public boolean isReverse() {
060    return reverse;
061  }
062
063  public void setReverse(boolean reverse) {
064    this.reverse = reverse;
065  }
066
067  public boolean isUnderline() {
068    return underline;
069  }
070
071  public void setUnderline(boolean underline) {
072    this.underline = underline;
073  }
074
075  public Color getForegroundColor() {
076    return foregroundColor;
077  }
078
079  public void setForegroundColor(Color foregroundColor) {
080    this.foregroundColor = foregroundColor;
081  }
082
083  public Color getBackgroundColor() {
084    return backgroundColor;
085  }
086
087  public void setBackgroundColor(Color backgroundColor) {
088    this.backgroundColor = backgroundColor;
089  }
090
091  public void reset() {
092    bold = false;
093    blink = false;
094    reverse = false;
095    underline = false;
096    foregroundColor = Color.WHITE;
097    backgroundColor = Color.BLACK;
098  }
099
100  public void set(Attributes attributes) {
101    bold = attributes.bold;
102    blink = attributes.blink;
103    reverse = attributes.reverse;
104    underline = attributes.underline;
105    foregroundColor = attributes.foregroundColor;
106    backgroundColor = attributes.backgroundColor;
107  }
108
109  @Override
110  public boolean equals(Object o) {
111    if (this == o) {
112      return true;
113    }
114    if (!(o instanceof Attributes)) {
115      return false;
116    }
117    Attributes that = (Attributes) o;
118    return bold == that.bold && blink == that.blink && reverse == that.reverse
119      && underline == that.underline && foregroundColor == that.foregroundColor
120      && backgroundColor == that.backgroundColor;
121  }
122
123  @Override
124  public int hashCode() {
125    return Objects.hash(bold, blink, reverse, underline, foregroundColor, backgroundColor);
126  }
127}