class Ops {

	public static boolean in(TemplateContext ctx, Object o, Object in) {
		if (in == null) {
			return false;
		}

		if (in instanceof LongRange) {
			return ((LongRange) in).in(Types.toLong(ctx, o));
		}

		if (in instanceof DoubleRange) {
			return ((DoubleRange) in).in(Types.toDouble(ctx, o));
		}

		if (in instanceof Map<?, ?>) {
			Map<?, ?> map = (Map<?, ?>) in;
			return map.containsKey(o) || map.containsKey(Types.toString(ctx, o));
		}

		if (Types.isString(ctx, in)) {
			return Types.toString(ctx, in).contains(Types.toString(ctx, o));
		}

		if (in instanceof Iterable<?> || Types.isArray(ctx, in)) {
			Iterator<?> it = Types.toIterator(ctx, in);
			while (it.hasNext()) {
				Object item = it.next();
				if (CompareOps.eq(ctx, o, item)) {
					return true;
				}
			}

			return false;
		}

		return false;
	}

}