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 * Nuxeo - initial API and implementation 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.ecm.core.query.sql.model; 016 017/** 018 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 019 */ 020public class DoubleLiteral extends Literal { 021 022 private static final long serialVersionUID = 5003174671214111301L; 023 024 public final double value; 025 026 public DoubleLiteral(double value) { 027 this.value = value; 028 } 029 030 public DoubleLiteral(Double value) { 031 this.value = value; 032 } 033 034 public DoubleLiteral(Float value) { 035 this.value = value; 036 } 037 038 public DoubleLiteral(String value) { 039 this.value = Double.parseDouble(value); 040 } 041 042 @Override 043 public void accept(IVisitor visitor) { 044 visitor.visitDoubleLiteral(this); 045 } 046 047 @Override 048 public String asString() { 049 return String.valueOf(value); 050 } 051 052 @Override 053 public String toString() { 054 return String.valueOf(value); 055 } 056 057 @Override 058 public boolean equals(Object obj) { 059 if (obj == this) { 060 return true; 061 } 062 if (obj instanceof DoubleLiteral) { 063 return value == ((DoubleLiteral) obj).value; 064 } 065 return false; 066 } 067 068 @Override 069 public int hashCode() { 070 return Double.valueOf(value).hashCode(); 071 } 072 073}