Implements fall-back strategy. If the expected type of a collection literal does not match the actual type, but the expected element
types would match the actual element type, the collection literal will be successfully typed according to the expectation.
549830
protected boolean matchesExpectation(LightweightTypeReference elementType, LightweightTypeReference expectation) {
		return expectation != null && expectation.isResolved() && !expectation.isWildcard() && expectation.isAssignableFrom(elementType);
	}
158737
public void assertEqualMappedBy(Function<? super E, ?> expectedMapper, Function<? super A, ?> actualMapper) {
		if (!isEqualMappedBy(expectedMapper, actualMapper)) {
			throwAssertionError();
		}
	}
107742
function (collection, settings, elements, element, oldIndex, newIndex) {
            if (1 === Math.abs(newIndex - oldIndex)) {
                elements = swapElements(collection, elements, oldIndex, newIndex);
                if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                    elements = swapElements(collection, elements, newIndex, oldIndex);
                }
            } else {
                if (oldIndex < newIndex) {
                    elements = swapElementsUp(collection, elements, settings, oldIndex, newIndex);
                    if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                        elements = swapElementsDown(collection, elements, settings, newIndex, oldIndex);
                    }
                } else {
                    elements = swapElementsDown(collection, elements, settings, oldIndex, newIndex);
                    if (!(newIndex - oldIndex > 0 ? trueOrUndefined(settings.after_up(collection, element)) : trueOrUndefined(settings.after_down(collection, element)))) {
                        elements = swapElementsUp(collection, elements, settings, newIndex, oldIndex);
                    }
                }
            }
            dumpCollectionActions(collection, settings, false);

            if (settings.position_field_selector) {
                return doRewritePositions(settings, elements);
            }

            return elements;
        }
388492
private FunctionType matchFunction(
      FunctionType expectedType, FunctionType currentType, boolean declared) {
    if (declared) {
      // If the function was declared but it doesn't have a known "this"
      // but the expected type does, back fill it.
      if (currentType.getTypeOfThis().isUnknownType()
          && !expectedType.getTypeOfThis().isUnknownType()) {
        FunctionType replacement =
            FunctionType.builder(registry)
                .copyFromOtherFunction(currentType)
                .withTypeOfThis(expectedType.getTypeOfThis())
                .build();
         return replacement;
      }
    } else {
      // For now, we just make sure the current type has enough
      // arguments to match the expected type, and return the
      // expected type if it does.
      if (currentType.getMaxArity() <= expectedType.getMaxArity()) {
        return expectedType;
      }
    }
    return currentType;
  }
1298483
protected CollectionMatch selectBestCollectionMatch(CollectionMatch previousMatch, CollectionMatch currentMatch) {

        CollectionMatch bestMatch = null;
        if (previousMatch == null) {
            bestMatch = currentMatch;
        } else if (previousMatch.isDenyMatchByOmission()) {
            bestMatch = previousMatch;
        } else if (currentMatch.isDenyMatchByOmission()) {
            bestMatch = currentMatch;
        } else if (previousMatch.isDenyMatch()) {
            bestMatch = previousMatch;
        } else if (currentMatch.isDenyMatch()) {
            bestMatch = currentMatch;
        } else if (previousMatch.isPermitMatch()) {
            bestMatch = previousMatch;
        } else if (currentMatch.isPermitMatch()) {
            bestMatch = currentMatch;
        } else if (previousMatch.isExactMatch()) {
            bestMatch = previousMatch;
        } else if (currentMatch.isExactMatch()) {
            bestMatch = currentMatch;
        } else if (previousMatch.isPathMatch() && previousMatch.getUrlPattern().length() >= currentMatch.getUrlPattern().length()) {
            bestMatch = previousMatch;
        } else {
            bestMatch = currentMatch;
        }
        return bestMatch;
    }
667998
public static boolean notEmptyCollectionCheck(Object parameter, String error){
        if(parameter == null || (parameter instanceof Collection && ((Collection) parameter).size() == 0)){
            throw new IllegalArgumentException(error);
        }
        return true;
    }
