You may add a wrapper like this. So your class would be:
class MetaData {
public _<String> version;
public _<String> compression;
}
And use it the way you want it:
class AnyOther {
public void instantiate() {
MetaData m = new Metadata();
m.version = new _<String>("v1.0");
m.compression = new _<String>("compression");
_<String> currentVersion = m.version;
System.out.println( "Before: " + currentVersion );
changeIt( m );
System.out.println( "After: " + currentVersion );
}
private void changeIt( MetaData m ) {
_<String> currentVersion = m.version;
currentVersion.s("1.1");
}
}
Should print
Before: 1.0
After: 1.1
But, I think it is a bit awkward.
If your are programming in Java you may consider leave the responsibility of that value to the holding class "MetaData" rather and stripping away its attributes.
class AnyOtherJavaWay {
public void instantiate() {
MetaData m = new Metadata();
m.version = "v1.0";
m.compression = "compression";
String currentVersion = m.version;
System.out.println( "Before: " + currentVersion );
changeIt( m );
// you have to get it again...
currentVersion = m.version;
System.out.println( "After: " + currentVersion );
}
private void changeIt( MetaData m ) {
// let the objet "m", hold the new value
// it is his ( its'??? ) responsability
m.version = "1.1";
}
}
Which yields the same result.