001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Florent Guillaume 018 */ 019package org.nuxeo.ecm.core.query.sql.model; 020 021/** 022 * Boolean literal. 023 */ 024public class BooleanLiteral extends Literal { 025 026 private static final long serialVersionUID = 1L; 027 028 public final boolean value; 029 030 public BooleanLiteral(boolean value) { 031 this.value = value; 032 } 033 034 @Override 035 public void accept(IVisitor visitor) { 036 visitor.visitBooleanLiteral(this); 037 } 038 039 @Override 040 public String asString() { 041 return String.valueOf(value); 042 } 043 044 @Override 045 public String toString() { 046 return String.valueOf(value); 047 } 048 049 @Override 050 public boolean equals(Object obj) { 051 if (obj == this) { 052 return true; 053 } 054 if (obj instanceof BooleanLiteral) { 055 return value == ((BooleanLiteral) obj).value; 056 } 057 return false; 058 } 059 060 @Override 061 public int hashCode() { 062 return Boolean.valueOf(value).hashCode(); 063 } 064 065}