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/** 025 * The attributes of text in the terminal. 026 */ 027@InterfaceAudience.Private 028public class Attributes { 029 private boolean bold; 030 private boolean blink; 031 private boolean reverse; 032 private boolean underline; 033 private Color foregroundColor; 034 private Color backgroundColor; 035 036 public Attributes() { 037 reset(); 038 } 039 040 public Attributes(Attributes attributes) { 041 set(attributes); 042 } 043 044 public boolean isBold() { 045 return bold; 046 } 047 048 public void setBold(boolean bold) { 049 this.bold = bold; 050 } 051 052 public boolean isBlink() { 053 return blink; 054 } 055 056 public void setBlink(boolean blink) { 057 this.blink = blink; 058 } 059 060 public boolean isReverse() { 061 return reverse; 062 } 063 064 public void setReverse(boolean reverse) { 065 this.reverse = reverse; 066 } 067 068 public boolean isUnderline() { 069 return underline; 070 } 071 072 public void setUnderline(boolean underline) { 073 this.underline = underline; 074 } 075 076 public Color getForegroundColor() { 077 return foregroundColor; 078 } 079 080 public void setForegroundColor(Color foregroundColor) { 081 this.foregroundColor = foregroundColor; 082 } 083 084 public Color getBackgroundColor() { 085 return backgroundColor; 086 } 087 088 public void setBackgroundColor(Color backgroundColor) { 089 this.backgroundColor = backgroundColor; 090 } 091 092 public void reset() { 093 bold = false; 094 blink = false; 095 reverse = false; 096 underline = false; 097 foregroundColor = Color.WHITE; 098 backgroundColor = Color.BLACK; 099 } 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}