/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.master.user;
import java.util.Map;
import java.util.Set;
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.DirectMetaBean;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.opengamma.id.ObjectId;
import com.opengamma.util.ArgumentChecker;
/**
* Request for the history of a user.
* <p>
* A user master implements lightweight historical storage of data.
* This object is used to request that history.
* <p>
* Either the object identifier or the user name must be specified.
* If both are specified, the user name is ignored.
*/
@BeanDefinition
public class UserEventHistoryRequest implements Bean {
/**
* The object identifier to retrieve history for.
*/
@PropertyDefinition
private ObjectId _objectId;
/**
* The user name to retrieve history for.
*/
@PropertyDefinition
private String _userName;
/**
* Creates an instance.
*/
protected UserEventHistoryRequest() {
super();
}
/**
* Creates an instance with object identifier.
*
* @param objectId the object identifier, not null
*/
public UserEventHistoryRequest(final ObjectId objectId) {
_objectId = ArgumentChecker.notNull(objectId, "objectId");
}
/**
* Creates an instance with user name.
*
* @param userName the user name, not null
*/
public UserEventHistoryRequest(final String userName) {
_userName = ArgumentChecker.notNull(userName, "userName");
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code UserEventHistoryRequest}.
* @return the meta-bean, not null
*/
public static UserEventHistoryRequest.Meta meta() {
return UserEventHistoryRequest.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(UserEventHistoryRequest.Meta.INSTANCE);
}
@Override
public UserEventHistoryRequest.Meta metaBean() {
return UserEventHistoryRequest.Meta.INSTANCE;
}
@Override
public <R> Property<R> property(String propertyName) {
return metaBean().<R>metaProperty(propertyName).createProperty(this);
}
@Override
public Set<String> propertyNames() {
return metaBean().metaPropertyMap().keySet();
}
//-----------------------------------------------------------------------
/**
* Gets the object identifier to retrieve history for.
* @return the value of the property
*/
public ObjectId getObjectId() {
return _objectId;
}
/**
* Sets the object identifier to retrieve history for.
* @param objectId the new value of the property
*/
public void setObjectId(ObjectId objectId) {
this._objectId = objectId;
}
/**
* Gets the the {@code objectId} property.
* @return the property, not null
*/
public final Property<ObjectId> objectId() {
return metaBean().objectId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the user name to retrieve history for.
* @return the value of the property
*/
public String getUserName() {
return _userName;
}
/**
* Sets the user name to retrieve history for.
* @param userName the new value of the property
*/
public void setUserName(String userName) {
this._userName = userName;
}
/**
* Gets the the {@code userName} property.
* @return the property, not null
*/
public final Property<String> userName() {
return metaBean().userName().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public UserEventHistoryRequest clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
UserEventHistoryRequest other = (UserEventHistoryRequest) obj;
return JodaBeanUtils.equal(getObjectId(), other.getObjectId()) &&
JodaBeanUtils.equal(getUserName(), other.getUserName());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(getObjectId());
hash = hash * 31 + JodaBeanUtils.hashCode(getUserName());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(96);
buf.append("UserEventHistoryRequest{");
int len = buf.length();
toString(buf);
if (buf.length() > len) {
buf.setLength(buf.length() - 2);
}
buf.append('}');
return buf.toString();
}
protected void toString(StringBuilder buf) {
buf.append("objectId").append('=').append(JodaBeanUtils.toString(getObjectId())).append(',').append(' ');
buf.append("userName").append('=').append(JodaBeanUtils.toString(getUserName())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code UserEventHistoryRequest}.
*/
public static class Meta extends DirectMetaBean {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code objectId} property.
*/
private final MetaProperty<ObjectId> _objectId = DirectMetaProperty.ofReadWrite(
this, "objectId", UserEventHistoryRequest.class, ObjectId.class);
/**
* The meta-property for the {@code userName} property.
*/
private final MetaProperty<String> _userName = DirectMetaProperty.ofReadWrite(
this, "userName", UserEventHistoryRequest.class, String.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"objectId",
"userName");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 90495162: // objectId
return _objectId;
case -266666762: // userName
return _userName;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends UserEventHistoryRequest> builder() {
return new DirectBeanBuilder<UserEventHistoryRequest>(new UserEventHistoryRequest());
}
@Override
public Class<? extends UserEventHistoryRequest> beanType() {
return UserEventHistoryRequest.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code objectId} property.
* @return the meta-property, not null
*/
public final MetaProperty<ObjectId> objectId() {
return _objectId;
}
/**
* The meta-property for the {@code userName} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> userName() {
return _userName;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 90495162: // objectId
return ((UserEventHistoryRequest) bean).getObjectId();
case -266666762: // userName
return ((UserEventHistoryRequest) bean).getUserName();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 90495162: // objectId
((UserEventHistoryRequest) bean).setObjectId((ObjectId) newValue);
return;
case -266666762: // userName
((UserEventHistoryRequest) bean).setUserName((String) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}