If the value is null, return the defaultValue.
Otherwise return the new value.
766264
public static String getStringValue(Object newValue, String defaultValue) {
        if (newValue == null)
            return defaultValue;

        return (String) newValue;
    }
580014
public static String stringOrDefault(String str, String defaultValue) {
		if(isStringValued(str)) return str;
		return defaultValue;
	}
1112526
public static AllowableValues emptyToNull(AllowableValues newValue, AllowableValues current) {
    if (newValue != null) {
      if (newValue instanceof AllowableListValues) {
        return defaultIfAbsent(emptyListValuesToNull((AllowableListValues) newValue), current);
      } else {
        return defaultIfAbsent(newValue, current);
      }
    }
    return current;
  }
1287780
public T orElse(T defaultValue) {
        T value = get();

        if (value != null) {
            return value;
        }

        return defaultValue;
    }
1139823
@Nullable
  public static <T> T defaultValue(Class<T> type) {
    // Primitives.wrap(type).cast(...) would avoid the warning, but we can't use that from here
    @SuppressWarnings("unchecked") // the put method enforces this key-value relationship
    T t = (T) DEFAULTS.get(checkNotNull(type));
    return t;
  }
892472
public Option defaultValue(String defaultValue) throws RequiredParametersException {
		if (this.choices.isEmpty()) {
			return this.setDefaultValue(defaultValue);
		} else {
			if (this.choices.contains(defaultValue)) {
				return this.setDefaultValue(defaultValue);
			} else {
				throw new RequiredParametersException("Default value " + defaultValue +
						" is not in the list of valid values for option " + this.longName);
			}
		}
	}
810958
private String ifEmptyUseDefault(String firstValue, String defaultValue) {
        return StringUtils.ifEmpty(firstValue, defaultValue);
    }
256764
private String getDefaultValue(GroovySourceAST t) {
        GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
        if (t.getNumberOfChildren() != 4) return null;
        for (int i = 1; i < t.getNumberOfChildren(); i++) {
            child = (GroovySourceAST) child.getNextSibling();
        }
        GroovySourceAST nodeToProcess = child;
        if (child.getType() != ANNOTATION_ARRAY_INIT && child.getNumberOfChildren() > 0) {
            nodeToProcess = (GroovySourceAST) child.getFirstChild();
        }
        return getChildTextFromSource(nodeToProcess, ";");
    }
312711
public AnnotationValue defaultValue() {
        return (sym.defaultValue == null)
               ? null
               : new AnnotationValueImpl(env, sym.defaultValue);
    }
283577
public static String getStringValue(String key, String defaultValue) {
        return getStringValue(null, key, defaultValue);
    }
306201
def to_float_with_default(value, default_value):
        
        result = FloatConverter.to_nullable_float(value)
        return result if result != None else default_value
62340
public static DefaultValueFunction defaultValue(Function function, Object defaultValue) {

		Assert.notNull(function, "Function must not be 'null' for default value operation.");
		Assert.notNull(defaultValue, "DefaultValue must not be 'null'.");

		return new DefaultValueFunction(function, defaultValue);
	}
363675
public boolean get(boolean defaultValue)
    {
        final String value =
            getInternal(
                Boolean.toString(defaultValue),
                false);
        if (value == null) {
            return defaultValue;
        }
        return toBoolean(value);
    }
1336707
public Optional<Object> getDefaultValue() {
        Validate.notNull(parameter, "parameter must not be null!");
        if (parameter instanceof AbstractSerializableParameter) {
            AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter;
            return Optional.ofNullable(serializableParameter.getDefaultValue());
        }
        return Optional.empty();
    }
436443
public function getValueByPathOrDefaultValue($path, $defaultValue)
    {
        $value = $this->getValueByPath($path);
        if (is_null($value)) {
            return $defaultValue;
        }

        return $value;
    }
126846
public String get(String key, String defaultValue) {
        String v = get(key);
        if (v==null)    v=defaultValue;
        return v;
    }
1367800
def GetDefault(self, fd=None, default=None):
    """"""
    if callable(self.default):
      return self.default(fd)

    if self.default is not None:
      # We can't return mutable objects here or the default might change for all
      # objects of this class.
      if isinstance(self.default, rdfvalue.RDFValue):
        default = self.default.Copy()
        default.attribute_instance = self
        return self(default)
      else:
        return self(self.default)

    if isinstance(default, rdfvalue.RDFValue):
      default = default.Copy()
      default.attribute_instance = self

    return default