@Override public IChemObject newTestObject() { return new ChemObject(); } });
/** * Compares an Element with this Element. * * @param object Object of type AtomType * @return true if the atom types are equal */ @Override public boolean compare(Object object) { if (!(object instanceof Element)) { return false; } if (!super.compare(object)) { return false; } Element elem = (Element) object; return Objects.equal(atomicNumber, elem.atomicNumber); } }
/**{@inheritDoc} */ @Override public void setProperties(Map<Object, Object> properties) { this.properties = null; if (properties != null) addProperties(properties); }
/** * Clones this <code>IChemObject</code>. It clones the identifier, flags, * properties and pointer vectors. The ChemObjectListeners are not cloned, and * neither is the content of the pointer vectors. * *@return The cloned object */ @Override public Object clone() throws CloneNotSupportedException { ChemObject clone = (ChemObject) super.clone(); // clone the flags clone.flags = this.getFlagValue(); // clone the properties - using the HashMap copy constructor // this does not deep copy all objects but this was not done // originally if (properties != null) { clone.properties = new HashMap<Object, Object>(getProperties()); } return clone; }
@Test public void compareDifferent() { ChemObject co1 = new ChemObject(); ChemObject co2 = new ChemObject(); co1.setID(new String("a1")); co2.setID(new String("a2")); Assert.assertFalse(co1.compare(co2)); } }
@Override public Object clone() throws CloneNotSupportedException { return super.clone(); }
@Test public void testReadAtomTypes_IChemObjectBuilder() throws Exception { OWLBasedAtomTypeConfigurator configurator = new OWLBasedAtomTypeConfigurator(); String configFile = "org/openscience/cdk/dict/data/cdk-atom-types.owl"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(configFile); configurator.setInputStream(ins); Assert.assertNotSame(0, configurator.readAtomTypes(new ChemObject().getBuilder()).size()); }
/** * 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); }
/** *{@inheritDoc} */ @Override public boolean[] getFlags() { // could use a list a invoke .toArray() on the return boolean[] flagArray = new boolean[CDKConstants.MAX_FLAG_INDEX + 1]; for (int i = 0; i < CDKConstants.FLAG_MASKS.length; i++) { int mask = CDKConstants.FLAG_MASKS[i]; flagArray[i] = getFlag(mask); } return flagArray; }
/** *{@inheritDoc} */ @Override public void setFlag(int mask, boolean value) { if (mask > Short.MAX_VALUE || !isPowerOfTwo(mask)) throw new IllegalArgumentException("setFlag() must be provided a valid CDKConstant and not used for custom properties"); // set/unset a bit in the flags value if (value) flags |= mask; else flags &= ~(mask); }
@Test public void compare() { ChemObject co1 = new ChemObject(); ChemObject co2 = new ChemObject(); co1.setID(new String("a1")); co2.setID(new String("a1")); Assert.assertTrue(co1.compare(co2)); }
@Override public Object clone() throws CloneNotSupportedException { return super.clone(); }
/** * 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); }
/** * Clones this <code>IChemObject</code>. It clones the identifier, flags, * properties and pointer vectors. The ChemObjectListeners are not cloned, and * neither is the content of the pointer vectors. * *@return The cloned object */ @Override public Object clone() throws CloneNotSupportedException { ChemObject clone = (ChemObject) super.clone(); // clone the flags clone.flags = this.getFlagValue(); // clone the properties - using the HashMap copy constructor // this does not deep copy all objects but this was not done // originally if (properties != null) { clone.properties = new HashMap<Object, Object>(getProperties()); } return clone; }
/** *{@inheritDoc} */ @Override public boolean[] getFlags() { // could use a list a invoke .toArray() on the return boolean[] flagArray = new boolean[CDKConstants.MAX_FLAG_INDEX + 1]; for (int i = 0; i < CDKConstants.FLAG_MASKS.length; i++) { int mask = CDKConstants.FLAG_MASKS[i]; flagArray[i] = getFlag(mask); } return flagArray; }
/** *{@inheritDoc} */ @Override public void setFlag(int mask, boolean value) { if (mask > Short.MAX_VALUE || !isPowerOfTwo(mask)) throw new IllegalArgumentException("setFlag() must be provided a valid CDKConstant and not used for custom properties"); // set/unset a bit in the flags value if (value) flags |= mask; else flags &= ~(mask); }
@Override public Object clone() throws CloneNotSupportedException { return super.clone(); }
@Test public void testChemObject_IChemObject() { IChemObject chemObject1 = new ChemObject(); IChemObject chemObject = new ChemObject(chemObject1); Assert.assertNotNull(chemObject); }
/** * 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); }
/** * Compares an Element with this Element. * * @param object Object of type AtomType * @return true if the atom types are equal */ @Override public boolean compare(Object object) { if (!(object instanceof Element)) { return false; } if (!super.compare(object)) { return false; } Element elem = (Element) object; return Objects.equal(atomicNumber, elem.atomicNumber); } }