/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.web.bundle;
import java.net.URI;
import java.util.Collections;
import java.util.List;
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.util.ArgumentChecker;
/**
* A fragment of a bundle, representing a single CSS/Javascript file.
* <p>
* Fragments are not referred to directly, instead they are grouped into
* {@link Bundle bundles}.
* <p>
* This class is mutable and not thread-safe.
*/
@BeanDefinition
public class Fragment extends DirectBean implements BundleNode {
/**
* The internal URI of the fragment
*/
@PropertyDefinition
private URI _uri;
/**
* The path to the fragment
*/
@PropertyDefinition
private String _path;
/**
* Creates an instance.
*/
protected Fragment() {
}
/**
* Creates a populated instance.
*
* @param uri the internal URI of the fragment, not null
* @param path the path to the fragment, not null
*/
public Fragment(URI uri, String path) {
ArgumentChecker.notNull(uri, "uri");
ArgumentChecker.notNull(path, "path");
_uri = uri;
_path = path;
}
//-------------------------------------------------------------------------
@Override
public List<Bundle> getAllBundles() {
return Collections.emptyList();
}
@Override
public List<Fragment> getAllFragments() {
return Collections.singletonList(this);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code Fragment}.
* @return the meta-bean, not null
*/
public static Fragment.Meta meta() {
return Fragment.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(Fragment.Meta.INSTANCE);
}
@Override
public Fragment.Meta metaBean() {
return Fragment.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the internal URI of the fragment
* @return the value of the property
*/
public URI getUri() {
return _uri;
}
/**
* Sets the internal URI of the fragment
* @param uri the new value of the property
*/
public void setUri(URI uri) {
this._uri = uri;
}
/**
* Gets the the {@code uri} property.
* @return the property, not null
*/
public final Property<URI> uri() {
return metaBean().uri().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the path to the fragment
* @return the value of the property
*/
public String getPath() {
return _path;
}
/**
* Sets the path to the fragment
* @param path the new value of the property
*/
public void setPath(String path) {
this._path = path;
}
/**
* Gets the the {@code path} property.
* @return the property, not null
*/
public final Property<String> path() {
return metaBean().path().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public Fragment clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
Fragment other = (Fragment) obj;
return JodaBeanUtils.equal(getUri(), other.getUri()) &&
JodaBeanUtils.equal(getPath(), other.getPath());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(getUri());
hash = hash * 31 + JodaBeanUtils.hashCode(getPath());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(96);
buf.append("Fragment{");
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("uri").append('=').append(JodaBeanUtils.toString(getUri())).append(',').append(' ');
buf.append("path").append('=').append(JodaBeanUtils.toString(getPath())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code Fragment}.
*/
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 uri} property.
*/
private final MetaProperty<URI> _uri = DirectMetaProperty.ofReadWrite(
this, "uri", Fragment.class, URI.class);
/**
* The meta-property for the {@code path} property.
*/
private final MetaProperty<String> _path = DirectMetaProperty.ofReadWrite(
this, "path", Fragment.class, String.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"uri",
"path");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 116076: // uri
return _uri;
case 3433509: // path
return _path;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends Fragment> builder() {
return new DirectBeanBuilder<Fragment>(new Fragment());
}
@Override
public Class<? extends Fragment> beanType() {
return Fragment.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code uri} property.
* @return the meta-property, not null
*/
public final MetaProperty<URI> uri() {
return _uri;
}
/**
* The meta-property for the {@code path} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> path() {
return _path;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 116076: // uri
return ((Fragment) bean).getUri();
case 3433509: // path
return ((Fragment) bean).getPath();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 116076: // uri
((Fragment) bean).setUri((URI) newValue);
return;
case 3433509: // path
((Fragment) bean).setPath((String) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}