
uk.ac.ceh.components.userstore.UserAttributeReader Maven / Gradle / Ivy
package uk.ac.ceh.components.userstore;
import java.lang.reflect.Type;
import java.util.Map;
/**
* The following interface defines how to read given user attributes from a user
* instance.
* @author Christopher Johnson
*/
public interface UserAttributeReader {
/**
* Returns the map of user attribute keys to their defined Types which this
* UserAttributeReader is capable of reading
* @return the UserAttribute keys which can be read using this reader mapped to
* the expected type
*/
Map getDefinedAttributes();
/**
* Gets the value of the {@link UserAttribute} represented by uri from the
* user
* @param user The user to read from
* @param uri The property to read
* @return The value of uri from the user if it exists. else null.
* @throws UserAttributeReaderException if the property exists but could not be read
*/
Object get(U user, String uri) throws UserAttributeReaderException;
/**
* The following method will get the specified property off of the given user
* and attempt to cast that value to the type specified by type.
*
* Implementations are free to attempt to convert the actual value to the specified
* type if necessary.
* @param The type to attempt to get the value of
* @param user The user to read the property from
* @param uri The uri of the property to read from the user
* @param type The class representing the desired type
* @return The property value to read in the desired type
* @throws UserAttributeReaderException if the property can not be transformed
* to the desired type or the property exists but can not be read
*/
T get(U user, String uri, Class type) throws UserAttributeReaderException;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy