mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-08 19:14:52 +00:00
rolled back the Mutable change. It doubled the size of a mutable instance, and as it wrapped another object, doubled the work for garbage collection
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137851 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9840e7e0e8
commit
f16ee38329
@ -19,25 +19,49 @@
|
||||
* A mutable <code>Byte</code>.
|
||||
*
|
||||
* @since 2.1
|
||||
* @version $Id: MutableByte.java,v 1.2 2004/06/13 06:18:49 bayard Exp $
|
||||
* @version $Id: MutableByte.java,v 1.3 2004/06/24 04:20:46 bayard Exp $
|
||||
*/
|
||||
public class MutableByte extends MutableNumber {
|
||||
|
||||
/**
|
||||
* Internal value.
|
||||
*/
|
||||
private byte value;
|
||||
|
||||
/**
|
||||
* Instantiates with the specified value
|
||||
* @param value a value.
|
||||
*/
|
||||
public MutableByte(byte value) {
|
||||
super();
|
||||
setValue(new Byte(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValue(byte value) {
|
||||
setValue(new Byte(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value a <code>Number</code>
|
||||
* @return a <code>Byte</code>
|
||||
*/
|
||||
public Object getValue() {
|
||||
return new Byte(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value a <code>Byte</code>
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
setValue(((Number)value).byteValue());
|
||||
|
@ -16,29 +16,47 @@
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
/**
|
||||
* A mutable <code>Double</code>.
|
||||
* A mutable <code>Double</code>
|
||||
*
|
||||
* @since 2.1
|
||||
* @version $Id: MutableDouble.java,v 1.2 2004/06/13 06:18:49 bayard Exp $
|
||||
* @version $Id: MutableDouble.java,v 1.3 2004/06/24 04:20:46 bayard Exp $
|
||||
*/
|
||||
public class MutableDouble extends MutableNumber {
|
||||
|
||||
/**
|
||||
* Internal value.
|
||||
*/
|
||||
private double value;
|
||||
|
||||
/**
|
||||
* Instantiates with the specified value
|
||||
* @param value a value.
|
||||
*/
|
||||
public MutableDouble(double value) {
|
||||
super();
|
||||
setValue(new Double(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
setValue(new Double(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return (long)this.value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return (int)this.value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return new Double(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value a <code>Number</code>
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
setValue(((Number)value).doubleValue());
|
||||
}
|
||||
|
@ -16,29 +16,48 @@
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
/**
|
||||
* A mutable <code>Float</code>.
|
||||
* A mutable <code>Float</code>
|
||||
*
|
||||
* @since 2.1
|
||||
* @version $Id: MutableFloat.java,v 1.2 2004/06/13 06:18:49 bayard Exp $
|
||||
* @version $Id: MutableFloat.java,v 1.3 2004/06/24 04:20:46 bayard Exp $
|
||||
*/
|
||||
public class MutableFloat extends MutableNumber {
|
||||
|
||||
/**
|
||||
* Internal value.
|
||||
*/
|
||||
private float value;
|
||||
|
||||
/**
|
||||
* Instantiates with the specified value
|
||||
*
|
||||
* @param value a value.
|
||||
*/
|
||||
public MutableFloat(float value) {
|
||||
super();
|
||||
setValue(new Float(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValue(float value) {
|
||||
setValue(new Float(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return (int)this.value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return (long)this.value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return new Float(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value a <code>Number</code>
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
setValue(((Number)value).floatValue());
|
||||
}
|
||||
|
@ -19,26 +19,45 @@
|
||||
* A mutable <code>Integer</code>.
|
||||
*
|
||||
* @since 2.1
|
||||
* @version $Id: MutableInteger.java,v 1.2 2004/06/13 06:18:49 bayard Exp $
|
||||
* @version $Id: MutableInteger.java,v 1.3 2004/06/24 04:20:46 bayard Exp $
|
||||
*/
|
||||
public class MutableInteger extends MutableNumber {
|
||||
|
||||
/**
|
||||
* Internal value.
|
||||
*/
|
||||
private int value;
|
||||
|
||||
/**
|
||||
* Instantiates with the specified value
|
||||
*
|
||||
* @param value a value.
|
||||
*/
|
||||
public MutableInteger(int value) {
|
||||
super();
|
||||
setValue(new Integer(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
setValue(new Integer(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return new Float(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value a <code>Number</code>
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
setValue(((Number)value).intValue());
|
||||
}
|
||||
|
@ -16,29 +16,47 @@
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
/**
|
||||
* A mutable <code>Long</code>.
|
||||
* A mutable <code>Long</code>
|
||||
*
|
||||
* @since 2.1
|
||||
* @version $Id: MutableLong.java,v 1.2 2004/06/13 06:18:49 bayard Exp $
|
||||
* @version $Id: MutableLong.java,v 1.3 2004/06/24 04:20:46 bayard Exp $
|
||||
*/
|
||||
public class MutableLong extends MutableNumber {
|
||||
|
||||
/**
|
||||
* Internal value.
|
||||
*/
|
||||
private long value;
|
||||
|
||||
/**
|
||||
* Instantiates with the specified value
|
||||
* @param value a value.
|
||||
*/
|
||||
public MutableLong(long value) {
|
||||
super();
|
||||
setValue(new Long(value));
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public void setValue(long value) {
|
||||
setValue(new Long(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return (int)this.value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return new Long(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value a <code>Number</code>
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
setValue(((Number)value).longValue());
|
||||
}
|
||||
|
@ -22,55 +22,24 @@
|
||||
* A mutable <code>Number</code>.
|
||||
*
|
||||
* @since 2.1
|
||||
* @version $Id: MutableNumber.java,v 1.2 2004/06/13 06:18:49 bayard Exp $
|
||||
* @version $Id: MutableNumber.java,v 1.3 2004/06/24 04:20:46 bayard Exp $
|
||||
*/
|
||||
public abstract class MutableNumber
|
||||
extends Number
|
||||
implements Comparable, Mutable, Serializable {
|
||||
|
||||
private Number value;
|
||||
|
||||
public MutableNumber() {
|
||||
MutableNumber() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param a <code>Number</code>
|
||||
*/
|
||||
protected void setValue(Number value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Number overrides
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
public float floatValue() {
|
||||
return this.value.floatValue();
|
||||
return (float)doubleValue();
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return this.value.longValue();
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value.doubleValue();
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return this.value.intValue();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Mutable overrides
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @return a <code>Number</code>
|
||||
*/
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
// ----------------------------------------------------------------
|
||||
// Object overrides
|
||||
// ----------------------------------------------------------------
|
||||
@ -80,7 +49,7 @@ public String toString() {
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.value.hashCode();
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,7 +61,7 @@ public int hashCode() {
|
||||
* @see #compareTo(Object)
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
return this.value.equals(obj);
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
@ -16,29 +16,47 @@
|
||||
package org.apache.commons.lang.mutable;
|
||||
|
||||
/**
|
||||
* A mutable <code>Short</code>.
|
||||
* A mutable <code>Short</code>
|
||||
*
|
||||
* @since 2.1
|
||||
* @version $Id: MutableShort.java,v 1.2 2004/06/13 06:18:49 bayard Exp $
|
||||
* @version $Id: MutableShort.java,v 1.3 2004/06/24 04:20:46 bayard Exp $
|
||||
*/
|
||||
public class MutableShort extends MutableNumber {
|
||||
|
||||
/**
|
||||
* Internal value.
|
||||
*/
|
||||
private short value;
|
||||
|
||||
/**
|
||||
* Instantiates with the specified value
|
||||
* @param value a value.
|
||||
*/
|
||||
public MutableShort(short value) {
|
||||
super();
|
||||
setValue(new Short(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValue(short value) {
|
||||
setValue(new Short(value));
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return new Short(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value a <code>Number</code>
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
setValue(((Number)value).shortValue());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user