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 IntegerLiteral extends Literal { 021 022 private static final long serialVersionUID = 4769705314623462546L; 023 024 public final long value; 025 026 public IntegerLiteral(long value) { 027 this.value = value; 028 } 029 030 public IntegerLiteral(Long value) { 031 this.value = value; 032 } 033 034 public IntegerLiteral(Integer value) { 035 this.value = value; 036 } 037 038 public IntegerLiteral(String value) { 039 this.value = Long.parseLong(value); 040 } 041 042 @Override 043 public void accept(IVisitor visitor) { 044 visitor.visitIntegerLiteral(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 IntegerLiteral) { 063 return value == ((IntegerLiteral) obj).value; 064 } 065 return false; 066 } 067 068 @Override 069 public int hashCode() { 070 return Long.valueOf(value).hashCode(); 071 } 072 073}