/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.web.user;
import java.util.Map;
import javax.ws.rs.core.UriInfo;
import org.apache.shiro.authc.credential.PasswordService;
import org.joda.beans.Bean;
import org.joda.beans.BeanBuilder;
import org.joda.beans.BeanDefinition;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.PropertyDefinition;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.opengamma.master.user.ManageableUser;
import com.opengamma.master.user.UserMaster;
import com.opengamma.web.WebPerRequestData;
/**
* Data class for web-based users.
*/
@BeanDefinition
public class WebUserData extends WebPerRequestData {
/**
* The user master.
*/
@PropertyDefinition
private UserMaster _userMaster;
/**
* The password service.
*/
@PropertyDefinition
private PasswordService _passwordService;
/**
* The user name from the input URI.
*/
@PropertyDefinition
private String _uriUserName;
/**
* The user.
*/
@PropertyDefinition
private ManageableUser _user;
/**
* Creates an instance.
*/
public WebUserData() {
}
/**
* Creates an instance.
* @param uriInfo the URI information
*/
public WebUserData(final UriInfo uriInfo) {
setUriInfo(uriInfo);
}
//-------------------------------------------------------------------------
/**
* Gets the best available user name.
* @param overrideName the override id, null derives the result from the data
* @return the id, may be null
*/
public String getBestUserUriName(final String overrideName) {
if (overrideName != null) {
return overrideName;
}
return getUser() != null ? getUser().getUserName() : getUriUserName();
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code WebUserData}.
* @return the meta-bean, not null
*/
public static WebUserData.Meta meta() {
return WebUserData.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(WebUserData.Meta.INSTANCE);
}
@Override
public WebUserData.Meta metaBean() {
return WebUserData.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the user master.
* @return the value of the property
*/
public UserMaster getUserMaster() {
return _userMaster;
}
/**
* Sets the user master.
* @param userMaster the new value of the property
*/
public void setUserMaster(UserMaster userMaster) {
this._userMaster = userMaster;
}
/**
* Gets the the {@code userMaster} property.
* @return the property, not null
*/
public final Property<UserMaster> userMaster() {
return metaBean().userMaster().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the password service.
* @return the value of the property
*/
public PasswordService getPasswordService() {
return _passwordService;
}
/**
* Sets the password service.
* @param passwordService the new value of the property
*/
public void setPasswordService(PasswordService passwordService) {
this._passwordService = passwordService;
}
/**
* Gets the the {@code passwordService} property.
* @return the property, not null
*/
public final Property<PasswordService> passwordService() {
return metaBean().passwordService().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the user name from the input URI.
* @return the value of the property
*/
public String getUriUserName() {
return _uriUserName;
}
/**
* Sets the user name from the input URI.
* @param uriUserName the new value of the property
*/
public void setUriUserName(String uriUserName) {
this._uriUserName = uriUserName;
}
/**
* Gets the the {@code uriUserName} property.
* @return the property, not null
*/
public final Property<String> uriUserName() {
return metaBean().uriUserName().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the user.
* @return the value of the property
*/
public ManageableUser getUser() {
return _user;
}
/**
* Sets the user.
* @param user the new value of the property
*/
public void setUser(ManageableUser user) {
this._user = user;
}
/**
* Gets the the {@code user} property.
* @return the property, not null
*/
public final Property<ManageableUser> user() {
return metaBean().user().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public WebUserData clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
WebUserData other = (WebUserData) obj;
return JodaBeanUtils.equal(getUserMaster(), other.getUserMaster()) &&
JodaBeanUtils.equal(getPasswordService(), other.getPasswordService()) &&
JodaBeanUtils.equal(getUriUserName(), other.getUriUserName()) &&
JodaBeanUtils.equal(getUser(), other.getUser()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getUserMaster());
hash = hash * 31 + JodaBeanUtils.hashCode(getPasswordService());
hash = hash * 31 + JodaBeanUtils.hashCode(getUriUserName());
hash = hash * 31 + JodaBeanUtils.hashCode(getUser());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(160);
buf.append("WebUserData{");
int len = buf.length();
toString(buf);
if (buf.length() > len) {
buf.setLength(buf.length() - 2);
}
buf.append('}');
return buf.toString();
}
@Override
protected void toString(StringBuilder buf) {
super.toString(buf);
buf.append("userMaster").append('=').append(JodaBeanUtils.toString(getUserMaster())).append(',').append(' ');
buf.append("passwordService").append('=').append(JodaBeanUtils.toString(getPasswordService())).append(',').append(' ');
buf.append("uriUserName").append('=').append(JodaBeanUtils.toString(getUriUserName())).append(',').append(' ');
buf.append("user").append('=').append(JodaBeanUtils.toString(getUser())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code WebUserData}.
*/
public static class Meta extends WebPerRequestData.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code userMaster} property.
*/
private final MetaProperty<UserMaster> _userMaster = DirectMetaProperty.ofReadWrite(
this, "userMaster", WebUserData.class, UserMaster.class);
/**
* The meta-property for the {@code passwordService} property.
*/
private final MetaProperty<PasswordService> _passwordService = DirectMetaProperty.ofReadWrite(
this, "passwordService", WebUserData.class, PasswordService.class);
/**
* The meta-property for the {@code uriUserName} property.
*/
private final MetaProperty<String> _uriUserName = DirectMetaProperty.ofReadWrite(
this, "uriUserName", WebUserData.class, String.class);
/**
* The meta-property for the {@code user} property.
*/
private final MetaProperty<ManageableUser> _user = DirectMetaProperty.ofReadWrite(
this, "user", WebUserData.class, ManageableUser.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"userMaster",
"passwordService",
"uriUserName",
"user");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 1402846733: // userMaster
return _userMaster;
case 348360602: // passwordService
return _passwordService;
case -1723794814: // uriUserName
return _uriUserName;
case 3599307: // user
return _user;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends WebUserData> builder() {
return new DirectBeanBuilder<WebUserData>(new WebUserData());
}
@Override
public Class<? extends WebUserData> beanType() {
return WebUserData.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code userMaster} property.
* @return the meta-property, not null
*/
public final MetaProperty<UserMaster> userMaster() {
return _userMaster;
}
/**
* The meta-property for the {@code passwordService} property.
* @return the meta-property, not null
*/
public final MetaProperty<PasswordService> passwordService() {
return _passwordService;
}
/**
* The meta-property for the {@code uriUserName} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> uriUserName() {
return _uriUserName;
}
/**
* The meta-property for the {@code user} property.
* @return the meta-property, not null
*/
public final MetaProperty<ManageableUser> user() {
return _user;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 1402846733: // userMaster
return ((WebUserData) bean).getUserMaster();
case 348360602: // passwordService
return ((WebUserData) bean).getPasswordService();
case -1723794814: // uriUserName
return ((WebUserData) bean).getUriUserName();
case 3599307: // user
return ((WebUserData) bean).getUser();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 1402846733: // userMaster
((WebUserData) bean).setUserMaster((UserMaster) newValue);
return;
case 348360602: // passwordService
((WebUserData) bean).setPasswordService((PasswordService) newValue);
return;
case -1723794814: // uriUserName
((WebUserData) bean).setUriUserName((String) newValue);
return;
case 3599307: // user
((WebUserData) bean).setUser((ManageableUser) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}