Java tutorial
/*---------------- FILE HEADER KALYPSO ------------------------------------------ * * This file is part of kalypso. * Copyright (C) 2004 by: * * Technical University Hamburg-Harburg (TUHH) * Institute of River and coastal engineering * Denickestrae 22 * 21073 Hamburg, Germany * http://www.tuhh.de/wb * * and * * Bjoernsen Consulting Engineers (BCE) * Maria Trost 3 * 56070 Koblenz, Germany * http://www.bjoernsen.de * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact: * * E-Mail: * belger@bjoernsen.de * schlienger@bjoernsen.de * v.doemming@tuhh.de * * ---------------------------------------------------------------------------*/ package org.kalypso.repository; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.kalypso.repository.utils.RepositoryVisitors; /** * This repository item represents a simple repository item, which can be added at any point in the repository structure * for UI purposes. * * @author Holger Albert */ public class SimpleRepositoryItem implements IRepositoryItem { /** * The name. */ private final String m_name; /** * The link. */ private final String m_link; /** * The parent. */ private final IRepositoryItem m_parent; /** * The constructor. * * @param name * The name. * @param link * The link. * @param parent * The parent. */ public SimpleRepositoryItem(final String name, final String link, final IRepositoryItem parent) { m_name = name; m_link = link; m_parent = parent; } /** * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ @Override public Object getAdapter(final Class adapter) { return null; } /** * @see org.kalypso.repository.IRepositoryItem#accept(org.kalypso.repository.IRepositoryItemVisitor) */ @Override public void accept(final IRepositoryItemVisitor visitor) throws RepositoryException { RepositoryVisitors.accept(this, visitor); } /** * @see org.kalypso.repository.IRepositoryItem#getName() */ @Override public String getName() { return m_name; } /** * @see org.kalypso.repository.IRepositoryItem#getIdentifier() */ @Override public String getIdentifier() { return m_link; } /** * @see org.kalypso.repository.IRepositoryItem#getParent() */ @Override public IRepositoryItem getParent() { return m_parent; } /** * @see org.kalypso.repository.IRepositoryItem#hasChildren() */ @Override public boolean hasChildren() { return false; } /** * @see org.kalypso.repository.IRepositoryItem#getChildren() */ @Override public IRepositoryItem[] getChildren() { return new IRepositoryItem[] {}; } /** * @see org.kalypso.repository.IRepositoryItem#getRepository() */ @Override public IRepository getRepository() { return null; } /** * @see org.kalypso.repository.IRepositoryItem#hasAdapter(java.lang.Class) */ @Override public boolean hasAdapter(final Class<?> adapter) { return false; } /** * @see org.kalypso.repository.IRepositoryItem#isMultipleSourceItem() */ @Override public boolean isMultipleSourceItem() { return false; } /** * @see java.lang.Object#toString() */ @Override public String toString() { return getName(); } /** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(final Object obj) { if (!(obj instanceof SimpleRepositoryItem)) return false; final EqualsBuilder builder = new EqualsBuilder(); final SimpleRepositoryItem other = (SimpleRepositoryItem) obj; builder.append(m_name, other.m_name); builder.append(m_link, other.m_link); builder.append(m_parent, other.m_parent); return builder.isEquals(); } /** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final HashCodeBuilder builder = new HashCodeBuilder(); builder.append(m_name); builder.append(m_link); builder.append(m_parent); return builder.hashCode(); } }