private URL getAsUrl()

in core/src/main/java/org/hibernate/ogm/util/configurationreader/impl/SimplePropertyReaderContext.java [165:200]


	private URL getAsUrl() {
		Object value = getConfiguredValue();
		if ( StringHelper.isNullOrEmptyString( value ) && getDefaultValue() != null ) {
			return (URL) getDefaultValue();
		}
		else if ( value instanceof URL ) {
			return (URL) value;
		}

		boolean useDefault = false;
		if ( StringHelper.isNullOrEmptyString( value ) && getDefaultStringValue() != null ) {
			value = getDefaultStringValue();
			useDefault = true;
		}
		if ( value == null ) {
			return null;
		}

		String stringValue = value.toString().trim();

		URL resource = getFromClassPath( stringValue );

		if ( resource == null ) {
			resource = getFromStringUrl( stringValue );
		}
		if ( resource == null ) {
			resource = getFromFileSystemPath( stringValue );
		}

		// if the resource is explicitly defined by the user, it mustn't be null
		if ( resource == null && !useDefault ) {
			throw log.invalidConfigurationUrl( getPropertyName(), value.toString() );
		}

		return resource;
	}