001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Florent Guillaume
011 */
012package org.nuxeo.ecm.core.query.sql.model;
013
014/**
015 * Boolean literal.
016 */
017public class BooleanLiteral extends Literal {
018
019    private static final long serialVersionUID = 1L;
020
021    public final boolean value;
022
023    public BooleanLiteral(boolean value) {
024        this.value = value;
025    }
026
027    @Override
028    public void accept(IVisitor visitor) {
029        visitor.visitBooleanLiteral(this);
030    }
031
032    @Override
033    public String asString() {
034        return String.valueOf(value);
035    }
036
037    @Override
038    public String toString() {
039        return String.valueOf(value);
040    }
041
042    @Override
043    public boolean equals(Object obj) {
044        if (obj == this) {
045            return true;
046        }
047        if (obj instanceof BooleanLiteral) {
048            return value == ((BooleanLiteral) obj).value;
049        }
050        return false;
051    }
052
053    @Override
054    public int hashCode() {
055        return Boolean.valueOf(value).hashCode();
056    }
057
058}