001package org.clafer.ir; 002 003/** 004 * 005 * @author jimmy 006 */ 007public class IrBoolConstant extends IrBoolVar implements IrConstant { 008 009 private final boolean value; 010 011 IrBoolConstant(boolean value) { 012 super(Boolean.toString(value), value ? IrBoolDomain.TrueDomain : IrBoolDomain.FalseDomain); 013 this.value = value; 014 } 015 016 public boolean getValue() { 017 return value; 018 } 019 020 @Override 021 public boolean equals(Object obj) { 022 if (this == obj) { 023 return true; 024 } 025 if (obj instanceof IrBoolConstant) { 026 IrBoolConstant other = (IrBoolConstant) obj; 027 // Don't need to call super.equals since the domain is the same as value. 028 return value == other.value; 029 } 030 return false; 031 } 032 033 @Override 034 public int hashCode() { 035 // Same values as java.lang.Boolean.hashCode 036 return value ? 1231 : 1237; 037 } 038 039 @Override 040 public String toString() { 041 return getName(); 042 } 043}