@Test public void testClone(){ LabelsMetaData clonedMetaData = metaData.clone(); Assert.assertNotSame(metaData, clonedMetaData); Assert.assertEquals(metaData.isHierarchy(), clonedMetaData.isHierarchy()); Assert.assertEquals(metaData.getNumLabels(), clonedMetaData.getNumLabels()); Assert.assertEquals(metaData.getRootLabels().size(), clonedMetaData.getRootLabels().size()); Assert.assertTrue(clonedMetaData.containsLabel(HIERARCHY_CHILD_1_NODE_NAME)); Assert.assertTrue(clonedMetaData.containsLabel(HIERARCHY_CHILD_2_NODE_NAME)); Assert.assertTrue(clonedMetaData.containsLabel(HIERARCHY_ROOT_NODE_NAME)); Assert.assertTrue(clonedMetaData.containsLabel(PLAIN_ROOT_NODE_NAME)); }
@SuppressWarnings("unchecked") @Override public LabelsMetaData clone() { Set<LabelNode> rootNodes = null; try { SerializedObject obj = new SerializedObject(rootLabelNodes); rootNodes = (Set<LabelNode>) obj.getObject(); } catch (Exception ex) { throw new WekaException("Failed to create copy of 'root label nodes'.", ex); } LabelsMetaDataImpl copyResult = new LabelsMetaDataImpl(); for (LabelNode rootNode : rootNodes) { copyResult.addRootNode(rootNode); } return copyResult; }
LabelsMetaDataImpl implements LabelsMetaData, Serializable, Externalizable { @SuppressWarnings("unchecked") @Override public LabelsMetaData clone() { Set<LabelNode> rootNodes = null; try { SerializedObject obj = new SerializedObject(rootLabelNodes); rootNodes = (Set<LabelNode>) obj.getObject(); } catch (Exception ex) { throw new WekaException("Failed to create copy of 'root label nodes'.", ex); } LabelsMetaDataImpl copyResult = new LabelsMetaDataImpl(); for (LabelNode rootNode : rootNodes) { copyResult.addRootNode(rootNode); } return copyResult; } }
LabelsMetaDataImpl implements LabelsMetaData, Serializable, Externalizable { @SuppressWarnings("unchecked") @Override public LabelsMetaData clone() { Set<LabelNode> rootNodes = null; try { SerializedObject obj = new SerializedObject(rootLabelNodes); rootNodes = (Set<LabelNode>) obj.getObject(); } catch (Exception ex) { throw new WekaException("Failed to create copy of 'root label nodes'.", ex); } LabelsMetaDataImpl copyResult = new LabelsMetaDataImpl(); for (LabelNode rootNode : rootNodes) { copyResult.addRootNode(rootNode); } return copyResult; } LabelsMetaDataImpl(); }
LabelsMetaDataImpl implements LabelsMetaData, Serializable, Externalizable { @SuppressWarnings("unchecked") @Override public LabelsMetaData clone() { Set<LabelNode> rootNodes = null; try { SerializedObject obj = new SerializedObject(rootLabelNodes); rootNodes = (Set<LabelNode>) obj.getObject(); } catch (Exception ex) { throw new WekaException("Failed to create copy of 'root label nodes'.", ex); } LabelsMetaDataImpl copyResult = new LabelsMetaDataImpl(); for (LabelNode rootNode : rootNodes) { copyResult.addRootNode(rootNode); } return copyResult; } LabelsMetaDataImpl(); void addRootNode(LabelNode rootNode); LabelNode getLabelNode(String labelName); Set<String> getLabelNames(); boolean containsLabel(String labelName); boolean isHierarchy(); int getNumLabels(); Set<LabelNode> getRootLabels(); @SuppressWarnings("unchecked") @Override LabelsMetaData clone(); int removeLabelNode(String labelName); @SuppressWarnings("unchecked") @Override void readExternal(ObjectInput in); @Override void writeExternal(ObjectOutput out); }
LabelsMetaDataImpl implements LabelsMetaData, Serializable, Externalizable { @SuppressWarnings("unchecked") @Override public LabelsMetaData clone() { Set<LabelNode> rootNodes = null; try { SerializedObject obj = new SerializedObject(rootLabelNodes); rootNodes = (Set<LabelNode>) obj.getObject(); } catch (Exception ex) { throw new WekaException("Failed to create copy of 'root label nodes'.", ex); } LabelsMetaDataImpl copyResult = new LabelsMetaDataImpl(); for (LabelNode rootNode : rootNodes) { copyResult.addRootNode(rootNode); } return copyResult; } LabelsMetaDataImpl(); void addRootNode(LabelNode rootNode); LabelNode getLabelNode(String labelName); Set<String> getLabelNames(); boolean containsLabel(String labelName); boolean isHierarchy(); int getNumLabels(); Set<LabelNode> getRootLabels(); @SuppressWarnings("unchecked") @Override LabelsMetaData clone(); int removeLabelNode(String labelName); @SuppressWarnings("unchecked") @Override void readExternal(ObjectInput in); @Override void writeExternal(ObjectOutput out);  }