Skip to content

Commit

Permalink
Add Javadocs
Browse files Browse the repository at this point in the history
- Use the result value Args.notNull() to assign instance variable
- Resolves all Javadoc warnings in URIAuthority
  • Loading branch information
garydgregory committed Oct 29, 2024
1 parent 7e507b6 commit a510c68
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 11 deletions.
9 changes: 9 additions & 0 deletions httpcore5/src/main/java/org/apache/hc/core5/net/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ static boolean isPunyCode(final CharSequence s) {
s.charAt(3) == '-';
}

/**
* Constructs a new instance.
*
* @param name The host name, not null.
* @param port The port value, between 0 and 65535, inclusive. {@code -1} indicates the scheme default port.
* @throws NullPointerException if the {@code name} is {@code null}.
* @throws IllegalArgumentException If the port parameter is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
* {@code -1} indicates the scheme default port.
*/
public Host(final String name, final int port) {
super();
Args.notNull(name, "Host name");
Expand Down
70 changes: 59 additions & 11 deletions httpcore5/src/main/java/org/apache/hc/core5/net/URIAuthority.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,38 +91,66 @@ static String format(final URIAuthority uriAuthority) {
/**
* Constructs a new instance.
*
* @throws IllegalArgumentException
* If the port parameter is outside the specified range of valid port values, which is between 0 and
* 65535, inclusive. {@code -1} indicates the scheme default port.
* @param userInfo The user info, may be null.
* @param hostName The host name, not null.
* @param port The port value, between 0 and 65535, inclusive. {@code -1} indicates the scheme default port.
* @throws NullPointerException If the {@code name} is {@code null}.
* @throws IllegalArgumentException If the port is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
* {@code -1} indicates the scheme default port.
*/
public URIAuthority(final String userInfo, final String hostname, final int port) {
public URIAuthority(final String userInfo, final String hostName, final int port) {
super();
this.userInfo = userInfo;
this.host = new Host(hostname, port);
this.host = new Host(hostName, port);
}

public URIAuthority(final String hostname, final int port) {
this(null, hostname, port);
/**
* Constructs a new instance.
*
* @param hostName The host name, not null.
* @param port The port value, between 0 and 65535, inclusive. {@code -1} indicates the scheme default port.
* @throws NullPointerException If the {@code name} is {@code null}.
* @throws IllegalArgumentException If the port is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
* {@code -1} indicates the scheme default port.
*/
public URIAuthority(final String hostName, final int port) {
this(null, hostName, port);
}

/**
* Constructs a new instance.
*
* @param userInfo The user info, may be null.
* @param host The host, never null.
* @throws NullPointerException if the {@code host} is {@code null}.
* @since 5.2
*/
public URIAuthority(final String userInfo, final Host host) {
super();
Args.notNull(host, "Host");
this.host = Args.notNull(host, "Host");
this.userInfo = userInfo;
this.host = host;
}

/**
* Constructs a new instance.
*
* @param host The host, never null.
* @throws NullPointerException if the {@code host} is {@code null}.
* @since 5.2
*/
public URIAuthority(final Host host) {
this(null, host);
}

/**
* Constructs a new instance.
*
* @param userInfo The user info, may be null.
* @param endpoint The named end-point, never null.
* @throws NullPointerException If the end-point is {@code null}.
* @throws NullPointerException If the end-point {@code name} is {@code null}.
* @throws IllegalArgumentException If the end-point port is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
* {@code -1} indicates the scheme default port.
* @since 5.2
*/
public URIAuthority(final String userInfo, final NamedEndpoint endpoint) {
Expand All @@ -132,6 +160,15 @@ public URIAuthority(final String userInfo, final NamedEndpoint endpoint) {
this.host = new Host(endpoint.getHostName(), endpoint.getPort());
}

/**
* Constructs a new instance.
*
* @param namedEndpoint The named end-point, never null.
* @throws NullPointerException If the end-point is {@code null}.
* @throws NullPointerException If the end-point {@code name} is {@code null}.
* @throws IllegalArgumentException If the end-point port is outside the specified range of valid port values, which is between 0 and 65535, inclusive.
* {@code -1} indicates the scheme default port.
*/
public URIAuthority(final NamedEndpoint namedEndpoint) {
this(null, namedEndpoint);
}
Expand All @@ -155,10 +192,21 @@ public static URIAuthority create(final String s) throws URISyntaxException {
return uriAuthority;
}

public URIAuthority(final String hostname) {
this(null, hostname, -1);
/**
* Constructs a new instance.
*
* @param hostName The host name, not null.
* @throws NullPointerException If the {@code name} is {@code null}.
*/
public URIAuthority(final String hostName) {
this(null, hostName, -1);
}

/**
* Gets the user info String.
*
* @return the user info String.
*/
public String getUserInfo() {
return userInfo;
}
Expand Down

0 comments on commit a510c68

Please sign in to comment.