Package net.hydromatic.morel.type
Class RecordType
- java.lang.Object
-
- net.hydromatic.morel.type.BaseType
-
- net.hydromatic.morel.type.RecordType
-
- All Implemented Interfaces:
RecordLikeType,Type
public class RecordType extends BaseType implements RecordLikeType
The type of a record value.
-
-
Constructor Summary
Constructors Constructor Description RecordType(com.google.common.collect.ImmutableSortedMap<String,Type> argNameTypes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Raccept(TypeVisitor<R> typeVisitor)SortedMap<String,Type>argNameTypes()TypeargType(int i)Returns the type of theith field, or throws.static intcompareNames(String o1, String o2)Helper forORDERING.RecordTypecopy(TypeSystem typeSystem, UnaryOperator<Type> transform)Copies this type, applying a given transform to component types, and returning the original type if the component types are unchanged.Type.Keykey()Description of the type, e.g.Ord<Type>lookupField(String fieldName)Returns the index of a given field, or -1.private static intparseInt(String s)Parses a string that contains an integer value; returnsInteger.MAX_VALUEif the string does not contain an integer, or if the value is less than zero, or if the value is greater than or equal to 1 billion.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.hydromatic.morel.type.Type
moniker, op, substitute
-
-
-
-
Field Detail
-
ORDERING
public static final com.google.common.collect.Ordering<String> ORDERING
Ordering that compares integer values numerically, string values lexicographically, and integer values before string values.Thus: 2, 22, 202, a, a2, a202, a22.
-
-
Method Detail
-
argNameTypes
public SortedMap<String,Type> argNameTypes()
- Specified by:
argNameTypesin interfaceRecordLikeType
-
argType
public Type argType(int i)
Description copied from interface:RecordLikeTypeReturns the type of theith field, or throws.- Specified by:
argTypein interfaceRecordLikeType
-
accept
public <R> R accept(TypeVisitor<R> typeVisitor)
-
key
public Type.Key key()
Description copied from interface:TypeDescription of the type, e.g. "int", "int -> int", "NONE | SOME of 'a".
-
copy
public RecordType copy(TypeSystem typeSystem, UnaryOperator<Type> transform)
Description copied from interface:TypeCopies this type, applying a given transform to component types, and returning the original type if the component types are unchanged.
-
parseInt
private static int parseInt(String s)
Parses a string that contains an integer value; returnsInteger.MAX_VALUEif the string does not contain an integer, or if the value is less than zero, or if the value is greater than or equal to 1 billion.This approach is much faster for our purposes than
Integer.parseInt(String), which has to create and throw an exception if the value is not an integer.
-
-