988302
public void selectStrategy() {
		LightweightTypeReference expectedType = expectation.getExpectedType();
		if (expectedType == null) {
			strategy = getClosureWithoutExpectationHelper();
		} else {
			JvmOperation operation = functionTypes.findImplementingOperation(expectedType);
			JvmType type = expectedType.getType();
			int closureParameterSize;
			if (closure.isExplicitSyntax()) {
				closureParameterSize = closure.getDeclaredFormalParameters().size();
			} else if (operation != null) {
				closureParameterSize = operation.getParameters().size();
			} else {
				closureParameterSize = 1;
			}
			if (operation == null || operation.getParameters().size() != closureParameterSize || type == null) {
				strategy = getClosureWithoutExpectationHelper();
			} else {
				strategy = createClosureWithExpectationHelper(operation);
			}
		}
		
	}
801740
@Nonnull
    public static <T> Collection<T> checkNotEmpty(Collection<T> collection, @Nonnull String errorMessage) {
        checkState(collection != null && !collection.isEmpty(), errorMessage);
        return collection;
    }
738435
def assert_in(self, actual_collection_or_string, expected_value, failure_message='Expected "{1}" to be in "{0}"'):
        
        assertion = lambda: expected_value in actual_collection_or_string
        self.webdriver_assert(assertion, unicode(failure_message).format(actual_collection_or_string, expected_value))
191161
private Class getCollectionType()
  {
    Class collectionType = Collection.class;
    IParsedElement parent = getParsedElement().getParent();
    if( parent instanceof NewExpression )
    {
      IType newType = ((NewExpression)parent).getType();
      IJavaClassInfo classInfo = IRTypeResolver.getJavaBackedClass(newType);
      Class javaBackedClass = classInfo != null ? classInfo.getBackingClass() : null;
      if( classInfo != null && javaBackedClass != null )
      {
        collectionType = javaBackedClass;
      }
      else if( JavaTypes.getJreType(AbstractCollection.class).isAssignableFrom( newType ) )
      {
        collectionType = AbstractCollection.class;
      }
    }
    return collectionType;
  }
245065
private void checkListMapType(Field field) {
        Class<?> cls = field.getType();
        boolean needCheckGenericType = false;
        if (List.class.isAssignableFrom(cls)) {
            // if check is list ignore check
            isList = true;
            needCheckGenericType = true;
        }
        if (Map.class.isAssignableFrom(cls)) {
            // if check is list ignore check
            isMap = true;
            needCheckGenericType = true;
        }

        if (!needCheckGenericType) {
            return;
        }

        Type type = field.getGenericType();
        if (type instanceof ParameterizedType) {
            ParameterizedType ptype = (ParameterizedType) type;

            Type[] actualTypeArguments = ptype.getActualTypeArguments();

            if (actualTypeArguments != null) {

                int length = actualTypeArguments.length;
                // validate
                if (isList) {
                    if (length != 1) {
                        throw new RuntimeException(
                                "List must use generic definiation like List<String>, please check  field name '"
                                        + field.getName() + " at class " + field.getDeclaringClass().getName());
                    }
                } else if (isMap) {
                    if (length != 2) {
                        throw new RuntimeException(
                                "Map must use generic definiation like Map<String, String>, please check  field name '"
                                        + field.getName() + " at class " + field.getDeclaringClass().getName());
                    }
                }

                Type targetType = actualTypeArguments[0];
                if (targetType instanceof Class) {
                    genericKeyType = (Class) targetType;
                }

                if (actualTypeArguments.length > 1) {
                    targetType = actualTypeArguments[1];
                    if (targetType instanceof Class) {
                        genericeValueType = (Class) targetType;
                    }
                }

            }
        }

    }
