/** * Checks an argument and throws an exception if null. */ public static <T> T checkNotNull(T argument) throws NullArgumentException { return checkNotNull(argument, null); }
public LocaleString(Locale locale, String value) { this.locale = NullArgumentException.checkNotNull(locale, "locale"); this.value = NullArgumentException.checkNotNull(value, "value"); }
ProtocolOrPortRange(Protocol protocol) { this.protocol = NullArgumentException.checkNotNull(protocol, "protocol"); this.portRange = null; }
/** * Gets the current page index setup by a combined view or <code>null</code> * if not doing a combined view. */ public static PageIndex getCurrentPageIndex(ServletRequest request) { NullArgumentException.checkNotNull(request, "request"); return (PageIndex)request.getAttribute(PAGE_INDEX_REQUEST_ATTRIBUTE_NAME); }
/** * Gets the destination for the given {@link AddressFamily}. */ public InetAddressPrefix getDestination(AddressFamily addressFamily) { NullArgumentException.checkNotNull(addressFamily); switch(addressFamily) { case INET : return destinationIPv4; case INET6 : return destinationIPv6; default : throw new AssertionError(addressFamily); } }
@Override public void addParameter(String name, String value) { NullArgumentException.checkNotNull(name, "name"); NullArgumentException.checkNotNull(value, "value"); List<String> values = map.get(name); if(values==null) map.put(name, values = new ArrayList<String>()); values.add(value); } }
ProtocolOrPortRange(Protocol protocol, IPortRange portRange) { this.protocol = NullArgumentException.checkNotNull(protocol, "protocol"); this.portRange = portRange; assert portRange == null || portRange.getProtocol() == protocol; }
/** * @param destination The destination is {@link InetAddressPrefix#normalize() normalized} */ Target(InetAddressPrefix destination, ProtocolOrPortRange protocolOrPortRange) { this.destination = NullArgumentException.checkNotNull(destination, "destination"); assert destination == destination.normalize(); this.protocolOrPortRange = protocolOrPortRange; }
/** * Parses a protocol value compatible with <code>/etc/protocols</code>. */ static Protocol parseProtocol(String protocol) throws IllegalArgumentException { NullArgumentException.checkNotNull(protocol); // This might need some other type of conversion. Do as-needed. Protocol p = Protocol.getProtocolByKeyword(protocol); if(p == null) throw new IllegalArgumentException("Protocol not found: " + protocol); return p; }
ProtocolOrPortRange(IPortRange portRange) { this.portRange = NullArgumentException.checkNotNull(portRange, "portRange"); this.protocol = portRange.getProtocol(); }
/** * Parses a version number from its string representation. * * @see #toString() */ public static Version valueOf(String version) throws IllegalArgumentException { NullArgumentException.checkNotNull(version, "version"); int dot1Pos = version.indexOf('.'); if(dot1Pos==-1) throw new IllegalArgumentException(version); int dot2Pos = version.indexOf('.', dot1Pos+1); if(dot2Pos==-1) throw new IllegalArgumentException(version); int dot3Pos = version.indexOf('.', dot2Pos+1); if(dot3Pos==-1) throw new IllegalArgumentException(version); return getInstance( Integer.parseInt(version.substring(0, dot1Pos)), Integer.parseInt(version.substring(dot1Pos+1, dot2Pos)), Integer.parseInt(version.substring(dot2Pos+1, dot3Pos)), Integer.parseInt(version.substring(dot3Pos+1)) ); }
public void setCapturedPage(Page capturedPage) { NullArgumentException.checkNotNull(capturedPage, "page"); if(this.capturedPage != null) { throw new IllegalStateException( "Cannot capture more than one page: first page=" + this.capturedPage.getPageRef() + ", second page=" + capturedPage.getPageRef() ); } this.capturedPage = capturedPage; }
/** * @param destination The destination is {@link InetAddressPrefix#normalize() normalized} */ public Target(InetAddressPrefix destination, IPortRange portRange) { this.destination = NullArgumentException.checkNotNull(destination, "destination").normalize(); this.protocolOrPortRange = new ProtocolOrPortRange(portRange); }
/** * @param destination The destination is {@link InetAddressPrefix#normalize() normalized} */ public Target(InetAddressPrefix destination, Protocol protocol) { this.destination = NullArgumentException.checkNotNull(destination, "destination").normalize(); this.protocolOrPortRange = new ProtocolOrPortRange(protocol); }
&& !relativeUrlPath.startsWith("cid:") ) { NullArgumentException.checkNotNull(servletPath, "servletPath"); int slashPos = servletPath.lastIndexOf('/'); if(slashPos==-1) throw new MalformedURLException("No slash found in servlet path: "+servletPath);
LinuxGroup getPrimaryGroup(LinuxAccount account) throws IOException, SQLException { NullArgumentException.checkNotNull(account, "account"); synchronized(primaryHash) {
InetAddressPrefix destinationIPv6 ) { this.name = NullArgumentException.checkNotNull(name, "name"); this.version = version==null || version.isEmpty() ? null : version; this.shortName = shortName==null || shortName.isEmpty() ? null : shortName;
NullArgumentException.checkNotNull(path, "path"); if(path.isEmpty()) throw new IllegalArgumentException("path is empty"); SemanticCMS semanticCMS = SemanticCMS.getInstance(servletContext);
Cache cache ) throws ServletException, IOException { NullArgumentException.checkNotNull(level, "level"); PageRef pageRef = pageReferrer.getPageRef();