/** * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies * * Please see distribution for license. */ package com.opengamma.component.rest; import java.util.Map; 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.DirectBean; 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.component.ComponentInfo; /** * Stores information about the published components. * <p> * Components are defined in terms of an interface type. */ @BeanDefinition public class RestComponent extends DirectBean { /** * The instance that is to be managed by {@code DataComponentsResource}. * This will be a JAX-RS class. */ @PropertyDefinition(validate = "notNull") private Object _instance; /** * The component info for the instance. */ @PropertyDefinition(validate = "notNull") private ComponentInfo _info; /** * Creates an instance. */ protected RestComponent() { } /** * Creates an instance. * * @param info the managed component info, not null * @param instance the managed component instance, not null */ public RestComponent(ComponentInfo info, Object instance) { setInfo(info); setInstance(instance); } //------------------------- AUTOGENERATED START ------------------------- ///CLOVER:OFF /** * The meta-bean for {@code RestComponent}. * @return the meta-bean, not null */ public static RestComponent.Meta meta() { return RestComponent.Meta.INSTANCE; } static { JodaBeanUtils.registerMetaBean(RestComponent.Meta.INSTANCE); } @Override public RestComponent.Meta metaBean() { return RestComponent.Meta.INSTANCE; } //----------------------------------------------------------------------- /** * Gets the instance that is to be managed by {@code DataComponentsResource}. * This will be a JAX-RS class. * @return the value of the property, not null */ public Object getInstance() { return _instance; } /** * Sets the instance that is to be managed by {@code DataComponentsResource}. * This will be a JAX-RS class. * @param instance the new value of the property, not null */ public void setInstance(Object instance) { JodaBeanUtils.notNull(instance, "instance"); this._instance = instance; } /** * Gets the the {@code instance} property. * This will be a JAX-RS class. * @return the property, not null */ public final Property<Object> instance() { return metaBean().instance().createProperty(this); } //----------------------------------------------------------------------- /** * Gets the component info for the instance. * @return the value of the property, not null */ public ComponentInfo getInfo() { return _info; } /** * Sets the component info for the instance. * @param info the new value of the property, not null */ public void setInfo(ComponentInfo info) { JodaBeanUtils.notNull(info, "info"); this._info = info; } /** * Gets the the {@code info} property. * @return the property, not null */ public final Property<ComponentInfo> info() { return metaBean().info().createProperty(this); } //----------------------------------------------------------------------- @Override public RestComponent clone() { return JodaBeanUtils.cloneAlways(this); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj != null && obj.getClass() == this.getClass()) { RestComponent other = (RestComponent) obj; return JodaBeanUtils.equal(getInstance(), other.getInstance()) && JodaBeanUtils.equal(getInfo(), other.getInfo()); } return false; } @Override public int hashCode() { int hash = getClass().hashCode(); hash = hash * 31 + JodaBeanUtils.hashCode(getInstance()); hash = hash * 31 + JodaBeanUtils.hashCode(getInfo()); return hash; } @Override public String toString() { StringBuilder buf = new StringBuilder(96); buf.append("RestComponent{"); 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("instance").append('=').append(JodaBeanUtils.toString(getInstance())).append(',').append(' '); buf.append("info").append('=').append(JodaBeanUtils.toString(getInfo())).append(',').append(' '); } //----------------------------------------------------------------------- /** * The meta-bean for {@code RestComponent}. */ 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 instance} property. */ private final MetaProperty<Object> _instance = DirectMetaProperty.ofReadWrite( this, "instance", RestComponent.class, Object.class); /** * The meta-property for the {@code info} property. */ private final MetaProperty<ComponentInfo> _info = DirectMetaProperty.ofReadWrite( this, "info", RestComponent.class, ComponentInfo.class); /** * The meta-properties. */ private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap( this, null, "instance", "info"); /** * Restricted constructor. */ protected Meta() { } @Override protected MetaProperty<?> metaPropertyGet(String propertyName) { switch (propertyName.hashCode()) { case 555127957: // instance return _instance; case 3237038: // info return _info; } return super.metaPropertyGet(propertyName); } @Override public BeanBuilder<? extends RestComponent> builder() { return new DirectBeanBuilder<RestComponent>(new RestComponent()); } @Override public Class<? extends RestComponent> beanType() { return RestComponent.class; } @Override public Map<String, MetaProperty<?>> metaPropertyMap() { return _metaPropertyMap$; } //----------------------------------------------------------------------- /** * The meta-property for the {@code instance} property. * @return the meta-property, not null */ public final MetaProperty<Object> instance() { return _instance; } /** * The meta-property for the {@code info} property. * @return the meta-property, not null */ public final MetaProperty<ComponentInfo> info() { return _info; } //----------------------------------------------------------------------- @Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 555127957: // instance return ((RestComponent) bean).getInstance(); case 3237038: // info return ((RestComponent) bean).getInfo(); } return super.propertyGet(bean, propertyName, quiet); } @Override protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) { switch (propertyName.hashCode()) { case 555127957: // instance ((RestComponent) bean).setInstance((Object) newValue); return; case 3237038: // info ((RestComponent) bean).setInfo((ComponentInfo) newValue); return; } super.propertySet(bean, propertyName, newValue, quiet); } @Override protected void validate(Bean bean) { JodaBeanUtils.notNull(((RestComponent) bean)._instance, "instance"); JodaBeanUtils.notNull(((RestComponent) bean)._info, "info"); } } ///CLOVER:ON //-------------------------- AUTOGENERATED END -------------------------- }