Class EnumType
java.lang.Object
com.google.javascript.rhino.jstype.JSType
com.google.javascript.rhino.jstype.ObjectType
com.google.javascript.rhino.jstype.PrototypeObjectType
com.google.javascript.rhino.jstype.EnumType
- All Implemented Interfaces:
JSType.WithSourceRef
An enum type representing a branded collection of elements. Each element is referenced by its
name, and has an
EnumElementType type.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.google.javascript.rhino.jstype.JSType
JSType.HasPropertyKind, JSType.Nullability, JSType.SubtypingMode, JSType.TypePair, JSType.WithSourceRef -
Field Summary
Fields inherited from class com.google.javascript.rhino.jstype.JSType
templateTypeMap -
Method Summary
Modifier and TypeMethodDescriptionstatic EnumType.Builderbuilder(JSTypeRegistry registry) booleandefineElement(String name, Node definingNode) Defines a new element on this enum.@Nullable FunctionTypeGets this object's constructor.Returns a user meaningful label for the JSType instance.Gets the elements defined on this enum.Gets the elements' type, which is a subtype of the enumerated type.Gets the enumerated type.@Nullable StringThe ID of the goog.module in which this type was declared.Gets the implicit prototype (a.k.a.final NodeThe node representing the declaration of this type.booleanThis predicate is used to test whether a given type can appear in a numeric context, such as an operand of a multiply operator.booleanThis predicate is used to test whether a given type can appear in anObjectcontext, such as the expression in a with statement.booleanThis predicate is used to test whether a given type can appear in aStringcontext, such as an operand of a string concat (+) operator.testForEquality(JSType that) Comparesthisandthat.Downcasts this to an EnumType, or returns null if this is not an EnumType.<T> TVisit this type with the given visitor.Methods inherited from class com.google.javascript.rhino.jstype.PrototypeObjectType
getCtorExtendedInterfaces, getCtorImplementedInterfaces, getOwnerFunction, getReferenceName, getTemplateParamCount, isAnonymous, isNativeObjectType, matchConstraint, matchesSymbolContext, matchRecordTypeConstraint, setPropertyJSDocInfo, setPropertyNodeMethods inherited from class com.google.javascript.rhino.jstype.ObjectType
cast, clearCachedValues, createDelegateSuffix, defineDeclaredProperty, defineDeclaredProperty, defineInferredProperty, defineInferredProperty, defineSynthesizedProperty, findClosestDefinition, findClosestDefinition, findPropertyTypeWithoutConsideringTemplateTypes, getAllKeys, getClosestDefiningType, getImplicitPrototypeChain, getJSDocInfo, getNormalizedReferenceName, getOwnPropertyDefSite, getOwnPropertyDefSite, getOwnPropertyJSDocInfo, getOwnPropertyJSDocInfo, getOwnPropertyKeys, getOwnPropertyKind, getOwnPropertyKind, getOwnPropertyKnownSymbols, getOwnPropertyNames, getOwnSlot, getOwnSlot, getPossibleToBooleanOutcomes, getPropertiesCount, getPropertyDefSite, getPropertyDefSite, getPropertyJSDocInfo, getPropertyJSDocInfo, getPropertyKind, getPropertyNames, getPropertyNode, getPropertyNode, getPropertyType, getPropertyType, getPropertyTypeMap, getRawType, getSlot, getSlot, getSuperClassConstructor, getTemplateTypes, getTypeOfThis, hasCachedValues, hasOwnDeclaredProperty, hasOwnDeclaredProperty, hasOwnProperty, hasOwnProperty, hasReferenceName, isFunctionPrototypeType, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeDeclared, isPropertyTypeInferred, isPropertyTypeInferred, isStructuralType, isUnknownType, setJSDocInfo, setPropertyJSDocInfo, setPropertyNodeMethods inherited from class com.google.javascript.rhino.jstype.JSType
areSimilar, assertFunctionType, assertObjectType, autobox, autoboxesTo, canBeCalled, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, collapseUnion, containsReferenceAncestor, dereference, differsFrom, equals, findPropertyType, findPropertyType, getEnumeratedTypeOfEnumElement, getGreatestSubtype, getLeastSupertype, getPropertyKind, getPropertyKind, getPropertyKind, getRestrictedTypeGivenOutcome, getTemplateTypeMap, getTypeParameters, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, getUnionMembers, hasAnyTemplateTypes, hasDisplayName, hashCode, hasProperty, hasProperty, isAllType, isArrayType, isBigIntObjectType, isBigIntOrNumber, isBigIntValueType, isBooleanObjectType, isBooleanValueType, isBoxableScalar, isCheckedUnknownType, isConstructor, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isExplicitlyVoidable, isFunctionType, isGlobalThisType, isInstanceType, isInterface, isKnownSymbolValueType, isLiteralObject, isNamedType, isNominalConstructorOrInterface, isNominalType, isNoObjectType, isNoResolvedType, isNoType, isNullable, isNullType, isNumber, isNumberObjectType, isNumberValueType, isObjectType, isOnlyBigInt, isOrdinaryFunction, isRawTypeOfTemplatizedType, isReadonlyArrayType, isRecordType, isRegexpType, isResolved, isSomeUnknownType, isString, isStringObjectType, isStringValueType, isStruct, isStructuralInterface, isSubtype, isSubtype, isSubtypeOf, isSubtypeOf, isSubtypeWithoutStructuralTyping, isSuccessfullyResolved, isSymbol, isSymbolObjectType, isSymbolValueType, isTemplateType, isTemplatizedType, isUnionType, isUnsuccessfullyResolved, isVoidable, isVoidType, loosenTypecheckingDueToForwardReferencedSupertype, mergeSupertypeTemplateTypes, resolve, restrictByNotNull, restrictByNotNullOrUndefined, restrictByNotUndefined, setValidator, toAnnotationString, toMaybeEnumElementType, toMaybeFunctionType, toMaybeFunctionType, toMaybeKnownSymbolType, toMaybeNamedType, toMaybeObjectType, toMaybeRecordType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toObjectType, toString
-
Method Details
-
builder
-
toMaybeEnumType
Description copied from class:JSTypeDowncasts this to an EnumType, or returns null if this is not an EnumType.- Overrides:
toMaybeEnumTypein classJSType
-
getImplicitPrototype
Description copied from class:ObjectTypeGets the implicit prototype (a.k.a. the[[Prototype]]property).- Overrides:
getImplicitPrototypein classPrototypeObjectType
-
getElements
Gets the elements defined on this enum.- Returns:
- the elements' names defined on this enum. The returned set is immutable.
-
defineElement
Defines a new element on this enum.- Parameters:
name- the name of the new elementdefiningNode- theNodethat defines this new element- Returns:
- true iff the new element is added successfully
-
getElementsType
Gets the elements' type, which is a subtype of the enumerated type. -
getEnumeratedTypeOfEnumObject
Gets the enumerated type.- Overrides:
getEnumeratedTypeOfEnumObjectin classObjectType
-
testForEquality
Description copied from class:JSTypeComparesthisandthat.- Overrides:
testForEqualityin classObjectType- Returns:
Tri.TRUEif the comparison of values ofthistype andthatalways succeed (such asundefinedcompared tonull)Tri.FALSEif the comparison of values ofthistype andthatalways fails (such asundefinedcompared tonumber)Tri.UNKNOWNif the comparison can succeed or fail depending on the concrete values
-
getDisplayName
Description copied from class:JSTypeReturns a user meaningful label for the JSType instance. For example, Functions and Enums will return their declaration name (if they have one). Some types will not have a meaningful display name. Calls to hasDisplayName() will return true IFF getDisplayName() will return null or a zero length string.- Overrides:
getDisplayNamein classObjectType- Returns:
- the display name of the type, or null if one is not available
-
visit
Description copied from class:JSTypeVisit this type with the given visitor.- Overrides:
visitin classObjectType- Returns:
- the value returned by the visitor
- See Also:
-
getConstructor
Description copied from class:ObjectTypeGets this object's constructor.- Overrides:
getConstructorin classPrototypeObjectType- Returns:
- this object's constructor or
nullif it is a native object (constructed natively v.s. by instantiation of a function)
-
matchesNumberContext
public boolean matchesNumberContext()Description copied from class:JSTypeThis predicate is used to test whether a given type can appear in a numeric context, such as an operand of a multiply operator.- Overrides:
matchesNumberContextin classPrototypeObjectType
-
matchesStringContext
public boolean matchesStringContext()Description copied from class:JSTypeThis predicate is used to test whether a given type can appear in aStringcontext, such as an operand of a string concat (+) operator. All types have at least the potential for converting toString. When we add externally defined types, such as a browser OM, we may choose to add types that do not automatically convert toString.- Overrides:
matchesStringContextin classPrototypeObjectType
-
matchesObjectContext
public boolean matchesObjectContext()Description copied from class:JSTypeThis predicate is used to test whether a given type can appear in anObjectcontext, such as the expression in a with statement. Most types we will encounter, except notablynull, have at least the potential for converting toObject. Host defined objects can get peculiar.- Overrides:
matchesObjectContextin classPrototypeObjectType
-
getSource
Description copied from interface:JSType.WithSourceRefThe node representing the declaration of this type.- Specified by:
getSourcein interfaceJSType.WithSourceRef
-
getGoogModuleId
Description copied from interface:JSType.WithSourceRefThe ID of the goog.module in which this type was declared.- Specified by:
getGoogModuleIdin interfaceJSType.WithSourceRef
-