refactor: simplify collection.toArray()
[egit/eclipse.git] / org.eclipse.egit.ui / src / org / eclipse / egit / ui / internal / synchronize / model / GitModelObject.java
blobd5fcd07007aa32bc91fbc51d508a280bcdb553ba
1 /*******************************************************************************
2 * Copyright (C) 2010, Dariusz Luksza <dariusz@luksza.org>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
10 *******************************************************************************/
11 package org.eclipse.egit.ui.internal.synchronize.model;
13 import java.io.IOException;
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.core.runtime.PlatformObject;
17 import org.eclipse.egit.core.synchronize.dto.GitSynchronizeData;
18 import org.eclipse.jgit.errors.MissingObjectException;
20 /**
21 * Abstract representation of all object that are included in Git ChangeSet
22 * model.
24 public abstract class GitModelObject extends PlatformObject {
26 private final GitModelObject parent;
28 /**
29 * Creates root of Git ChangeSet model.
31 * @param data
32 * synchronization data
33 * @return Git ChangeSet model root
34 * @throws IOException
35 * @throws MissingObjectException
37 public static GitModelObject createRoot(GitSynchronizeData data)
38 throws MissingObjectException, IOException {
39 return new GitModelRepository(data);
42 /**
43 * @param parent
45 public GitModelObject(GitModelObject parent) {
46 this.parent = parent;
49 /**
50 * @return parent
52 public GitModelObject getParent() {
53 return parent;
56 /**
57 * @return repository hash code
59 public abstract int repositoryHashCode();
61 /**
62 * @return child's of particular model object
64 public abstract GitModelObject[] getChildren();
66 /**
67 * Returns name of model object, in case of:
68 * <ul>
69 * <li>root node it will return repository path
70 * <li>commit node it will return first 6 characters of commit's SHA-1
71 * connected with short commit message
72 * <li>tree node it will return folder name
73 * <li>blob node it will return file name
74 * </ul>
76 * @return name of model object
78 public abstract String getName();
80 /**
82 * @return change kind
84 public abstract int getKind();
86 /**
87 * @return location of resource associated with particular model object
89 public abstract IPath getLocation();
91 /**
92 * Answers if model object may have children.
94 * @return <code>true</code> if the model object may have children and
95 * <code>false</code> otherwise.
97 public abstract boolean isContainer();
99 /**
100 * Disposed all nested resources
102 public abstract void dispose();