288907
protected LightweightTypeReference createCollectionTypeReference(JvmGenericType collectionType, LightweightTypeReference elementType, LightweightTypeReference expectedType, ITypeReferenceOwner owner) {
		ParameterizedTypeReference result = new ParameterizedTypeReference(owner, collectionType);
		result.addTypeArgument(elementType);
		if (isIterableExpectation(expectedType) && !expectedType.isAssignableFrom(result)) {
			// avoid to assign a set literal to a list and viceversa:
			// at least the raw types must be assignable
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=498779
			if (expectedType.getRawTypeReference().isAssignableFrom(result.getRawTypeReference())) {
				LightweightTypeReference expectedElementType = getElementOrComponentType(expectedType, owner);
				if (matchesExpectation(elementType, expectedElementType)) {
					return expectedType;
				}
			}
		}
		return result;
	}
138054
public boolean assessMatch(final OgnlContext ognlContext) throws OgnlException
	{

		if (! inputRun)
		{
			throw new IllegalArgumentException("Attempted to match on a rule whose rulesets input has not yet been produced");
		}

		final Object result = condition.run(ognlContext, ognlContext);

		if (result == null || !Boolean.class.isAssignableFrom(result.getClass()))
		{
			throw new IllegalArgumentException("Expression " + condition.getOriginalExpression() +
			                                   " did not return a boolean value");
		}

		matches = (Boolean) result;

		return matches;
	}
503479
private <T> void checkFormat(Collection<T> c) {
		Class<?> type = null;
		List<Class<?>> typeList = new ArrayList<Class<?>>();
		Iterator<T> it = c.iterator();
		while (it.hasNext()) {
			Object o = it.next();

			// check the input types for 1-dimension
			if (type != null && !type.equals(o.getClass())) {
				throw new RuntimeException("elements of input list should have the same type");
			}
			else {
				type = o.getClass();
			}

			// check the input types for 2-dimension array
			if (typeList.size() == 0 && o.getClass().isArray()) {
				for (Object s : (Object[]) o) {
					typeList.add(s.getClass());
				}
			}
			else if (o.getClass().isArray()) {
				int index = 0;
				if (((Object[]) o).length != typeList.size()) {
					throw new RuntimeException("elements of input list should have the same size");
				}
				for (Object s : (Object[]) o) {
					if (!s.getClass().equals(typeList.get(index++))) {
						throw new RuntimeException("elements of input list should have the same type");
					}
				}
			}

			// check the input types for 2-dimension collection
			if (typeList.size() == 0 && o instanceof Collection) {
				@SuppressWarnings("unchecked")
				Iterator<Object> tmpIt = ((Collection<Object>) o).iterator();
				while (tmpIt.hasNext()) {
					Object s = tmpIt.next();
					typeList.add(s.getClass());
				}
			}
			else if (o instanceof Collection) {
				int index = 0;
				@SuppressWarnings("unchecked")
				Iterator<Object> tmpIt = ((Collection<Object>) o).iterator();
				while (tmpIt.hasNext()) {
					Object s = tmpIt.next();
					if (!s.getClass().equals(typeList.get(index++))) {
						throw new RuntimeException("elements of input list should have the same type");
					}
				}

				if (index != typeList.size()) {
					throw new RuntimeException("elements of input list should have the same size");
				}
			}
		}
	}
673706
function fallBack(fallback) {
  return computed({
    get() { return fallback; },
    set(_, v) { return v === undefined ? fallback : v; }
  });
}
681828
protected void handleCollectionTypeNotAvailable(XCollectionLiteral literal, ITypeComputationState state, Class<?> clazz) {
		for(XExpression element: literal.getElements()) {
			state.withNonVoidExpectation().computeTypes(element);
		}
		state.acceptActualType(state.getReferenceOwner().newUnknownTypeReference(clazz.getName()));
	}
1069577
public void computeType(XListLiteral literal, ITypeComputationState state) {
		JvmGenericType listType = findDeclaredType(List.class, state);
		if (listType == null) {
			handleCollectionTypeNotAvailable(literal, state, List.class);
			return;
		}
		for(ITypeExpectation expectation: state.getExpectations()) {
			computeType(literal, listType, expectation, state);
		}
	}