All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bitbucket.cowwoc.preconditions.UriPreconditionsImpl Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2013 Gili Tzabari.
 * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
 */
package org.bitbucket.cowwoc.preconditions;

import java.net.URI;
import java.util.Objects;

/**
 * Default implementation of UriPreconditions.
 * 

* @author Gili Tzabari */ final class UriPreconditionsImpl extends AbstractObjectPreconditions implements UriPreconditions { /** * Creates new UriPreconditionsImpl. *

* @param parameter the value of the parameter * @param name the name of the parameter * @param exceptionOverride the type of exception to throw, null to disable the override * @throws NullPointerException if {@code name} is null * @throws IllegalArgumentException if {@code name} is empty */ UriPreconditionsImpl(URI parameter, String name, Class exceptionOverride) { super(parameter, name, exceptionOverride); } @Override public UriPreconditions isAbsolute() throws IllegalArgumentException { if (parameter.isAbsolute()) return this; return throwException(IllegalArgumentException.class, String.format("%s must be absolute.\n" + "Actual: %s", name, parameter)); } @Override public UriPreconditions usingException(Class exceptionOverride) { if (Objects.equals(exceptionOverride, this.exceptionOverride)) return this; return new UriPreconditionsImpl(parameter, name, exceptionOverride); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy