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

com.gemstone.gemfire.internal.lang.InOutParameter Maven / Gradle / Ivy

There is a newer version: 2.0-BETA
Show newest version
/*
 * Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
 *
 * 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. See accompanying
 * LICENSE file.
 */

package com.gemstone.gemfire.internal.lang;

/**
 * The InOutParameter class is a utility class useful for creating methods with in/out parameters.  This class
 * constitutes a wrapper around the value it encapsulates.  In essence, an instance of this class is the same thing
 * as it's value, as determined by the equals method and so this class just serves as a kind of holder for it's value.
 * 

* @author John Blum * @param the expected Class type of the parameter's value. * @since 6.8 */ public class InOutParameter { private T value; /** * Default constructor creating an instance of the InOutParameter with a null initial value. */ public InOutParameter() { } /** * Constructs an instance of the InOutParameter with the specified value. *

* @param value the initial value of this parameter. */ public InOutParameter(final T value) { this.value = value; } /** * Gets the value of this in/out parameter. *

* @return the value of this in/out parameter. */ public T getValue() { return value; } /** * Sets the value of this in/out parameter. *

* @param value the Object value to set this in/out parameter to. */ public void setValue(final T value) { this.value = value; } /** * Determines whether the in/out parameter value is equal in value to the specified Object. Note, this is not * typically how an equals method should be coded, but then this is not your typical class either! *

* @param obj the Object value being compared for equality with this in/out parameter value. * @return boolean value indicating whether this in/out parameter value is equal to the specified Object. */ @Override public boolean equals(Object obj) { if (obj instanceof InOutParameter) { obj = ((InOutParameter) obj).getValue(); } return ((obj == value) || (value != null && value.equals(obj))); } /** * Computes the hash value of this in/out parameter value. *

* @return an integer value constituting the computed hash value of this in/out parameter. */ @Override public int hashCode() { return (value == null ? 0 : value.hashCode()); } /** * Gets the String representation of this in/out parameter value. *

* @return a String value representing the value of this in/out parameter. */ @Override public String toString() { return String.valueOf(value); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy