Java tutorial
/** * Copyright (C) 2012 Ness Computing, Inc. * * Licensed 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 com.nesscomputing.lifecycle; import java.util.Locale; import javax.annotation.Nonnull; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; /** * Describes a lifecycle stage. This is intentionally not an enumeration to allow construction of arbitrary stages outside the * released lifecycle component. */ public class LifecycleStage { /** Well known "configure" stage. */ public static final String CONFIGURE = "configure"; public static final LifecycleStage CONFIGURE_STAGE = new LifecycleStage(CONFIGURE); /** Well known "announce" stage. */ public static final String ANNOUNCE = "announce"; public static final LifecycleStage ANNOUNCE_STAGE = new LifecycleStage(ANNOUNCE); /** Well known "unannounce" stage. */ public static final String UNANNOUNCE = "unannounce"; public static final LifecycleStage UNANNOUNCE_STAGE = new LifecycleStage(UNANNOUNCE); /** Well known "start" stage. */ public static final String START = "start"; public static final LifecycleStage START_STAGE = new LifecycleStage(START); /** Well known "stop" stage. */ public static final String STOP = "stop"; public static final LifecycleStage STOP_STAGE = new LifecycleStage(STOP); private final String name; /** * Creates a new LifecycleStage. * @param name Name of the stage. Must not be null. */ public LifecycleStage(@Nonnull final String name) { this.name = name.toLowerCase(Locale.ENGLISH); } public String getName() { return name; } // // Autogenerated by commons4e // @Override public boolean equals(final Object other) { if (!(other instanceof LifecycleStage)) { return false; } final LifecycleStage castOther = (LifecycleStage) other; return new EqualsBuilder().append(name, castOther.name).isEquals(); } private transient int hashCode; @Override public int hashCode() { if (hashCode == 0) { hashCode = new HashCodeBuilder().append(name).toHashCode(); } return hashCode; } private transient String toString; @Override public String toString() { if (toString == null) { toString = new ToStringBuilder(this).append("name", name).toString(); } return toString; } }