1 /*******************************************************************************
2 * Copyright (c) 2010 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.databoard.type;
16 import org.simantics.databoard.util.IdentityPair;
17 import org.simantics.databoard.util.Limit;
18 import org.simantics.databoard.util.Range;
20 public class ByteType extends NumberType {
23 public ByteType(String unit) {
26 public ByteType(String unit, String range) {
30 public ByteType(String unit, Range range) {
35 public byte minValue() {
36 Range range = getRange();
37 if (range==null) return Byte.MIN_VALUE;
38 Limit l = range.getLower();
39 byte value = l.getValue().byteValue();
40 if (l.isExclusive()) value++;
44 public byte maxValue() {
45 Range range = getRange();
46 if (range==null) return Byte.MAX_VALUE;
47 Limit l = range.getUpper();
48 byte value = l.getValue().byteValue();
49 if (l.isExclusive()) value--;
54 protected boolean deepEquals(Object obj, Set<IdentityPair<Datatype, Datatype>> compareHistory) {
55 if (this==obj) return true;
56 if ( !hasEqualMetadata(obj) ) return false;
57 return obj instanceof ByteType;
61 public int hashCode() {
62 return metadataHashCode() + 0x436765;
66 public void accept(Visitor1 v, Object obj) {
71 public <T> T accept(Visitor<T> v) {