Debian Codegraph @

net/sf/saxon/type/Type.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.type;
9
10 import net.sf.saxon.Configuration;
11 import net.sf.saxon.expr.parser.Token;
12 import net.sf.saxon.ma.arrays.ArrayItem;
13 import net.sf.saxon.ma.arrays.ArrayItemType;
14 import net.sf.saxon.ma.map.MapItem;
15 import net.sf.saxon.ma.map.MapType;
16 import net.sf.saxon.om.*;
17 import net.sf.saxon.pattern.*;
18 import net.sf.saxon.tree.iter.AxisIterator;
19 import net.sf.saxon.value.*;
20
21
22 /**
23 * This class contains static information about types and methods for constructing type codes.
24 * The class is never instantiated.
25 * <p><i>The constant integers used for type names in earlier versions of this class have been replaced
26 * by constants in {@link StandardNames}. The constants representing {@link AtomicType} objects are now
27 * available through the {@link BuiltInAtomicType} class.</i></p>
28 */
29
30 public abstract class Type {
31
32 // Note that the integer codes representing node kinds are the same as
33 // the codes allocated in the DOM interface, while the codes for built-in
34 // atomic types are fingerprints allocated in StandardNames. These two sets of
35 // codes must not overlap!
36
37 /**
38 * Type representing an element node - element()
39 */
40
41 public static final short ELEMENT = 1;
42 /**
43 * Item type representing an attribute node - attribute()
44 */
45 public static final short ATTRIBUTE = 2;
46 /**
47 * Item type representing a text node - text()
48 */
49 public static final short TEXT = 3;
50 /**
51 * Item type representing a text node stored in the tiny tree as compressed whitespace
52 */
53 public static final short WHITESPACE_TEXT = 4;
54 /**
55 * Item type representing a processing-instruction node
56 */
57 public static final short PROCESSING_INSTRUCTION = 7;
58 /**
59 * Item type representing a comment node
60 */
61 public static final short COMMENT = 8;
62 /**
63 * Item type representing a document node
64 */
65 public static final short DOCUMENT = 9;
66 /**
67 * Item type representing a namespace node
68 */
69 public static final short NAMESPACE = 13;
70 /**
71 * Dummy node kind used in the tiny tree to mark the end of the tree
72 */
73 public static final short STOPPER = 11;
74 /**
75 * Dummy node kind used in the tiny tree to contain a parent pointer
76 */
77 public static final short PARENT_POINTER = 12;
78 /**
79 * Node kind used in the tiny tree to represent an element node having simple text content
80 */
81 public static final short TEXTUAL_ELEMENT = 17; // Chosen so kind & 0x0f = Type.ELEMENT
82 /**
83 * Item type representing an external element node grafted into the tiny tree
84 */
85 public static final short EXTERNAL_NODE_REFERENCE = 33; // Chosen so kind & 0x0f = Type.ELEMENT
86 /**
87 * An item type that matches any node
88 */
89
90 public static final short NODE = 0;
91
92 public static final ItemType NODE_TYPE = AnyNodeTest.getInstance();
93
94 /**
95 * An item type that matches any item
96 */
97
98 public static final short ITEM = 88;
99
100 /*@NotNull*/ public static final ItemType ITEM_TYPE = AnyItemType.getInstance();
101
102 /**
103 * A type number for function()
104 */
105
106 public static final short FUNCTION = 99;
107
108
109 private Type() {
110 }
111
112 /**
113 * Test whether a given type is (some subtype of) node()
114 *
115 * @param type The type to be tested
116 * @return true if the item type is node() or a subtype of node()
117 */
118
119 public static boolean isNodeType(ItemType type) {
120 return type instanceof NodeTest;
121 }
122
123 /**
124 * Get the ItemType of an Item. This method is used almost entirely for diagnostics, to report
125 * the actual type of an item when it differs from the required type. The actual result is
126 * not completely well-defined, since there are many item types that a given type conforms
127 * to, and it is not always the case that one of them is a subtype of all the others.
128 *
129 * @param item the item whose type is required
130 * @param th the type hierarchy cache. If null, the returned type may be less precise
131 * @return the item type of the item
132 */
133
134 /*@NotNull*/
135 public static ItemType getItemType(/*@NotNull*/ Item item, /*@Nullable*/ TypeHierarchy th) {
136 if (item == null) {
137 return AnyItemType.getInstance();
138 } else if (item instanceof AtomicValue) {
139 return ((AtomicValue) item).getItemType();
140 } else if (item instanceof NodeInfo) {
141 NodeInfo node = (NodeInfo) item;
142 if (th == null) {
143 th = node.getConfiguration().getTypeHierarchy();
144 }
145 switch (node.getNodeKind()) {
146 case Type.DOCUMENT:
147 // Need to know whether the document is well-formed and if so what the element type is
148 AxisIterator iter = node.iterateAxis(AxisInfo.CHILD);
149 ItemType elementType = null;
150 while (true) {
151 NodeInfo n = iter.next();
152 if (n == null) {
153 break;
154 }
155 int kind = n.getNodeKind();
156 if (kind == Type.TEXT) {
157 elementType = null;
158 break;
159 } else if (kind == Type.ELEMENT) {
160 if (elementType != null) {
161 elementType = null;
162 break;
163 }
164 elementType = Type.getItemType(n, th);
165 }
166 }
167 if (elementType == null) {
168 return NodeKindTest.DOCUMENT;
169 } else {
170 return new DocumentNodeTest((NodeTest) elementType);
171 }
172
173 case Type.ELEMENT:
174 SchemaType eltype = node.getSchemaType();
175 if (eltype.equals(Untyped.getInstance()) || eltype.equals(AnyType.getInstance())) {
176 return new SameNameTest(node);
177 } else {
178 return new CombinedNodeTest(
179 new SameNameTest(node),
180 Token.INTERSECT,
181 new ContentTypeTest(Type.ELEMENT, eltype, node.getConfiguration(), false));
182 }
183
184 case Type.ATTRIBUTE:
185 SchemaType attype = node.getSchemaType();
186 if (attype.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) {
187 return new SameNameTest(node);
188 } else {
189 return new CombinedNodeTest(
190 new SameNameTest(node),
191 Token.INTERSECT,
192 new ContentTypeTest(Type.ATTRIBUTE, attype, node.getConfiguration(), false));
193 }
194
195 case Type.TEXT:
196 return NodeKindTest.TEXT;
197
198 case Type.COMMENT:
199 return NodeKindTest.COMMENT;
200
201 case Type.PROCESSING_INSTRUCTION:
202 return NodeKindTest.PROCESSING_INSTRUCTION;
203
204 case Type.NAMESPACE:
205 return NodeKindTest.NAMESPACE;
206
207 default:
208 throw new IllegalArgumentException("Unknown node kind " + node.getNodeKind());
209 }
210 } else if (item instanceof ExternalObject) {
211 return ((ExternalObject) item).getItemType(th);
212 } else if (item instanceof MapItem) {
213 return ((MapItem)item).getItemType(th);
214 } else if (item instanceof ArrayItem) {
215 return new ArrayItemType(((ArrayItem) item).getMemberType(th));
216 } else { //if (item instanceof FunctionItem) {
217 return ((Function) item).getFunctionItemType();
218 }
219 }
220
221
222 /**
223 * Output (for diagnostics) a representation of the type of an item. This
224 * does not have to be the most specific type
225 *
226 * @param item the item whose type is to be displayed
227 * @return a string representation of the type of the item
228 */
229
230 public static String displayTypeName(/*@NotNull*/ Item item) {
231 if (item instanceof NodeInfo) {
232 NodeInfo node = (NodeInfo) item;
233 switch (node.getNodeKind()) {
234 case DOCUMENT:
235 return "document-node()";
236 case ELEMENT:
237 SchemaType annotation = node.getSchemaType();
238 return "element(" +
239 ((NodeInfo) item).getDisplayName() + ", " +
240 annotation.getDisplayName() + ')';
241 case ATTRIBUTE:
242 SchemaType annotation2 = node.getSchemaType();
243 return "attribute(" +
244 ((NodeInfo) item).getDisplayName() + ", " +
245 annotation2.getDisplayName() + ')';
246 case TEXT:
247 return "text()";
248 case COMMENT:
249 return "comment()";
250 case PROCESSING_INSTRUCTION:
251 return "processing-instruction()";
252 case NAMESPACE:
253 return "namespace()";
254 default:
255 return "";
256 }
257 } else if (item instanceof ExternalObject) {
258 return ObjectValue.displayTypeName(((ExternalObject) item).getObject());
259 } else if (item instanceof AtomicValue) {
260 return ((AtomicValue) item).getItemType().toString();
261 } else if (item instanceof Function) {
262 return "function(*)";
263 } else {
264 return item.getClass().toString();
265 }
266 }
267
268 /**
269 * Get the ItemType object for a built-in atomic or list type
270 *
271 * @param namespace the namespace URI of the type
272 * @param localName the local name of the type
273 * @return the ItemType, or null if not found
274 */
275
276 /*@Nullable*/
277 public static ItemType getBuiltInItemType(String namespace, String localName) {
278 SchemaType t = BuiltInType.getSchemaType(
279 StandardNames.getFingerprint(namespace, localName));
280 if (t instanceof ItemType) {
281 return (ItemType) t;
282 } else {
283 return null;
284 }
285 }
286
287 /**
288 * Get the SimpleType object for a built-in simple type (atomic type or list type)
289 *
290 * @param namespace the namespace URI of the type
291 * @param localName the local name of the type
292 * @return the SimpleType, or null if not found
293 */
294
295 /*@Nullable*/
296 public static SimpleType getBuiltInSimpleType(String namespace, String localName) {
297 SchemaType t = BuiltInType.getSchemaType(
298 StandardNames.getFingerprint(namespace, localName));
299 if (t instanceof SimpleType && ((SimpleType) t).isBuiltInType()) {
300 return (SimpleType) t;
301 } else {
302 return null;
303 }
304 }
305
306 /**
307 * Determine whether one atomic type is a subtype of another (without access to the TypeHierarchy object)
308 * @param one the first atomic type
309 * @param two the second atomic type
310 * @return true if the first atomic type is equal to, or derived by restriction from, the second atomic
311 * type
312 */
313
314 public static boolean isSubType(AtomicType one, AtomicType two) {
315 while (true) {
316 if (one.getFingerprint() == two.getFingerprint()) {
317 return true;
318 }
319 SchemaType s = one.getBaseType();
320 if (s instanceof AtomicType) {
321 one = (AtomicType)s;
322 } else {
323 return false;
324 }
325 }
326 }
327
328 /**
329 * Get a type that is a common supertype of two given item types
330 *
331 * @param t1 the first item type
332 * @param t2 the second item type
333 * @param th the type hierarchy cache
334 * @return the item type that is a supertype of both
335 * the supplied item types
336 */
337
338 /*@NotNull*/
339 public static ItemType getCommonSuperType(ItemType t1, ItemType t2, TypeHierarchy th) {
340 if (t1 == t2) {
341 return t1;
342 }
343 if (t1 instanceof ErrorType) {
344 return t2;
345 }
346 if (t2 instanceof ErrorType) {
347 return t1;
348 }
349 if (t1 instanceof JavaExternalObjectType && t2 instanceof JavaExternalObjectType) {
350 Configuration config = ((JavaExternalObjectType) t1).getConfiguration();
351 Class c1 = ((JavaExternalObjectType) t1).getJavaClass();
352 Class c2 = ((JavaExternalObjectType) t2).getJavaClass();
353 return config.getJavaExternalObjectType(leastCommonSuperClass(c1, c2));
354 }
355 if (t1 instanceof MapType && t2 instanceof MapType) {
356 if (t1 == MapType.EMPTY_MAP_TYPE) {
357 return t2;
358 }
359 if (t2 == MapType.EMPTY_MAP_TYPE) {
360 return t1;
361 }
362 ItemType keyType = getCommonSuperType(((MapType) t1).getKeyType(), ((MapType)t2).getKeyType());
363 AtomicType k;
364 if (keyType instanceof AtomicType) {
365 k = (AtomicType)keyType;
366 } else {
367 k = keyType.getAtomizedItemType().getPrimitiveItemType();
368 }
369 SequenceType v = SequenceType.makeSequenceType(
370 getCommonSuperType(((MapType) t1).getValueType().getPrimaryType(), ((MapType) t2).getValueType().getPrimaryType()),
371 Cardinality.union(((MapType) t1).getValueType().getCardinality(), ((MapType) t2).getValueType().getCardinality()));
372 return new MapType(k, v);
373 }
374 int r = th.relationship(t1, t2);
375 if (r == TypeHierarchy.SAME_TYPE) {
376 return t1;
377 } else if (r == TypeHierarchy.SUBSUMED_BY) {
378 return t2;
379 } else if (r == TypeHierarchy.SUBSUMES) {
380 return t1;
381 } else {
382 return t1.getUType().union(t2.getUType()).toItemType();
383 }
384 }
385
386 /**
387 * Get a type that is a common supertype of two given item types, without the benefit of a TypeHierarchy cache.
388 * This will generally give a less precise answer than the method {@link #getCommonSuperType(ItemType, ItemType, TypeHierarchy)}
389 *
390 * @param t1 the first item type
391 * @param t2 the second item type
392 * @return an item type that is a supertype of both the supplied item types
393 */
394
395 /*@NotNull*/
396 public static ItemType getCommonSuperType(/*@NotNull*/ ItemType t1, /*@NotNull*/ ItemType t2) {
397 if (t1 == t2) {
398 return t1;
399 }
400 if (t1 instanceof ErrorType) {
401 return t2;
402 }
403 if (t2 instanceof ErrorType) {
404 return t1;
405 }
406 if (t1 == AnyItemType.getInstance() || t2 == AnyItemType.getInstance()) {
407 return AnyItemType.getInstance();
408 }
409 ItemType p1 = t1.getPrimitiveItemType();
410 ItemType p2 = t2.getPrimitiveItemType();
411 if (p1 == p2) {
412 return p1;
413 }
414 if ((p1 == BuiltInAtomicType.DECIMAL && p2 == BuiltInAtomicType.INTEGER) ||
415 (p2 == BuiltInAtomicType.DECIMAL && p1 == BuiltInAtomicType.INTEGER)) {
416 return BuiltInAtomicType.DECIMAL;
417 }
418 if (p1 instanceof BuiltInAtomicType && ((BuiltInAtomicType) p1).isNumericType() &&
419 p2 instanceof BuiltInAtomicType && ((BuiltInAtomicType) p2).isNumericType()) {
420 return NumericType.getInstance();
421 }
422 if (t1.isAtomicType() && t2.isAtomicType()) {
423 return BuiltInAtomicType.ANY_ATOMIC;
424 }
425 if (t1 instanceof NodeTest && t2 instanceof NodeTest) {
426 return AnyNodeTest.getInstance();
427 }
428 if (t1 instanceof JavaExternalObjectType && t2 instanceof JavaExternalObjectType) {
429 Configuration config = ((JavaExternalObjectType) t1).getConfiguration();
430 Class c1 = ((JavaExternalObjectType) t1).getJavaClass();
431 Class c2 = ((JavaExternalObjectType) t2).getJavaClass();
432 return config.getJavaExternalObjectType(leastCommonSuperClass(c1, c2));
433 }
434 return AnyItemType.getInstance();
435
436 // Note: for function items, the result is always AnyFunctionType, since all functions have the same primitive type
437
438 }
439
440 public static SequenceType getCommonSuperType(SequenceType t1, SequenceType t2) {
441 if (t1.equals(t2)) {
442 return t1;
443 } else {
444 return SequenceType.makeSequenceType(getCommonSuperType(t1.getPrimaryType(), t2.getPrimaryType()),
445 Cardinality.union(t1.getCardinality(), t2.getCardinality()));
446 }
447 }
448
449 private static Class<?> leastCommonSuperClass(Class<?> class1, Class<?> class2) {
450 if (class1 == class2) {
451 return class1;
452 }
453 if (class1 == null || class2 == null) {
454 return null;
455 }
456 if (!class1.isArray() && class1.isAssignableFrom(class2)) {
457 return class1;
458 }
459 if (!class2.isArray() && class2.isAssignableFrom(class1)) {
460 return class2;
461 }
462 if (class1.isInterface() || class2.isInterface()) {
463 return Object.class;
464 }
465 return leastCommonSuperClass(class1.getSuperclass(), class2.getSuperclass());
466 }
467
468
469 /**
470 * Determine whether a given atomic type is a primitive type. The primitive types are
471 * the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration;
472 * xs:untypedAtomic; the 7 node kinds; and all supertypes of these (item(), node(), xs:anyAtomicType,
473 * xs:numeric, ...)
474 *
475 * @param fingerprint the item type code to be tested
476 * @return true if the type is considered primitive under the above rules
477 */
478 public static boolean isPrimitiveAtomicType(int fingerprint) {
479 return fingerprint >= 0 && (fingerprint <= StandardNames.XS_INTEGER ||
480 fingerprint == StandardNames.XS_NUMERIC ||
481 fingerprint == StandardNames.XS_UNTYPED_ATOMIC ||
482 fingerprint == StandardNames.XS_ANY_ATOMIC_TYPE ||
483 fingerprint == StandardNames.XS_DAY_TIME_DURATION ||
484 fingerprint == StandardNames.XS_YEAR_MONTH_DURATION ||
485 fingerprint == StandardNames.XS_ANY_SIMPLE_TYPE);
486 }
487
488 /**
489 * Determine whether this type is a type that corresponds exactly to a UType
490 *
491 * @param fingerprint the item type code to be tested
492 * @return true if the type is considered primitive under the above rules
493 */
494 public static boolean isPrimitiveAtomicUType(int fingerprint) {
495 return fingerprint >= 0 && fingerprint <= StandardNames.XS_INTEGER;
496 }
497
498 /**
499 * Determine whether two primitive atomic types are comparable under the rules for ValueComparisons
500 * (that is, untyped atomic values treated as strings)
501 *
502 * @param t1 the first type to compared.
503 * This must be a primitive atomic type as defined by {@link ItemType#getPrimitiveType}
504 * @param t2 the second type to compared.
505 * This must be a primitive atomic type as defined by {@link ItemType#getPrimitiveType}
506 * @param ordered true if testing for an ordering comparison (lt, gt, le, ge). False
507 * if testing for an equality comparison (eq, ne)
508 * @return true if the types are comparable, as defined by the rules of the "eq" operator; false if they
509 * are not comparable, or if we don't yet know (because some subtypes of the static type are comparable
510 * and others are not)
511 */
512
513 public static boolean isGuaranteedComparable(/*@NotNull*/ BuiltInAtomicType t1, /*@NotNull*/ BuiltInAtomicType t2, boolean ordered) {
514 if (t1 == t2) {
515 return true; // short cut
516 }
517 if (t1.isPrimitiveNumeric()) {
518 return t2.isPrimitiveNumeric();
519 }
520 if (t1.equals(BuiltInAtomicType.UNTYPED_ATOMIC) || t1.equals(BuiltInAtomicType.ANY_URI)) {
521 t1 = BuiltInAtomicType.STRING;
522 }
523 if (t2.equals(BuiltInAtomicType.UNTYPED_ATOMIC) || t2.equals(BuiltInAtomicType.ANY_URI)) {
524 t2 = BuiltInAtomicType.STRING;
525 }
526
527 if (!ordered) {
528 if (t1.equals(BuiltInAtomicType.DAY_TIME_DURATION)) {
529 t1 = BuiltInAtomicType.DURATION;
530 }
531 if (t2.equals(BuiltInAtomicType.DAY_TIME_DURATION)) {
532 t2 = BuiltInAtomicType.DURATION;
533 }
534 if (t1.equals(BuiltInAtomicType.YEAR_MONTH_DURATION)) {
535 t1 = BuiltInAtomicType.DURATION;
536 }
537 if (t2.equals(BuiltInAtomicType.YEAR_MONTH_DURATION)) {
538 t2 = BuiltInAtomicType.DURATION;
539 }
540 }
541 return t1 == t2;
542 }
543
544 /**
545 * Determine whether two primitive atomic types are comparable under the rules for ValueComparisons
546 * (that is, untyped atomic values treated as strings)
547 *
548 * @param t1 the first type to compared.
549 * This must be a primitive atomic type as defined by {@link ItemType#getPrimitiveType}
550 * @param t2 the second type to compared.
551 * This must be a primitive atomic type as defined by {@link ItemType#getPrimitiveType}
552 * @param ordered true if testing for an ordering comparison (lt, gt, le, ge). False
553 * if testing for an equality comparison (eq, ne)
554 * @return true if the types are guaranteed comparable, as defined by the rules of the "eq" operator,
555 * or if we don't yet know (because some subtypes of the static type are comparable
556 * and others are not). False if they are definitely not comparable.
557 */
558
559 public static boolean isPossiblyComparable(/*@NotNull*/ BuiltInAtomicType t1, /*@NotNull*/ BuiltInAtomicType t2, boolean ordered) {
560 if (t1 == t2) {
561 return true; // short cut
562 }
563 if (t1.equals(BuiltInAtomicType.ANY_ATOMIC) || t2.equals(BuiltInAtomicType.ANY_ATOMIC)) {
564 return true; // meaning we don't actually know at this stage
565 }
566 if (t1.isPrimitiveNumeric()) {
567 return t2.isPrimitiveNumeric();
568 }
569 if (t1.equals(BuiltInAtomicType.UNTYPED_ATOMIC) || t1.equals(BuiltInAtomicType.ANY_URI)) {
570 t1 = BuiltInAtomicType.STRING;
571 }
572 if (t2.equals(BuiltInAtomicType.UNTYPED_ATOMIC) || t2.equals(BuiltInAtomicType.ANY_URI)) {
573 t2 = BuiltInAtomicType.STRING;
574 }
575 if (t1.equals(BuiltInAtomicType.DAY_TIME_DURATION)) {
576 t1 = BuiltInAtomicType.DURATION;
577 }
578 if (t2.equals(BuiltInAtomicType.DAY_TIME_DURATION)) {
579 t2 = BuiltInAtomicType.DURATION;
580 }
581 if (t1.equals(BuiltInAtomicType.YEAR_MONTH_DURATION)) {
582 t1 = BuiltInAtomicType.DURATION;
583 }
584 if (t2.equals(BuiltInAtomicType.YEAR_MONTH_DURATION)) {
585 t2 = BuiltInAtomicType.DURATION;
586 }
587 return t1 == t2;
588 }
589
590
591 /**
592 * Determine whether two primitive atomic types are comparable under the rules for GeneralComparisons
593 * (that is, untyped atomic values treated as comparable to anything)
594 *
595 * @param t1 the first type to compared.
596 * This must be a primitive atomic type as defined by {@link ItemType#getPrimitiveType}
597 * @param t2 the second type to compared.
598 * This must be a primitive atomic type as defined by {@link ItemType#getPrimitiveType}
599 * @param ordered true if testing for an ordering comparison (lt, gt, le, ge). False
600 * if testing for an equality comparison (eq, ne)
601 * @return true if the types are comparable, as defined by the rules of the "=" operator
602 */
603
604 public static boolean isGenerallyComparable(/*@NotNull*/ BuiltInAtomicType t1, /*@NotNull*/ BuiltInAtomicType t2, boolean ordered) {
605 return t1.equals(BuiltInAtomicType.ANY_ATOMIC)
606 || t2.equals(BuiltInAtomicType.ANY_ATOMIC)
607 || t1.equals(BuiltInAtomicType.UNTYPED_ATOMIC)
608 || t2.equals(BuiltInAtomicType.UNTYPED_ATOMIC)
609 || isGuaranteedComparable(t1, t2, ordered);
610 }
611
612 /**
613 * Determine whether two primitive atomic types are guaranteed comparable under the rules for GeneralComparisons
614 * (that is, untyped atomic values treated as comparable to anything). This method returns false if a run-time
615 * check is necessary.
616 *
617 * @param t1 the first type to compared.
618 * This must be a primitive atomic type as defined by {@link ItemType#getPrimitiveType}
619 * @param t2 the second type to compared.
620 * This must be a primitive atomic type as defined by {@link ItemType#getPrimitiveType}
621 * @param ordered true if testing for an ordering comparison (lt, gt, le, ge). False
622 * if testing for an equality comparison (eq, ne)
623 * @return true if the types are comparable, as defined by the rules of the "=" operator
624 */
625
626 public static boolean isGuaranteedGenerallyComparable(/*@NotNull*/ BuiltInAtomicType t1, /*@NotNull*/ BuiltInAtomicType t2, boolean ordered) {
627 return !(t1.equals(BuiltInAtomicType.ANY_ATOMIC) || t2.equals(BuiltInAtomicType.ANY_ATOMIC))
628 && isGenerallyComparable(t1, t2, ordered);
629 }
630
631
632 }
633