Item implements Serializable, Cacheable { public static Item copyValues(final Item from, final Item to) { Item item = new Item(); if (to != null && to.getItemType() != from.getItemType()) { throw new UnsupportedOperationException("Cannot change item type"); } String id = from.getId(); Bbox toBbox = null; Summary toSummary = null; if (to != null) { id = to.getId(); toBbox = to.getBbox(); toSummary = to.getSummary(); } Summary fromSummary = from.getSummary(); Summary newSummary; if (null == fromSummary) { newSummary = null; } else { newSummary = Summary.copyValues(from.getSummary(), toSummary); } item.setId(id); item.setItemType(from.getItemType()); item.setType(from.getType()); item.setName(from.getName()); item.setAttr(from.getAttr()); item.setBbox(Bbox.copyValues(from.getBbox(), toBbox)); item.setSummary(newSummary); item.setRibbonable(from.isRibbonable()); item.setShowChildren(from.isShowChildren()); item.setEnabled(from.isEnabled()); item.setServices(from.getServices()); item.setChildren(from.getChildren()); item.setDisplayedChildren(from.getDisplayedChildren()); item.setActiveStorm(from.isActiveStorm()); item.setFeatured(from.isFeatured()); return item; }  @Id String getId(); void setId(String id); @Enumerated(EnumType.STRING) @Column(name = ITEM_TYPE) ItemType getItemType(); void setItemType(ItemType itemType); @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(columnDefinition = "bbox_id") Bbox getBbox(); void setBbox(Bbox bbox); @Column(name = "name", length = NAME_MAX_LENGTH) String getName(); void setName(String name); @Enumerated(EnumType.STRING) Item.Type getType(); void setType(Item.Type type); @Column(name = "attr", length = ATTR_MAX_LENGTH) String getAttr(); void setAttr(String attr); boolean isRibbonable(); void setRibbonable(boolean ribbonable); @Column(name = "show_children") boolean isShowChildren(); void setShowChildren(boolean showChildren); boolean isEnabled(); void setEnabled(boolean enabled); @OneToOne(cascade = CascadeType.ALL) @JoinColumn(columnDefinition = "summary_id") Summary getSummary(); void setSummary(Summary summary); @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true) @JoinTable(name = "service_item", joinColumns = { @JoinColumn(name = "item_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "service_id", referencedColumnName = "id") }) @IndexColumn(name = "list_index") List<Service> getServices(); void setServices(List<Service> services); @ManyToMany(fetch = FetchType.LAZY) @LazyCollection(LazyCollectionOption.EXTRA) @JoinTable( name = "aggregation_children", joinColumns = { @JoinColumn(name = "aggregation_id", referencedColumnName = "id")}, inverseJoinColumns = { @JoinColumn(name = "item_id", referencedColumnName = "id")}) @IndexColumn(name = "list_index") List<Item> getChildren(); List<String> proxiedChildren(); void setChildren(List<Item> children); @ElementCollection(fetch = FetchType.EAGER) @CollectionTable(name = "displayed_children", joinColumns = @JoinColumn(name = "item_id")) @IndexColumn(name = "list_index") @Column(name = "child_id") List<String> getDisplayedChildren(); @Temporal(TemporalType.TIMESTAMP) @Column(name = "last_update") @Override Date getLastModified(); void setLastModified(Date timestamp); @Column(name="active_storm") boolean isActiveStorm(); void setActiveStorm(boolean isActiveStorm); boolean isFeatured(); void setFeatured(boolean featured); void setDisplayedChildren(List<String> displayedChildren); String toJSON(boolean subtree); static Item fromJSON(String json); static Item copyValues(final Item from, final Item to); Item instantiateTemplate(List<Service> withServices); WMSService fetchWmsService(); WFSService fetchWfsService(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final String UBER_ID; static final int NAME_MAX_LENGTH; static final int ATTR_MAX_LENGTH; static final String ITEM_TYPE; static final String DATA_TYPE; static final String AGGREGATION_TYPE; }
@Test public void testThatACloneEqualsTheOriginal() { Item i1 = new Item(); Item i2 = Item.copyValues(i1, null); assertEquals(i1, i2); }