Reduce allocations in decorator
[egit/eclipse.git] / org.eclipse.egit.ui / src / org / eclipse / egit / ui / internal / resources / ResourceState.java
blob5ddf813f9ce5e39da38b7ffe1a863206fe0be0b7
1 /*******************************************************************************
2 * Copyright (C) 2015, Thomas Wolf <thomas.wolf@paranor.ch>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org.eclipse.egit.ui.internal.resources;
11 import org.eclipse.jgit.annotations.NonNull;
13 /**
14 * Base implementation of an {@link IResourceState}.
16 public class ResourceState implements IResourceState {
18 /**
19 * Flag indicating whether or not the resource is tracked
21 private boolean tracked;
23 /**
24 * Flag indicating whether or not the resource is ignored
26 private boolean ignored;
28 /**
29 * Flag indicating whether or not the resource has changes that are not
30 * staged
32 private boolean dirty;
34 /**
35 * Flag indicating whether or not the resource has been deleted locally
36 * (unstaged deletion).
38 private boolean missing;
40 /**
41 * Staged state of the resource
43 @NonNull
44 private StagingState staged = StagingState.NOT_STAGED;
46 /**
47 * Flag indicating whether or not the resource has merge conflicts
49 private boolean conflicts;
51 /**
52 * Flag indicating whether or not the resource is assumed unchanged
54 private boolean assumeUnchanged;
56 @Override
57 public boolean isTracked() {
58 return tracked;
61 @Override
62 public boolean isIgnored() {
63 return ignored;
66 @Override
67 public boolean isDirty() {
68 return dirty;
71 @Override
72 public boolean isMissing() {
73 return missing;
76 @Override
77 public StagingState getStagingState() {
78 return staged;
81 @Override
82 public final boolean isStaged() {
83 return staged != StagingState.NOT_STAGED;
86 @Override
87 public boolean hasConflicts() {
88 return conflicts;
91 @Override
92 public boolean isAssumeUnchanged() {
93 return assumeUnchanged;
96 @Override
97 public final boolean hasUnstagedChanges() {
98 return !isIgnored()
99 && (!isTracked() || isDirty() || isMissing() || hasConflicts());
103 * Sets the staged property.
105 * @param staged
106 * value to set.
108 protected void setStagingState(@NonNull StagingState staged) {
109 this.staged = staged;
113 * Sets the conflicts property.
115 * @param conflicts
116 * value to set.
118 protected void setConflicts(boolean conflicts) {
119 this.conflicts = conflicts;
123 * Sets the tracked property.
125 * @param tracked
126 * value to set.
128 protected void setTracked(boolean tracked) {
129 this.tracked = tracked;
133 * Sets the ignored property.
135 * @param ignored
136 * value to set.
138 protected void setIgnored(boolean ignored) {
139 this.ignored = ignored;
143 * Sets the dirty property.
145 * @param dirty
146 * value to set.
148 protected void setDirty(boolean dirty) {
149 this.dirty = dirty;
153 * Sets the missing property.
155 * @param missing
156 * value to set.
158 protected void setMissing(boolean missing) {
159 this.missing = missing;
163 * Sets the assumeUnchanged property.
165 * @param assumeUnchanged
166 * value to set.
168 protected void setAssumeUnchanged(boolean assumeUnchanged) {
169 this.assumeUnchanged = assumeUnchanged;