1package org.apache.maven.scm;
23import java.io.Serializable;
45/*6 * Licensed to the Apache Software Foundation (ASF) under one7 * or more contributor license agreements. See the NOTICE file8 * distributed with this work for additional information9 * regarding copyright ownership. The ASF licenses this file10 * to you under the Apache License, Version 2.0 (the11 * "License"); you may not use this file except in compliance12 * with the License. You may obtain a copy of the License at13 *14 * http://www.apache.org/licenses/LICENSE-2.015 *16 * Unless required by applicable law or agreed to in writing,17 * software distributed under the License is distributed on an18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY19 * KIND, either express or implied. See the License for the20 * specific language governing permissions and limitations21 * under the License.22 */2324/**25 * @TODO move to a real enum26 * <p/>27 * Typesafe enum for file status28 * </p>29 * <p/>30 * There are two types of status defined in this class: <br/>31 * 1) Status: Changes in the working tree, not yet committed to the repository eg. MODIFIED <br/>32 * 2) Transaction: The file is part of some transaction with the repository eg. CHECKED_IN33 * </p>34 *35 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>36 *37 */38publicfinalclassScmFileStatus39implements Serializable
40 {
41privatestaticfinallong serialVersionUID = -7840223279162817915L;
4243/**44 * File is added to the working tree and does not yet exist in the repository45 */46publicstaticfinalScmFileStatus ADDED = newScmFileStatus( "added" );
4748/**49 * File is removed from the working tree thus not revisioned anymore.<br>50 * The file is still present in the repository.<br>51 * The file could be deleted from the filesystem depending on the provider.52 */53publicstaticfinalScmFileStatus DELETED = newScmFileStatus( "deleted" );
5455/**56 * The file has been modified in the working tree.57 */58publicstaticfinalScmFileStatus MODIFIED = newScmFileStatus( "modified" );
5960/**61 * The file has been renamed or moved in the working tree.62 * @since 1.763 */64publicstaticfinalScmFileStatus RENAMED = newScmFileStatus( "renamed" );
6566/**67 * The file has been copied in the working tree.68 * @since 1.769 */70publicstaticfinalScmFileStatus COPIED = newScmFileStatus( "copied" );
7172/**73 * The file is missing in the working tree.74 */75publicstaticfinalScmFileStatus MISSING = newScmFileStatus( "missing" );
7677/**78 * File from working tree is checked into the repository79 */80publicstaticfinalScmFileStatus CHECKED_IN = newScmFileStatus( "checked-in" );
8182/**83 * File is checked out from the repository and into the working tree84 */85publicstaticfinalScmFileStatus CHECKED_OUT = newScmFileStatus( "checked-out" );
8687/**88 * The file in the working tree has differences to the one in repository that89 * conflicts ie. it cannot automatically be merged.90 */91publicstaticfinalScmFileStatus CONFLICT = newScmFileStatus( "conflict" );
9293/**94 * The file in the working tree has been updated with changes from the repository.95 */96publicstaticfinalScmFileStatus PATCHED = newScmFileStatus( "patched" );
9798/**99 * The file is added, removed or updated from the repository, thus its100 * up-to-date with the version in the repository. See also isUpdate()101 */102publicstaticfinalScmFileStatus UPDATED = newScmFileStatus( "updated" );
103104/**105 * The file is part of a tag.106 */107publicstaticfinalScmFileStatus TAGGED = newScmFileStatus( "tagged" );
108109/**110 * The file is locked.111 */112publicstaticfinalScmFileStatus LOCKED = newScmFileStatus( "locked" );
113114/**115 * The file is in the working tree but is not versioned and not ignored either.116 */117publicstaticfinalScmFileStatus UNKNOWN = newScmFileStatus( "unknown" );
118119/**120 * @since 1.5121 * The file is being edited122 */123publicstaticfinalScmFileStatus EDITED = newScmFileStatus( "edit" );
124125/**126 * The status name127 */128privatefinal String name;
129130privateScmFileStatus( String name )
131 {
132this.name = name;
133 }
134135/** {@inheritDoc} */136public String toString()
137 {
138return name;
139 }
140141/**142 * There are changes in the working tree that are not committed to the repository, or <br>143 * the file is unknown for the working tree.144 *145 * @return true on changes in the working tree or if the file is unknown.146 */147publicboolean isStatus()
148 {
149returnthis == UNKNOWN || isDiff();
150 }
151152/**153 * There are changes in the working tree that are not committed to the repository. <br>154 *155 * @return true on changes in the working tree156 */157publicboolean isDiff()
158 {
159returnthis == ADDED || this == DELETED || this == MODIFIED;
160 }
161162/**163 * @return true if the file was part of a transaction with the repository.164 */165publicboolean isTransaction()
166 {
167returnthis == CHECKED_IN || this == CHECKED_OUT || this == LOCKED || this == TAGGED || isUpdate();
168 }
169170/**171 * File is part of an update transaction with the repository.<br>172 * Note: ADDED and REMOVED are not an update status since they indicates173 * that the working tree has changed.<br>174 * An update indicates the opposite, that the repository was changed compared to175 * the working tree and that it is now synchronized unless there are conflicts.176 *177 * @return true if the status is conflict, updated or patched.178 */179publicboolean isUpdate()
180 {
181returnthis == CONFLICT || this == UPDATED || this == PATCHED;
182 }
183 }