All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.netbeans.modules.glassfish.tooling.TaskState Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.netbeans.modules.glassfish.tooling;

import java.util.HashMap;
import java.util.Map;

/**
 * Current state of GlassFish server administration command execution
 * 

* @author Tomas Kraus, Peter Benedikovic */ public enum TaskState { //////////////////////////////////////////////////////////////////////////// // Enum values // //////////////////////////////////////////////////////////////////////////// /** Value representing task waiting in executor queue. */ READY, /** Value representing running task. */ RUNNING, /** Value representing successfully completed task (with no errors). */ COMPLETED, /** Value representing failed task. */ FAILED; //////////////////////////////////////////////////////////////////////////// // Class attributes // //////////////////////////////////////////////////////////////////////////// /** A String representation of READY value. */ private static final String READY_STR = "READY"; /** A String representation of RUNNING value. */ private static final String RUNNING_STR = "RUNNING"; /** A String representation of COMPLETED value. */ private static final String COMPLETED_STR = "COMPLETED"; /** A String representation of FAILED value. */ private static final String FAILED_STR = "FAILED"; /** * Stored String values for backward String * conversion. */ private static final Map stringValuesMap = new HashMap<>(values().length); // Initialize backward String conversion Map. static { for (TaskState state : TaskState.values()) { stringValuesMap.put(state.toString().toUpperCase(), state); } } //////////////////////////////////////////////////////////////////////////// // Static methods // //////////////////////////////////////////////////////////////////////////// /** * Returns a TaskState with a value represented by the * specified String. The TaskState returned * represents existing value only if specified String * matches any String returned by toString method. * Otherwise null value is returned. *

* @param stateStr Value containing TaskState * toString representation. * @return TaskState value represented by String * or null if value was not recognized. */ public static TaskState toValue(final String stateStr) { if (stateStr != null) { return (stringValuesMap.get(stateStr.toUpperCase())); } else { return null; } } //////////////////////////////////////////////////////////////////////////// // Methods // //////////////////////////////////////////////////////////////////////////// /** * Convert TaskState value to String. *

* @return A String representation of the value of this object. */ @Override public String toString() { switch (this) { case READY: return READY_STR; case RUNNING: return RUNNING_STR; case COMPLETED: return COMPLETED_STR; case FAILED: return FAILED_STR; // This is unrecheable. Returned null value means that some // enum value is not handled correctly. default: return null; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy