Returns an optional for a given value
177057
public static <T> Optional<T> of(T value) {
        return value == null ? (Optional<T>) EMPTY : new Optional<>(value);
    }
1054054
function opt(options, name, defaultValue){
    return options && options[name]!==undefined ? options[name] : defaultValue;
}
1049403
def optional(p, default_value=None):
    '''
    '''
    @Parser
    def optional_parser(text, index):
        res = p(text, index)
        if res.status:
            return Value.success(res.index, res.value)
        else:
            # Return the maybe existing default value without doing anything.
            return Value.success(res.index, default_value)
    return optional_parser
621204
def optional_string(name, default)
      optional_custom(name) do |env|
        if value = env[name.to_s.upcase]
          {name => value}
        else
          {name => default}
        end
      end
    end
174890
public static Optional<Double> toDouble(Object arg) {
        if ( arg instanceof Number ) {
            return Optional.of( ( (Number) arg ).doubleValue() );
        }
        else if(arg instanceof String) {
            Optional<? extends Number> optional = toNumber( arg );
            if ( optional.isPresent() ) {
                return Optional.of( optional.get().doubleValue() );
            }
            else {
                return Optional.empty();
            }
        }
        else {
            return Optional.empty();
        }
    }
1046253
function(value, element, param) {
			return this.optional(element) || this.getLength($.trim(value), element) >= param;
		}
145435
function(value) {
      var args = [].slice.call(arguments, 1);
      if (typeof value === 'function') {
        value = value.apply(null, args);
      }
      return value;
    }
613491
public static <T, S extends T> Optional<T> of(S value) {
    if (value == null) {
      throw new IllegalArgumentException("Optional does not support NULL, use Optional.empty() instead.");
    }

    return new Optional<T>(value);
  }
382678
function getOption(opts, key, def) {
  var value = opts[key];
  return value === undefined ? def : value;
}
824608
public static <T> Optional<T> getValueOptional(Object target, String dPath, Class<T> clazz) {
        return Optional.ofNullable(getValue(target, dPath, clazz));
    }
706738
private Optional<Integer> longToInt(Optional<Long> optLong) {

        if (optLong.isPresent()) {
            return Optional.fromNullable((Integer.valueOf((int)optLong.get().longValue())));
        } else {
            return Optional.absent();
        }
    }
264209
public static <K, V, M extends Map<K, V>> Optional<M> getOptional(M map) {
        return Optional.ofNullable(map).filter(m -> m.size() > 0);
    }
378833
public Optional<Boolean> getBoolean(String key) {
        Objects.requireNonNull(key, Required.KEY.toString());

        String value = this.values.get(key);
        if (StringUtils.isNotBlank(value)) {
            if (("1").equals(value)) {
                return Optional.of(Boolean.TRUE);
            } else if (("true").equals(value)) {
                return Optional.of(Boolean.TRUE);
            } else if (("false").equals(value)) {
                return Optional.of(Boolean.FALSE);
            } else if (("0").equals(value)) {
                return Optional.of(Boolean.FALSE);
            } else {
                // Ignore anything else
            }
        }

        return Optional.empty();
    }
215640
public static <A> Maybe<A> fromOptional(Optional<? extends A> optional) {
        return optional.map(Maybe::<A>just).orElse(Maybe.nothing());
    }
138791
def _py_check_optional(parameter, tab, assign):
    
    if parameter.direction == "(out)":
        result = []
        checks = ["{0}_{1:d}.value==0".format(parameter.lname, i) for i in range(parameter.D)]
        spacing = len(tab) + 2 + 3 + 3 + 2
        result.append("{}if not all([{}]):".format(tab, present_params(checks, spacing, linecont=", ")))
        for line in assign:
            if assign is not None:
                result.append("{0}{1}".format(tab, line))
        result.append("{}else:".format(tab))
        result.append('{0}{0}result.add("{1}", None)'.format(tab, parameter.lname))
        return '\n'.join(result)
    else:
        return '\n'.join(assign)
166045
public static Object toExternalObject( Object value)
    {
    return
      Optional.ofNullable(
        toExternalNumber( value))
      .orElse(
        toObject( String.valueOf( value)));
    }
824460
public Optional<String> value(String path, String key) {
		return Optional.ofNullable(paths.get(path))
				.flatMap(map -> Optional.ofNullable(map.get(key)));
	}