List of usage examples for com.google.common.collect MapConstraints constrainedBiMap
public static <K, V> BiMap<K, V> constrainedBiMap(BiMap<K, V> map, MapConstraint<? super K, ? super V> constraint)
From source file:org.sonatype.plugin.nexus.testenvironment.AbstractEnvironmentMojo.java
@SuppressWarnings("unchecked") private void validateStaticPorts() throws MojoExecutionException, MojoFailureException { if (this.staticPorts != null) { try {/*w w w.j a v a 2s .co m*/ @SuppressWarnings("rawtypes") BiMap staticPortMap = HashBiMap.create(this.staticPorts.size()); staticPortMap = MapConstraints.constrainedBiMap(staticPortMap, MapConstraints.notNull()); staticPortMap.putAll(this.staticPorts); this.staticPorts = staticPortMap; } catch (NullPointerException npe) { throw new MojoExecutionException("Port names and values must not be null.", npe); } catch (IllegalArgumentException iae) { throw new MojoExecutionException("Port names and values must not be duplicated.", iae); } } }