1
0
mirror of https://github.com/Rogiel/httpchannel synced 2025-12-06 07:32:50 +00:00

Adds service implementation documentation

This commit is contained in:
2012-01-18 17:13:36 -02:00
parent f8d5303f70
commit 35e2c2fc56
22 changed files with 754 additions and 11 deletions

View File

@@ -82,6 +82,25 @@ public interface Authenticator<C extends AuthenticatorConfiguration> {
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface AuthenticatorConfiguration {
/**
* Checks whether the configuration object can be casted to
* <code>type</code>
*
* @param type
* the casting type
* @return <code>true</code> if this object can be casted to
* <code>type</code>
*/
boolean is(Class<? extends AuthenticatorConfiguration> type);
/**
* Casts this object to <code>type</code>. If cannot be casted,
* <code>null</code> is returned.
*
* @param type
* the casting type
* @return the casted configuration
*/
<T extends AuthenticatorConfiguration> T as(Class<T> type);
}
}

View File

@@ -208,6 +208,25 @@ public interface Downloader<C extends DownloaderConfiguration> {
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface DownloaderConfiguration {
/**
* Checks whether the configuration object can be casted to
* <code>type</code>
*
* @param type
* the casting type
* @return <code>true</code> if this object can be casted to
* <code>type</code>
*/
boolean is(Class<? extends DownloaderConfiguration> type);
/**
* Casts this object to <code>type</code>. If cannot be casted,
* <code>null</code> is returned.
*
* @param type
* the casting type
* @return the casted configuration
*/
<T extends DownloaderConfiguration> T as(Class<T> type);
}
}

View File

@@ -80,6 +80,26 @@ public interface Uploader<C extends UploaderConfiguration> {
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface UploaderConfiguration {
/**
* Checks whether the configuration object can be casted to
* <code>type</code>
*
* @param type
* the casting type
* @return <code>true</code> if this object can be casted to
* <code>type</code>
*/
boolean is(Class<? extends UploaderConfiguration> type);
/**
* Casts this object to <code>type</code>. If cannot be casted,
* <code>null</code> is returned.
*
* @param type
* the casting type
* @return the casted configuration
*/
<T extends UploaderConfiguration> T as(Class<T> type);
}
/**

View File

@@ -35,4 +35,14 @@ public final class NullAuthenticatorConfiguration implements
private NullAuthenticatorConfiguration() {
}
@Override
public boolean is(Class<? extends AuthenticatorConfiguration> type) {
return false;
}
@Override
public <T extends AuthenticatorConfiguration> T as(Class<T> type) {
return null;
}
}

View File

@@ -34,4 +34,14 @@ public final class NullDownloaderConfiguration implements
private NullDownloaderConfiguration() {
}
@Override
public boolean is(Class<? extends DownloaderConfiguration> type) {
return false;
}
@Override
public <T extends DownloaderConfiguration> T as(Class<T> type) {
return null;
}
}

View File

@@ -33,4 +33,14 @@ public final class NullUploaderConfiguration implements UploaderConfiguration {
private NullUploaderConfiguration() {
}
@Override
public boolean is(Class<? extends UploaderConfiguration> type) {
return false;
}
@Override
public <T extends UploaderConfiguration> T as(Class<T> type) {
return null;
}
}

View File

@@ -25,6 +25,7 @@ import java.util.ServiceLoader;
import com.rogiel.httpchannel.service.DownloadService;
import com.rogiel.httpchannel.service.Service;
import com.rogiel.httpchannel.service.ServiceID;
import com.rogiel.httpchannel.service.UploadService;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
@@ -73,6 +74,36 @@ public class Services {
}
return null;
}
/**
* Tries to detect which service has the given <tt>id</tt>
*
* @param id
* the service id
* @return the matched service
*/
public static UploadService<?> getUploadService(ServiceID id) {
for (final Service service : iterate()) {
if (service.getServiceID().equals(id))
return (UploadService<?>) service;
}
return null;
}
/**
* Tries to detect which service has the given <tt>id</tt>
*
* @param id
* the service id
* @return the matched service
*/
public static DownloadService<?> getDownloadService(ServiceID id) {
for (final Service service : iterate()) {
if (service.getServiceID().equals(id))
return (DownloadService<?>) service;
}
return null;
}
/**
* Creates a new {@link Iterable} instance to iterate over services