/** * Returns a property for the IChemObject. * *@param description An object description of the property (most likely a * unique string) *@return The object containing the property. Returns null if * propert is not set. *@see #setProperty *@see #removeProperty */ @Override public <T> T getProperty(Object description) { if (properties == null) return null; // can't check the type @SuppressWarnings("unchecked") T value = (T) lazyProperties().get(description); return value; }
/** * Returns a property for the IChemObject. * *@param description An object description of the property (most likely a * unique string) *@return The object containing the property. Returns null if * propert is not set. *@see #setProperty *@see #removeProperty */ @Override public <T> T getProperty(Object description) { if (properties == null) return null; // can't check the type @SuppressWarnings("unchecked") T value = (T) lazyProperties().get(description); return value; }
/** *{@inheritDoc} */ @Override public <T> T getProperty(Object description, Class<T> c) { Object value = lazyProperties().get(description); if (c.isInstance(value)) { @SuppressWarnings("unchecked") T typed = (T) value; return typed; } else if (value != null) { throw new IllegalArgumentException("attempted to access a property of incorrect type, expected " + c.getSimpleName() + " got " + value.getClass().getSimpleName()); } return null; }
/** * Sets the properties of this object. * *@param properties a Hashtable specifying the property values *@see #getProperties */ @Override public void addProperties(Map<Object, Object> properties) { if (properties == null) return; lazyProperties().putAll(properties); notifyChanged(); }
/** *{@inheritDoc} */ @Override public <T> T getProperty(Object description, Class<T> c) { Object value = lazyProperties().get(description); if (c.isInstance(value)) { @SuppressWarnings("unchecked") T typed = (T) value; return typed; } else if (value != null) { throw new IllegalArgumentException("attempted to access a property of incorrect type, expected " + c.getSimpleName() + " got " + value.getClass().getSimpleName()); } return null; }
/** * Sets the properties of this object. * *@param properties a Hashtable specifying the property values *@see #getProperties */ @Override public void addProperties(Map<Object, Object> properties) { if (properties == null) return; lazyProperties().putAll(properties); notifyChanged(); }
/** * Sets a property for a IChemObject. * *@param description An object description of the property (most likely a * unique string) *@param property An object with the property itself *@see #getProperty *@see #removeProperty */ @Override public void setProperty(Object description, Object property) { lazyProperties().put(description, property); notifyChanged(); }
/** * Sets a property for a IChemObject. * *@param description An object description of the property (most likely a * unique string) *@param property An object with the property itself *@see #getProperty *@see #removeProperty */ @Override public void setProperty(Object description, Object property) { lazyProperties().put(description, property); notifyChanged(); }